Hello. I’m transmitting two ADC channels with a baud rate of 9600, 8bit, in unicast mode. The XBee system is set up to collect data from the ADC channels at 50Hz (IR=14 (Hex for 20ms sampling), TX=1).
I lose a very consistent amount of data when recording both in Matlab and Labview. For example 10s of recording results in 490 data points (instead of 500) and 20s of recording results in 980 data points (instead of 1,000) for each ADC channel. The buffer is never overloaded (max size at time of read in example below is 96 bytes), although the size is a bit variable (Stdev = 2.98 bytes). While I understand there is transmission time, the data is still being recorded into the buffer at 50Hz and thus I should still get the correct amount of data, right? Checking the buffer after close shows about 3 bytes so it isn’t just missing end data. Additionally the data lag seems to increase with time (see attached figure) suggesting that the sample rate is < 50Hz.
I would greatly appreciate any feedback or suggestions! Thank you.
Example of Matlab Collection Code
s = serial(‘COM5’);
fopen(s);
A=;
i=1;
fread(s,s.BytesAvailable); % Clear buffer
tic;
while toc<10;
pause(0.1); % Changing this changes buffer size but not the resulting data size.
Atemp=fread(s,s.BytesAvailable);
l(i)=length(Atemp); % So I can check if the buffer reached capacity
So set the DL, DH parameters so the XBee sends the data to the receiving XBee instead of on unicast.
This then requires the sending XBee to get an ACK and it will re-send if its doesn’t.
unicast mode does not have any error checking or ACK of received data packets. If the packet get RF interference and is not received then it disappears into the aether.
I have series 2 Xbees. I’ve switched to broadcast mode with no effect of data. Switching to 10Hz sampling rate decreases the amount of loss but there is still loss with higher collection times. For example 10s pretty consistently results in 100 data points for one channel, 20s in ~199, 40s in~397, and 60s in ~595. I would ideally like to use a higher frequency. Does this help diagnose the problem? Am I wrong to think I shouldn’t have any loss? Is there an expected amount of loss with the XBee system?
The sample loss is very consistent so I do not feel that it is likely to be transmission interference. I tried most of the other channel options. None of them resulted in an improvement, although some were certainly worse in terms of data loss and variability.
I recall there’s a way to use the XBee internal firmware to pack several samples in one transmission packet. Can you tolerate that?
1 sample per transmission packet (frame), 10 frames per second, with the XBee series 1 in 802.15.4 mode is no problem I routinely do 16 per second, with each frame having about 50 bytes (half the 100 byte max).
Xbee series 2 using ZigBee will have a lower rate due to the Zigbee overhead.
(ZigBee is not a synonym for 802.15.4 much like TCP/IP is not a synonym for Ethernet 802.3. Many don’t know this).