# Building Wireless Control Applications with XBee and LabVIEW
## 4 Experimental Tests
### Message Delay  
The third experiment was aimed at measuring the full message delay between sending a signal from the sensor to the computer and its reception at the actuator (see Figure 5). The time difference between sending and receiving was measured using an oscilloscope. These tests were also carried out at several distances--0 m (very close), 0.5 m, 2 m, and up to 5 m. In order to compare the message delay, a wired connection was also used as a reference.  
The message delay was measured ten times for the distances specified above. Table 2 presents the mean and standard deviation for the message delay at several distances. Note that the message delay measured was a two-way delay which involved all steps shown in Figure 5.  
Two conclusions could be drawn from this experiment--(1) the distance had a reduced impact on the delay (at least up to 5 m), and (2) the delay was significantly lower in the wired connection, as expected. For this experiment, the XBee modules were configured to transmit the data at a baud-rate of 9600 bits per second. Considering that the frames were around 100 bits, every connection at 9600 bps took around 10 ms. There were several serial connections to close the loop (see Figure 5)--(1) from the sensor XBee to the XBee at the NI myRIO; (2) from the XBee to the LabVIEW application and back to the XBee; (3) from the XBee at the NI myRIO to the actuator XBee; and (4) from the actuator XBee to the Arduino Uno. This could be explained by the mean time (which was around 46 milliseconds) and a higher standard deviation, since there were several stages involved. To reduce the time needed to translate the data into a frame, a higher baud-rate could be used. A second test was done at three different baud-rates at a very short distance. The obtained results are shown in Table 3.  
The table shows the influence of the communication speed configuration (in bits per second) at the delay. For example, at a baud-rate of 38,400, the time to send one frame would be considerably shorter and it would have a big impact on the closed loop communication. However, the authors expected a higher dropout rate. If the time used by the computer to process the data was considered to be the same for all tests (regardless of the communication speed), the following four stages were involved:  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Test** & **Distance (m)** & **Wired** & **0** & **0.5** & **2** & **5** \\ \hline Mean (ms) & 3 & 45.9 & 45.5 & 46.2 & 47.2 \\ \hline Std. Dev. & 0.60 & 3.93 & 5.25 & 4.92 & 6.39 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Message delay for 9600 bps.  
Figure 5: Layout for measuring the message delay.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Test** & **Speed (bps)** & **9600** & **38,400** & **57,600** \\ \hline Mean & 45.9 & 24.1 & 22.6 \\ \hline Std. Dev. & 3.93 & 4.07 & 3.95 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Message delay at different baud-rates.  
1. The communication between the XBee module at the sensor and the XBee module at the control computer. The frames considered had a 100 bits size.
2. At the control computer, the message was received and passed to the application. As shown in Figure 5, the influence of several components could introduce jitter.
3. The generated frame was serialized and immediately transmitted by the XBee.
4. After the entire frame was received by the actuator XBee, the reference was extracted from the frame and sent to the Arduino.