# Building Wireless Control Applications with XBee and LabVIEW
## 5 Case Study
### Test Results  
During the tests, the reference signal was created by the LabVIEW application executed at the NI myRIO and was sent to the PEA by means of the XBee communication. The PEA was positioned accordingly and the measured position was sent back to the LabVIEW program, which executed the PI algorithm aimed at correcting the position errors that occurred in the positioning process of the PEA. Several reference signals were used to analyze the behavior of the system in different situations. In particular, a ramp signal, a square signal, and a steady reference signal was used. The first test illustrates the behavior of the system without using close loop control schemes, i.e., as an open loop process. In this test, it could be observed that when a closed loop controller was not used, the error between the reference and the measured value was steady and noticeable. For this test, it was around 25% of the reference value, so it was necessary to correct this error, see Figure 10.  
In the following tests, the controller was a basic PI controller, with a value of 1.000 for the proportional gain, Kc, while the integral time Ti, was set to 0.001 min. Figure 11 shows the detail of one longer test, in which the system follows a ramp signal. The sampling frequency used in the test was 100 milliseconds and the duration of the shown sample was around 150 s. In this figure, the effect of the missed packages can be easily seen as the vertical orange lines out of the ramp input signal. In Figure 11, seven missed messages that made around 0.5% of the sent messages can be seen. The analysis of several tests indicated that sometimes the packages were corrupted and other times these were not delivered correctly. For this reason, two mechanisms were introduced in the software, in order to detect these wrong or lost packages, namely (1) checking the integrity of the messages by means of the checksum sent in the XBee frames and (2) analyzing the sequence number to detect the missed packages. These mechanisms were introduced both in the NI myRIO LabVIEW program and the Arduino sketch. Additionally, it was necessary to introduce a policy to deal with the missed messages. The authors decided that a policy that would be easy to implement was to always store the last known value, so that in case of a missing message, the software could use the previous known value. Therefore, the remaining tests were executed with this policy implemented in the software. The following tests were performed at the following conditions: (1) 5 m distance between the controller, the LabVIEW program embedded in the NI myRIO, and the sensor/actuator block connected to the Arduino Uno; (2) a sampling period of 100 milliseconds, and (3) a resolution of 1023. These graphs show, both, the reference signal generated at the controller and the actual position variable,  
Figure 10: Without a proportional integral (PI) controller. measured by the Arduino. These tests were executed with different reference signals in order to analyze the response of the PI in different situations. The first test was executed for a duration of 200 s (2000 samples at 100 ms). This test was aimed at analyzing the behavior of the PI controller to smooth the reference variations. An ascending/descending ramp signal was used for this. The results of the test are shown in Figure 12. Note that, both, the sent value (reference, generated at the controller) in blue, and the received value (PEA position measured by the integrated sensor) in red, are overlapping most of the time, even if with a short delay; identified in Section 4. Figure 13 shows the percentage of the difference between both signals, the reference signal and the measured value over the maximum value, 1023. It can be seen that for this test, the error was below 1% of the maximum value (1023) almost for the whole test. The second test was aimed at showing the behavior of the system when a strong control action was applied to the PEA. In this case, the reference position was changed from 0 to 512.