You are on page 1of 9

Loading the code

ArduIMU+ comes with some basic test firmware loaded at the factory, but to get full functionality you should load the latest AHRS firmware. Here's how: 1) First, download the latest code from the repository. 2) Then you need to download Arduino if you don't already have it and install it. ArduIMU only supports Arduino 023 or below. You can download it here: (Windows, Mac, Linux). The instructions for loading ArduIMU code are essentially the same as for ArduPilot, so follow them here(especially the part about setting the "Set RTS on close" box and choosing the right board in the Arduino IDE) and then come back to this page. 3) You must also define the folder Arduino will use for its "sketches" (Arduino-talk for the set of files that compose a program) and libraries Create a folder someplace where you can find it, perhaps in your Documents folder or even on your desktop. (If you've been using Arduino, you probably have this set up somewhere already). Launch the Arduino IDE and open the Preferences dialog. Set the sketchbook location to the folder you created or are using. Here's where I have mine:

Once you've changed that directory, you must close Arduino and restart it for it to be recognized. 4) Now download the latest ArduIMU software. It will be named ArduIMU(version number).zip. Unzip this main folder to your desktop. Inside the main folder there should be two folders: "arduimu" and "libraries". Drag them to the Arduino Sketchbook folder you defined in the previous step. Note: these are the same libraries as used in ArduPilotMega and ArduCopter. So if you've already loaded them, you don't have to copy the libraries folder again for ArduIMU. Here's where I put the libraries and APM code folder (highlighted). Note that it is exactly the same folder as I defined in the Arduino configuration menu in the step above.

We recommend you use this same file configuration. If you modify it, Arduino may not be able to find the libraries and you'll get compile errors. Important note: DO NOT drag the whole ArduIMU(version number) folder into your sketchfile directory. If you do, the code will not compile. Instead, just drag the two individual folders within it--"arduimu" and "libraries"--into the sketchfile folder as shown above. Once you've placed them in the sketchfile folder, you can delete the ArduIMU(version) folder on your desktop. 4) Open Arduino and load the ArduIMU code from your "arduimu" folder by open the "arduimu.pde" file, which will open all the tabs. Make any configuration changes needed in the first tab of the code. If you just want to try out the IMU with the desktop demo programs, make sure the following configuration options are set as shown:
#define PRINT_ANALOGS 1 //Will print the analog raw data #define PRINT_EULER 1 //Will print the Euler angles Roll, Pitch and Yaw #define PRINT_GPS 1 //Will print GPS data #define PRINT_BINARY 0 //Will print binary message and suppress ASCII messages (above)

You should also select a GPS module. The uBlox is the default and is recommended, but if you want to use the MediaTek module sold by the DIY Drones store, please note that it comes with a later firmware than is supported by ArduIMU and you must downgrade the firmware to 1.4 as explained in this tutorial.
#define GPS_PROTOCOL 3 // 1 - NMEA, 2 - EM406, 3 - Ublox, 4 -- MediaTek

If you want to use ArduIMU with ArduPilot, set the following configuration option as shown:
#define PRINT_BINARY 1 //Will print binary message and suppress ASCII messages (above)

Remember to adjust your magnetic declination setting for your local environment. 4) Then connect the FTDI cable to connector pins you soldered on the ArduIMU (check on the bottom of the board where it shows which orientation to plug the FTDI cable in--black is on one side) and use it to load the code on to the board. Again, the instructions for ArduPilot are essentially the same, so refer to them if you're having trouble. If you are having problems uploading the code (you get a bunch of error messages in red) follow ALL of the debugging tips here.

Running the Demo Program


We've provided two different demo programs so you can see how ArduIMU+ works. Note that you'll need GPS lock to give the most accurate results. Also note that they require Windows be set in standard English numbering, with periods (.) as decimal marks in numbers.

The easiest to use is the Windows test utility, developed by HappyKillmore

Download it from here and install it. Additional instructions are here. To use it, first, connect a GPS to the ArduIMU; currently only the uBlox 5 (with the DIY Drones adapter) is supported. If you don't connect a GPS module, the IMU will still work but Yaw data will be unreliable since there is no way to correct for drift in the Yaw gyro. Also, please note that the GPS will probably only get lock when you're outside with a clear view of the sky. If you don't have lock (blue LED on the ArduIMU+ board lights up), it will still work but the yaw data will be wrong. Note: When you're starting the IMU with AIRSTART = 0, the board will flash its LEDs for about a half-minute while it's calibrating. Once that is done, it should start sending data that you can read with the desktop utility. With AIRSTART = 1, it will boot faster, but be less accurate.

LabVIEW demo program


If you prefer the earlier LabVIEW demo software (shown below) you can find it here.If you don't already have them, you'll also need the LabView runtime engine and serial drivers. Download the runtime engine here and the drivers here. Run ArduIMU.exe in the ArduIMU Demo folder. Follow the directions below.

When you run the Desktop Utility you need to tell it to find the right serial port and connect to the IMU.

Select the port in the window shown above. If you're not sure what serial port your FTDI is connected on, you can find out in your Windows Device Manager, as shown below:

It may take a few seconds for the software to recognize the serial port and for the data to start flowing. But once it does, your main window and graphic display of the rotating box should be working. When you're done, press the little stop icon on the serial window to stop reading data, so you can close the window.

Output Overview
Please be aware that this page is extremely new, and its accuracy is still being verified. The ArduIMU outputs serial data in different formats depending on its configuration. The two main options are either binary or Ascii. You can pick between these formats and a variety of other options in the user configuration settings (see here).

Ascii Output
Typical Ascii output with a GPS unit looks like this:
!!!VER:1.8.1,RLL:1.12,PCH:-0.07,YAW:34.03,IMUH:253,LAT:499247361,LON:-1193955623, ALT:3525,COG:0,SOG:0,FIX:1,SAT:9,TOW:21230400***

The variables in the output are determined by configuration settings. Depending on what flags are set some of these fields may not appear or there will be more fields. The variables in this example are : 1. Roll: Measured in degrees with positive and increasing as the right wing drops 2. Pitch: Measured in degrees with positive and increasing as the nose rises 3. Yaw: Measured in degrees with positive and increasing as the nose goes right 4. IMUH: 5. Latitude: Measured in decimal degrees times 10^7 6. Longitude: Measured in decimal degrees times 10^7 7. Altitude: Measured in meters above sea level times 10^1 8. Course over ground: 9. Speed over ground: 10. GPS Fix: A binary indicator of a valid gps fix 11. Satellite Count: The number of GPS satellites used to calculate this position 12. Time of week: Time of week is related to GPS time formats. If this is important to your system, I suggest you read external resources on this confusing topic.

Binary Output
There are partial examples of parsing binary data on forum posts, but no official documentation.

Output Rate
Experimentation has shown that ascii serial data is pushed at about 8 Hz, though some fields (such as gps) are updated at a different rate (4 Hz) based on the availability of new data.

Thanks
Examples of output taken from a post by Scotty of DIYDrones.

Configuration
Updated Sep 5, 2010 by analogue...@gmail.com

User-modifiable options

There is no configuration file for the firmware. Use modifiable options are set with several #define statements in the main file (ArduIMU.pde). There are also #define statements which are not intended to be user modifiable options, so only change the parameters shown below.
// *** NOTE! Hardware version - Can be used for v1 (daughterboards) or v2 (flat) #define BOARD_VERSION 2 // 1 For V1 and 2 for V2 // Ublox gps is recommended! #define GPS_PROTOCOL 4 // 1 - NMEA, 2 - EM406, 3 - Ublox, 4 -- MediaTek

// Enable Air Start uses Remove Before Fly flag - connection to pin 6 on ArduPilot #define ENABLE_AIR_START 0 // 1 if using airstart/groundstart signaling, 0 if not #define GROUNDSTART_PIN 8 // Pin number used for ground start signal (recommend 10 on v1 and 8 on v2 hardware) /*Min Speed Filter for Yaw drift Correction*/ #define SPEEDFILT 2 // >1 use min speed filter for yaw drift cancellation, 0=do not use speed filter /*For debugging propurses*/ #define PRINT_DEBUG 0 //Will print Debug messages //OUTPUTMODE=1 will print the corrected data, 0 will print uncorrected data of the gyros (with drift), 2 will print accelerometer only data #define OUTPUTMODE 1 #define #define #define #define PRINT_DCM 0 //Will print PRINT_ANALOGS 0 //Will print PRINT_EULER 0 //Will print PRINT_GPS 1 //Will print the the the GPS whole direction cosine matrix analog raw data Euler angles Roll, Pitch and Yaw data

// *** NOTE! To use ArduIMU with ArduPilot you must select binary output messages (change to 1 here) #define PRINT_BINARY 0 //Will print binary message and suppress ASCII messages (above) // *** NOTE! Performance reporting is only supported for Ublox. Set to 0 for others #define PERFORMANCE_REPORTING 1 //Will include performance reports in the binary output ~ 1/2 min /* Support for optional magnetometer (1 enabled, 0 disabled) */ #define USE_MAGNETOMETER 0 // use 1 if you want to make yaw gyro drift corrections using the optional magnetometer /* Support for optional barometer (1 enabled, 0 disabled) */ #define USE_BAROMETER 0 // use 1 if you want to get altitude using the optional absolute pressure sensor #define ALT_MIX 50 // For binary messages: GPS or barometric altitude. 0 to 100 = % of barometric. For example 75 gives 25% GPS alt and 75% baro

These are all pretty self-explanatory, except for AIR_START. Here is the explanation of the author, Doug Weibel: "Airstart is only there to save you if for some reason the AP restarts in the air. This could happen due to a power glitch or due to toggling the mode quickly. If the AP restarts in the air it is important that it not take a lot of time doing the things it normally does when starting on the ground - i.e. calibrating everything. When we do a ground start we get the offsets for all the analog sensors, set the home location, etc. We then store this stuff in EEPROM. When an airstart occurs we just grab this stuff back from EEPROM and start operating immediately. There is no real reason a user would want to intentionally perform an airstart on the ground other than debugging. The biggest source of confusion I have seen is with the IMU. If users set ENABLE_AIRSTART then the IMU will ALWAYS air start unless it gets a signal from the AP to ground start. This will often result in the IMU doing funky stuff, because it will be using calibration data from EEPROM that may not be appropriate. So if a user is just looking at the IMU on the bench and they have it doing air start instead of ground start then they will often think there is a problem." In short, leave it at 0 when you're bench testing or unless you've got it attached to ArduPilot via the D6/D8 pin.

Other settings

There are also adjustable gains for the XY and Z directions, but you probably will not want to change them unless you understand what effect the change will cause. The values shown below have been shown to work reasonably well.
// LPR530 & LY530 Sensitivity (from datasheet) => 3.33mV//s, 3.22mV/ADC step => 1.03 // Tested values : 0.96,0.96,0.94 #define Gyro_Gain_X 0.92 //X axis Gyro gain #define Gyro_Gain_Y 0.92 //Y axis Gyro gain #define Gyro_Gain_Z 0.94 //Z axis Gyro gain

Theory of Operation (Simplified)


ArduIMU uses gyros, accelerometers, and GPS to maintain a model of the the board's orientation in space. This is not as simple a problem as integrating the roll rates from the gyros. As a simple illustrative example, consider an airplane flying level to the north that first banks (rolls) 90 degrees to the right and then pitches 90 degrees. mathematical algorithm called the Direction Cosine Matrix (DCM) to take sensor data from the gyros, accelerometersThe airplane would be flying horizontally to the east in a 90 degree bank orientation. If instead the airplane pitched up 90 degrees first, then banked 90 degrees the airplane would be flying straight up. We cannot just keep track of how much roll and pitch have occurred and know the orientation of the aircraft. For a detailed description of how the DCM algorithm works see Bill Premmerlanis tutorial here. You can also read a detailed description in Mahoney's original papers here. For this simplified explanation here are the essential components of the algorithm. The Direction Cosine Matrix is a 3 by 3 numerical matrix (array) The gyro data is used in a time step integration to update the DCM matrix Data from the accelerometers and gps is used to correct for errors that creep in to the DCM matrix. These errors arise from drift in the gyros as well as numerical errors due to quantization of the gyro signals and rounding errors in the computations. Pitch, roll and yaw can be computed from the elements of the direction cosine matrix. ArduIMU outputs a serial data stream. The firmware can be configured so that this data stream includes a variety of data including the DCM matrix itself, the pitch, roll and yaw of the unit, raw sensor and gps data, and other computed data. (DW)

For more information on this application of the DCM, please see the UAVDevBoard section on DIY Drones.

LED displays
When AIRSTART = 0, the red, blue and yellow LEDs will flash while the IMU is calibrating at startup. ArduIMU Indicator LEDs (after startup): Green LED = Power On Yellow LED = Indicates that the speed filter is supressing yaw drift correction. You should see it on if you are not in motion above the set threshold speed. Red LED = On after calibration

Troubleshooting Guide
No lights come on when programming Are you using an appropriate FTDI cable that supplies power? The blue GPS light does not come on Is the adapter board properly seated on the Ublox module? Are you indoors where satellite signals may be too weak? Are you using the uBlox GPS module, or if not have you changed the configuration for the one you are using?

You're using ArduIMU with ArduPilot, but it's not working and when you get GPS lock on ArduIMU it doesn't show as locked on ArduPilot. -- Have you changed #define PRINT_BINARY to 1? (see this for more)

You might also like