Xbee Error checking

Hi,

I currently have a Leonardo and a camera module. The camera module is connected to the Arduino by the means of a SoftwareSerial connection. To the same Arduino, there's also connected a Series 2 Xbee module.

What I need is to send the data being received from the camera back to my pc via the Xbee module. The images are of 120 by 160 pixels. That baud rate is setted at 115200.

The main problem is linked to the loss of information during the transmission. One wrong byte and everything goes down. Is there any way of error check the data received by the pc? How can I assure the data's integrity? Does the module have some sort of mechanisms for this? How can I do it? I guess a tutorial would be helpful here.

Thanks

XBees are low-bandwidth devices. I assume you're using transparent mode? I would not expect to send a large amount of data like that all in one continuous blast. The XBee will break it into packets that contain no more than 84 bytes of data. In transparent mode, it will end up tripping all over itself trying to send packets as fast as possible and also verify the previous packet was sent successfully, retry when needed, etc.

I would use API mode, packetize it myself, send one packet at a time then wait for the ACK before sending another. Be patient because it won't be as fast a process as a person might expect. The baud rate of the serial interface to the XBee has absolutely nothing to do with the RF data link speed, which is a constant, but affected by transmission protocol overhead, other network traffic, etc.

Read the product manual on Digi.com and/or Google for XBee ZB (S2) API mode.

I just finished reading the manual's section which refers to API mode.

I got the idea. Would it help me if I'd use the Xbee's libraries? both made for the Arduino and the pc? Instead of making a new frame generator on my own?

How slow do you suppose it will go? Will it transfer an image in less than a second? seconds or dozens of seconds? I don't have any prior experience with this operational mode. Considering the image's size to be at 19200 bytes and the distance between the modules at 2 meters.

I use Andrew Rapp's library, it works great so I recommend it wholeheartedly: https://code.google.com/p/xbee-arduino/

As for how long it will take to transfer the image, I have no experience to draw on. All my XBee applications have been small amounts of data at relatively long intervals.

I hope you can give it a go though, because I'd be interested to hear the results.

As soon as I finish this matter I'll post what happened.

But until then, some questions have risen up in my head. Let's say we have a bunch of packets that the microcontroller has to send to pc. Every packet has the maximum size of 84 bytes, in order to efficiencies the speed of data (the loss of data over large packets is relatively small because the distance is small). What if the remote xbee sends a packet and shortly after the TX response confirmation sends another one and rewrites the receiver's buffer before the data was read. How can I prevent this thing from happening? Is there a mechanism to notify the sender?

And the other question is: can you indicate a library for xbee suitable for pc environments?

RobertEagle: As soon as I finish this matter I'll post what happened.

But until then, some questions have risen up in my head. Let's say we have a bunch of packets that the microcontroller has to send to pc. Every packet has the maximum size of 84 bytes, in order to efficiencies the speed of data (the loss of data over large packets is relatively small because the distance is small). What if the remote xbee sends a packet and shortly after the TX response confirmation sends another one and rewrites the receiver's buffer before the data was read. How can I prevent this thing from happening? Is there a mechanism to notify the sender?

The XBee ZB product manual does not discuss buffering method or sizes. I certainly have to think that there is room for more than one packet but of course no matter what, it is a finite resource, and not a large one at that.

Note in the ZigBee Transmit Status frame (p 112) the Delivery Status field has an entry (0x2C) "Resource error lack of free buffers, timers, etc." That would provide notification, but may not be sufficient for prevention or even for recovery. Even if the sender knows that the receiver ran short on resources, that does not tell it what the last packet successfully received was.

Best practice is to ensure that the microcontroller application always gives top priority to reading the XBee. But I would not think this sufficient in a high-link-utilization scenario like you are envisioning. It will probably require an application-level protocol to sequence number the packets and acknowledge receipt. This may be a real challenge for a microcontroller with limited SRAM space for buffer pools. Keeping the packet size small will help but of course this works against transmission efficiency. Again, XBees are low bandwidth devices, intended for occasional transmission of relatively small packets, so this application runs somewhat contrary to the XBee design goals.

And the other question is: can you indicate a library for xbee suitable for pc environments?

I cannot, but I would think that Andrew Rapp's library could be a possible starting point, assuming a C++ compiler is available on the PC.

Hi I have a question, what happen when the number of retries is reached? what happen next?