sparkfun 9 degree of freedom comms problem

Hi All, please see second post (url restrictions) :slight_smile:

Hi All,

I'm working on a simple quadcopter, using one of these http://www.sparkfun.com/commerce/product_info.php?products_id=9623 as the main sensor board (gps coming later).

It communicates via serial, at 56k. I'ev tweaked it's code so that it outputs the following:

!!336.04:359.25:257.34!!336.05:359.23:257.33!!

!!roll:pitch:yaw!! etc

So I have a mega which connects to this device and reads the input stream and continuously parses the data from the ASCII string to a triple of doubles representing the angles.

So onto the problem.

I have the mega producing lots of debug output over one of it's other serial ports at 115k which I watch on my PC. The data coming in from the 9dof board gets heavily corrupted somewhere in the chain, leaving only perhaps half of the readings uncorrupted and usable. This means I lose data and have potentially very long gaps between sensor readings: not cool.

Here is an example of some corrupt input from the 9dof board. I trace every write from the serial input buffer to my temporary parse buffer below. I overwrite index 14 with a : on purpose.

Writing 3 at 0
Writing 4 at 1
Writing 2 at 2
Writing . at 3
Writing 7 at 4
Writing 7 at 5
Writing : at 6
Writing 3 at 7
Writing 5 at 8
Writing N at 9
Writing ? at 10
Writing V at 11
Writing รพ at 12
Writing 8 at 13
Writing ! at 14
Writing : at 14

You can see the apparently random corruption. It also happens frequently that I only get half a message parsed.

Where is the garbage coming from? Between every read & parse cycle I clean the temp buffer by writing 0x00 to every address. The only data coming in over the serial line from the 9dof board are the following ASCII characters:
1234567890!:. so the random garbage is very very strange.

My code is linked below if anyone would care to look and have any ideas.

When I plug the 9dof into my PC the data comes over perfectly. When I parse it with my code, it gets heavily corrupted :frowning:

Code: http://pastebin.com/RCTYS9LX

Please help, I'm going mad!

Cheers,
Chilly

So I tried a simple passthru program (which used to work just fine) and Simply looping on

Serial1.print(Serial3.read()) produces garbage output. I'm starting to think my board is faulty :frowning:

I'll try some other ports.

Just tried a combination of in/out ports and they all result in garbage data. Perhaps I'm using the serial interfaces wrong? I'm not using the CTS/RTS at all as there are no ports for it - should I be?

Serial1.print(Serial3.read()) produces garbage output. I'm starting to think my board is faulty

That statement will never work correctly. Study the Serial library function better ( Serial - Arduino Reference ). You must first test is there is a valid avalible character ready to be read before you do a serialx.read function.

Lefty

Hi Lefty - yes I use a check call first, apologies for not including it in the example - I was trying to be concise.

I've studied the serial libraries in detail and can assure you I am using them as the examples show.