Teensy to Teensy communication via Xbee

Status
Not open for further replies.

jliggot

New member
Hi. I'd love to get some project advice please. I have two roving robots, each gathering a lot of sensor data that they need to share with each other via xbee. The robots are moving quickly and using a PID algorithm to move, so the cycle speed of the Arduino loop() function on the Teensy's is critical. I want to minimize latency in that function and of course I want to make sure the serial buffers on the Teensy don't get overloaded as they share data from the Xbees.

I am wondering what is the best way for the xbees to share data. If latency in loop were not an option, I was thinking the best way might be to use a "call and response" approach, where rover 1's loop() function would include a call to a function where it shares its data with rover 2 and at the same time requests data back from rover 2. It would have to have some timer associated with it to break out of the call function if the data from rover 2 doesn't arrive in time. But I am nervous about latency with this approach because each Teensy would be waiting for two XBee communications to execute before proceeding.

But then thinking about latency, I was wondering if I could put the call and response in a thread using the Teensy Thread library. Another option I am considering would be to move the Xbee serial operations to a separate micrcontroller, like an ATtiny. Each Teensy would be connected to an ATtiny via i2c. The Teensy would send sensor data to the ATtiny via i2c and at the same time request the most recent sensor data from the other rover. The ATtiny's would be sharing sensor data with each other back and forth continuously via serial. I could put a delay in to ensure the buffers weren't saturated. The advantage of that would be that the latency on the Teensy's would be minimized bc the Teensy's wouldn't be waiting for the xbees to send data but the data might be slightly stale depending on any delay needed to keep the ATtiny serial buffers from becoming overloaded.

Perhaps I'm not even thinking about this all properly and there is a pretty standard way of doing this. Any thoughts on a recommended approach would be appreciated!

Thanks.
 
Status
Not open for further replies.
Back
Top