Tuesday, March 10, 2009

Timing of Arduino communication with GPS on the same serial line

The problem with using one serial port for two devices (see previsous post), is timing.

My Holux GPSlim 240 sends data every second, and satellite info every 5 seconds. I estimate that maximum number of charaters received is about 500, so it takes only 500ch/(38400bps /8bit/ch) ~ 0.1 sec to receive the whole GPS "datapack". That leaves 0.9 secods for arduino communication. Just to be on the safe side, I think 0.2 secods for gps-data should be reserved. The good thing is that sending data to arduino can happen at any time.

Here's my plan for the flow control from arduino:

1. OpenWrt: Wait for GPS data receive to end
2. OpwnWrt: Send "Ready to receive" notification to Arduino
3. Arduino can reply for 0.7 seconds. (Sensor telemetry data etc.)
4. Arduino goes to "no send mode", and only receives serial data.
5. There's a 0.1-0.2s gap between the last Arduino data and the next GPS data.

Naturally I'll implement a checksum for data coming from arduino just to be safe.

No comments:

Post a Comment