Pages: [1]   Go Down
Author Topic: Bi-directional Simultaneous Xbee Communication for vehicle control and telemetry  (Read 575 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Relevant Equipment used:

1. Two Xbee Series 1 modules
2.  Two Gravitech Xbee shields for the Arduino Nano
3.  Two Arduino Nano V3.0

Background:  I have a rocket that for all intents and purpose is a RC model version of the Space X Grass Hopper rocket.  It  balances in a similar manner as the traditional cart and inverted pendulum with the exception that this entire system flies utilizing counter-rotating brush-less motors for lift.  As of now, I send control signals to the motors from an Arduino connected to my laptop to the Arduino on the vehicle.

Objective of this post:  The goal of this post is to be able to determine how to send multiple sets of data from the control station (the laptop) to the vehicle.  For example, I wish to be able to send not only speed or altitude commands to the vehicle, I would also like to send position commands.  Continuing on with that, when the vehicle is not receiving any commands from the ground station, I would like the vehicle to transmit information to the laptop, such as pitch or roll angles, current GPS information such as signal quality or acquired satellites, etc.

Just to be clear, I don't have any problem sending any of the data one way.  For example, if I do not attempt to send any command from the ground station, then I can easily send pitch or roll angles to the laptop from the vehicle.  The issue here is true two-way or simultaneous communication.

Here is my initial communication pseudo-code:

Ground - Station:

listen for data from computer

if there is data {
 what kind of data is it (position or Altitude)

if data is position
{ format for position and send to vehicle}

elseif data is Altitude
{format for Altitude and send to vehicle}

else listen for data from the vehicle


if there is data from the vehicle
{print in the serial monitor}

Vehicle :

if data is available from the computer
{what kind of data is it (position or Altitude)}

if data is position
{change the position portion of control system}

elseif data is Altitude
{change altitude portion of control system}

else send data to computer

Major Concerns:
1.  Do I need to change the modes of the Xbee to make this work?  To clarify, do I need to change from AT or point to point mode to API mode?

2.  Do I need to format each set of data with specific termination characters.  For example, the Arduino knows when altitude data is being sent because it is formatted with these start and end characters '<'  '>'.  Then the GPS coordinates could be formatted with '\'  '/' start and end characters.  This would be utilized for every type of data being sent.  Would this work?  Are there better alternatives?  If so what are they?

That should do it for now.  I would be happy to clarify if anyone has further questions. 
Just for reference, I have only been working with the Arduino for about 2 months.  I am a recent Mechanical Engineering graduate with little coding experience for this type of application.  Therefore, any advice, tricks, tips, etc. would be greatly appreciated.

As a side note, I am curious to learn more about efficient code writing and data structures, etc.  Any good starting references would be greatly appreciated.
 


 





 
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
1.  Do I need to change the modes of the Xbee to make this work?  To clarify, do I need to change from AT or point to point mode to API mode?
Bi-directional communication works in either AT or API mode, if the XBees are properly configured.

Quote
2.  Do I need to format each set of data with specific termination characters.  For example, the Arduino knows when altitude data is being sent because it is formatted with these start and end characters '<'  '>'.  Then the GPS coordinates could be formatted with '\'  '/' start and end characters.  This would be utilized for every type of data being sent.  Would this work?  Are there better alternatives?  If so what are they?
Yes, it would work. Yes, there are better way. Use the same delimiters for all packets. Add a packet type in the packet - A for altitude, G for GPS, etc.

Quote
I am a recent Mechanical Engineering graduate with little coding experience for this type of application.
I really don't understand this. I'm a Mechanical Engineer, too. But, I got my degree in 1979. And, when I got my degree I COULD write programs. In FORTRAN, rather than C/C++, but logical thinking is the key, not the particular language. Computers are far more prevalent now than they were then, so the availability of programming classes has gone up. The need to, as an engineer, be able to use computers has not gone down. Only being able to use programs someone else has written is a career limiting position, so I can't understand why so many recent engineering degree owners can't program.
Logged

Pages: [1]   Go Up
Jump to: