Shop OBEX P1 Docs P2 Docs Learn Events
Communicating with XBee: Near real time control — Parallax Forums

Communicating with XBee: Near real time control

S. MartinS. Martin Posts: 5
edited 2010-04-09 01:04 in General Discussion
I've got two Javelin modules and two Digi XBee Pro 900 DigiMesh RF modems. Currently I'm doing a FPV RC airplane project and was hoping to use these as my control system. Being an airplane, I need as close to real time control as possible.

I set up a demo with one Tx Javelin reading a pot, sending it to the Tx radio, to the Rx radio, to the Rx Javelin, to control a servo. Just a bench test to see how it goes.

Problem is, it goes slow. Input will take a few seconds to register on the Rx radio, and another five or ten to be seen as servo movement. I'm fairly new to this realm, but not totally incompetent. The communication is UART, with handshaking, set at 57600 baud (highest Javelin will let me go), 1 stop bit. Data being sent is a single byte, read from the pot, over and over. I've included the Rx and Tx code. Nothing elegant - just quick and dirty to get a test going.

Perhaps I'm sending too much too fast? I know these microcontrollers and radios have been used together to control things before, so it has to get faster then this. What simple newb thing am I missing?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-04-08 06:50
    Limit baudrate to 28800. That is the highest speed at which the
    javelin can·receive without missing any byte.

    regards peter
    ·
  • S. MartinS. Martin Posts: 5
    edited 2010-04-09 01:04
    Thank you for the reply.

    Unfortunately the Xbee doesn't have a 28800 setting. However I do believe I found my problem. It seems I was 'over-buffering' for lack of a better term. In the code I have posted, the Javelin checks, sends, receives and updates the servo position as fast as it can. It seems the XBee couldn't talk to the microcontroller as fast on the Rx side as it can on the Tx side. Eventually it built a huge pool of buffered data (hence the slow response time). I modified the Tx code to wait 20 ms before reading and sending the data. I chose that delay value because the servo control pulse itself has to have some idle time to function properly (about 20 ms). So no matter how fast I update the data, the servo can only be updated once every 20 ms.

    Basically I made the code run slower to make the servo respond faster turn.gif .

    Perhaps this was a given for most everyone. If not, there it is.
Sign In or Register to comment.