# Building Wireless Control Applications with XBee and LabVIEW
## 3 Description of the Control Layout  
In this work, star-topology was considered for the WNCS. The controller, implemented at the central device, received the data from the distributed sensors, executed the control algorithm, and sent the reference to the distributed actuators, in order to control the plant. The controller device was implemented with a powerful platform, namely a NI myRIO device. This was a real-time embedded computer with FPGA capabilities, which was able to execute complex control algorithms by means of the LabVIEW software. The NI myRIO used a dual-core ARM Cortex-A9 processor and ran the NI Linux Real-Time OS. The CompactRIO architecture (also manufactured by National Instruments), followed the same philosophy but it was based on a set of modules. Thus, it might have better adapted to complex systems, given that it offered scalable computing power and different input and output modules. In addition, both the NI myRIO and the CompactRIO architecture allowed the implementation of easy hybrid control systems, i.e., those in which remote devices are connected by means of both wired and wireless links. For the wireless communication with sensors and actuators, the XBee technology was chosen. National Instruments and several other companies designed the NI VISA protocol, aimed at easing the communication with different devices. In particular, the NI VISA protocol allowed the connection between the XBee antenna located at the control computer and the LabVIEW application that executed the control algorithm. In this work, the authors aimed at carefully analyzing the behavior of control applications that followed the layout shown in Figure 1. For this purpose, the authors analyzed a basic single input single output (SISO) closed loop control application with (1) one sensor, (2) the control algorithm (executed at the computer), and (3) one actuator. Both the communications and the control algorithm were especially intertwined in the design of WNCS, consequently, the introduction of more sensors and actuators should be adequately scheduled, in order to manage the communication bandwidth and reduce the impact of collisions on the QoS performance. One possible approach would be the introduction of time-triggered approaches. Several TDMA scheduling algorithms for the wireless sensor networks have been discussed in [28]. Figure 1 shows the sensor connected to the physical system, connected to an XBee module like the XBee End Device. The use of a microcontroller allowed the execution of any pre-processing algorithm for the acquired value of the sensor (represented as H(z) in Figure 1). The measured values were serialized and sent to the NI myRIO device (which ran the control algorithm in LabVIEW). The computer was connected to the XBee module, configured as the XBee Coordinator, by means of a USB link. The LabVIEW VISA device has proven to be the simplest alternative to manage the data received/sent by the XBee module. The control algorithm generated the signal to be serialized and sent to the actuator, configured as an XBee End Device. Again, the use of a microcontroller on the actuator's side might be necessary for executing F(z). XBee modules could be programmed in two modes--the AT mode and the API. The latest provided a higher flexibility, since it allowed a formatting of the frames, to better adapt to the applications. However, it required a lower programming level, since the programs must dig into the frames to get the information. Regardless, this was considered the best approach for this kind of applications and, consequently, it was used at the sensor, controller, and actuator, to define the application protocol over XBee. Afterwards, the format of the API frames was briefly described.