NugePilot: Communication Timing Issue

3689513816?profile=original

Hi,

For the past year I have been engineering my own autopilot shield for the Arduino Mega(and unintentionally the Due). I hope to be finished by the time AVC rolls around, but I have run into an issue. I currently an using 3 separate Arduinos(Mega: autopilot, ArduIMU, and Atmega328: fail safe) and I am having trouble communicating with them efficiently.  Currently I have the Mega just waiting for a start data signal(at the beginning of a steam of data. Ex. "###") from the fail safe or ArduIMU, and then it decodes the data string following the start signal. But sometimes it can take upwards of 130ms per system to receive one string of data(because its waiting for the start signal. not because of excess data). 130ms for ArduIMU and 130ms for Fail safe. This isn't fast enough. The problem is that I am waiting for the two arduinos(Ex. arduIMU and mega) to be in sync but that doesn't happen very often. I have thought about using interrupts, but then I was afraid of interrupting crucial sections of the code. I have looked into MAVlink protocol because, If I understand it correctly, the heartbeat that it sends out is used for synchronization between devices? 

I was hoping someone could point me in a direction that would help me synchronize communications in a way that does not involve a lot of waiting.

Thanks in advance!

Daniel

If you are interested in reading more about the project, I have a blog.(Way out of Date and no pictures yet) 

(Sorry for posting on the main page, I didn't see a suitable place in the forums)

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • So after trying to communicate 4 or so different ways, I figured out that the ArduIMU was running slow. So it couldn't send data any quicker than 10 hz. I modified the ArduIMU code and now I am getting data 50 hz. Thanks for everyone's help! Just thought I would report my findings

  • I looked into fastserial and mavlink but I'm having a hard time understanding how they work. There is very little documentation. I understand that fastSerial is a non blocking serial driver for sending but I need a non blocking a serial driver when it comes to receiveing. From what I looked at fastserial doesn't do that and I am pretty sure that is impossible to do.

    So I review my communications functions and it operates at 9 hz per system. So receiving data from 2 sources would slow it down to  5hz. I tried to rewrite the protocol with a call response method, the ArduIMU v3 has some weird serial RX stuff that is mixed in with the GPS that I don't understand so I don't know how to fix. 

    My next plan is to try and receive the data string at any point during the transmission and then reorder it after it is received, but I am still trying to figure out a way to do this. 

    a

  • Developer

    Ardupilot's serial lib is FastSerial. I have used for intercommunication between a pcDuino and APM 2.5 using MAVLink. Very fast and reliable.

  • I'm using serial. What are the library names
  • Developer

    Are you using I2C to chat between devices or Serial? Ardupilot uses some very nice I2C and Serial stream libraries which have been engineered to be interrupt driven and not "block" execution of high level code. 

    I would use these instead of any of the Arduino libraries which are not designed for such demanding environments.

    Jason

This reply was deleted.