Ciao to everybody, just want you to know that today I finally made my EM406, ArduIMU and Ardupilot work together with a simple trick. From http://seniord.ece.iastate.edu/dec0803/manuals/EM-406%20Product_Gui... we see that the output baud rate of the infamous EM406 is 4800 bps. Adjusting the code for arduIMU, ardupilot to work at 4800 everything works very fast, ever without the "first time" GPS locking procedure. All right.
The only problem is that one might desire a higher than 4800 output rate. Argh, I am a very newbie to arduino and I am still searching for the solution.



UPDATE!

So, with the help of Hopslink, I finally got it all working.


This made my arduIMU connect with the so-hatred EM406 module without using the NMEA protocol.


If you make arduPilot communicate with arduIMU @ 38400 bps you're really done. That's it.

Views: 887

Tags: 406, arduimu, ardupilot, code, em, em406, gps, work

Comment by Ben Levitt on June 3, 2010 at 9:27pm
Hi iangl,

In MatrixPilot, we communicate with the EM406 at 4800 baud briefly on startup to tell it to switch to 19200 baud binary mode. Then we switch our serial port to use 19200 baud, and we can then happily continue to talk to the GPS in binary mode at 19200.

This is the message we send out to make the switch:

const char bin_mode[] = "$PSRF100,0,19200,8,1,0*39\r\n" ;

Ben
Comment by Tim - Arduino for Visual Studio on June 5, 2010 at 6:00pm
yes that's right the baud is set automatically so should not be a problem. i think the default for the 406 on the ardupilot is 57600 and on the imu it is 38400

you have to keep in mind that the two boards have only 1 serial port each so the ArduPilot designers have used them cleverly. the imu reads data from the gps and writes data to the ardupilot. the ardupilot reads data from the imu and writes to the xbee (or serial port tx)

this means that all 4 operations need to work at the same speed. using the 406 i have altered my ardupilot code, imu code and xbee to 57600. This simply means that I can use the ardupilot with or without imu.

it works, i can see the gps and telemtry info from the imu via the xbee however an IMPORTANT note

I think Chris is aware of a bug that prevents the 406/imu data from being used by the ArduPilot when the shield is connected. I believe you can switch the shield off in the code to prove this. I am about to investigate and think there is an article somewhere about this

So to prove the imu is working take off the shield from the ardupilot
Comment by Tim - Arduino for Visual Studio on June 5, 2010 at 8:22pm
I was wrong about the ardupilot setting the baud rate of the 406. you have to do it yourself. I bought my 406 from diy drones and I think it came preset to 57600

The problem of the imu/406 not working with the shield was fixed by Chris and is contained in the laest ArduPilot 26 download

So the imu/406 and ardupilot combination is finally working as of a few days ago. You just need to alter your baud rate to 38400
Comment by Ken on June 6, 2010 at 3:17pm
iangle,

Sorry to burst your bubble, but Ben is right.
There was never any question that the default for the EM-406 is NMEA text mode @ 4800. But that is too slow and is more difficult to parse than the binary protocol. So the first communication the Ardupilot/ArduIMU do with the GPS is to tell it to go to a higher data rate and change in to binary mode. The GPS will remember this setting for 3-5 days after power is removed.
Comment by Tim - Arduino for Visual Studio on June 6, 2010 at 3:22pm
Oh that's interesting thanks.

Then is the confusion that the 406 code in the IMU sets the baud rate to Serial.begin(57600) but the IMU in binary mode connected to the ardupilot connects at 38400?
Comment by iangl on June 6, 2010 at 6:58pm
I admit I am a totally new newbie to physical computing, i received my first arduino and arduimu just last week. I wasn't able to make the gps work even after searching over and over the Net, and tuning and re-tuning the baud rates. Today I discovered that the IDE running on my computer sometimes glitches abundantly. So now I'll try again with 38400, even if it works just fine with 4800. Thank you people for the support! I'll make you know for further news about my helicopter drone project.

AND, does anyone have tried to implement a BEAM based brain in a flying drone? This will be the finalest of the final improvements in the project
Comment by hopslink on June 7, 2010 at 2:10am
Iangl, I think you have found a bug.

The problem seems to be that the current IMU code never initialises the EM406 to the correct serial rate/protocol. The init_gps() function doesn't seem to get called as part of the setup routine. If called it sets EM406 to 57kbit/s (as TimL suspected). The Ublox init code seems to be inlined.

Attached are arduimu.pde and GPS_EM406.pde files which should fix the issues mentioned above with the latest arduimu code (unfortunately I can't test them, other than that they compile ok).

arduimu.pde
GPS_EM406.pde

Can you test these with the latest AP and IMU code at 38400? If they work for you give a shout so they can be considered for integration to the IMU codebase.
Comment by Ken on June 7, 2010 at 2:41pm
hopslink,

Which version do you think has the bug?

It is a bit of a jump around, but init_gps is called. Which init_gps depends on your GPS_PROTOCOL define.

I use ArduPilot/ArduIMU a whole different way than (I think) anyone around here. My last download of the software was in February and has gone its merry way since. But I went to look at the 2.5.04 software online and found that:

1. the serial port baud rate is set in the setup section (in "Ardu_pilot_25_04"). A message is printed. Then init_ardupilot is called.
2. init_ardupilot (in "system") calls init_gps.
3. In "GPS_EM406", init_gps looks like this:

void init_gps(void)
{
Serial.println("init_gps");
change_to_sirf_protocol();
delay(100);//Waits fot the GPS to start_UP
configure_gps();//Function to configure GPS, to output only the desired msg's
}

First line of change_to_sirf_protocol is

Serial.begin(4800); //First try in 4800

So we should be talking at the right rate.

Then the data rate is restored.
Comment by hopslink on June 7, 2010 at 3:16pm
Ken,

The latest ArduIMU 1.7 version in the repository at my time of posting. LINK

It is possible the call is made, however I could not see where... (your explanation points to ArduPilot init, not ArduIMU?) plus this would be a logical reason for iangl's success setting baud rate to 4800, the default for the EM406.

I am also pretty sure that the setup code initialises the GPS to 57600bit/s where the ArduIMU and ArduPilot 2.6 (with GPS_PROTOCOL set for IMU) operate at 38400bit/s.

It would be great if you could take a peek through the arduimu.pde and GPS_EM406.pde code at the link above and see what you think.
Comment by iangl on June 7, 2010 at 3:37pm
Dear HOPSLINK, you DID it! everything works ok now, the blue leds are solid blue forever. The GPS is in binary mode; its led is turned off.

With the previous code (the one at 4800) thie gps light was blinking red, meaning lock.

Arduimu locks independently and ardupilot locks fine too. Great job.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service