This repository contains code projects with the Max32 microcontroller. The code projects are presented below.
This code project is about making the Max32 communicate via an SPI channel with a 12 bits ADC.
This code project is about making the Max32 communicate via an SPI channel with the L3G4200D gyroscope.
This code project is about making the Max32 communicate in I2C with the HMC5883L magnetometer and communicate in SPI with the LSM330 accelerometer and gyroscope.
The accelerometer is used to compensate the tilting of the compass. The accelerometer can compensate up to 44 degrees of compass tilting. Also, there must be no other acceleration than earth's gravitational acceleration.
The gyroscope is used to calculate the attitude of the device.
It would be possible to use the device attitude to better calculate the compass heading. However, I haven't implemented it yet because the attitude value isn't very accurate. The gyro values might be a off. I might get a spinning table to calibrate the gyro properly.
- Download and install MPIDE
- Buy a Max32
- Buy a 12 bits ADC
- Buy an LSM330
- Buy a L3G4200D
- Buy an HMC5883L
- Execute MPIDE on your pc
- Open a code project on your MPIDE (/File/Open.../)
- Choose the right board for the program execution (/Tools/Board/chipKIT MAX32)
- Choose the right port for the program execution on the board (/Tools/Serial Port/)
- Upload the code on your board
- Open the serial monitor and make sure you are listening on the right port at the right baud rate
- You should read the output values on the monitor
The ADC input value is calculated : AdcOutputValue/4096*5 = AdcInputValueInVolts
- For a 5V ADC input value, you should read 4096 on the monitor.
- For a 3.3V ADC input value, you should read a value around 2700 on the monitor.
- For a 0V ADC input value, you should read 0 on the monitor.
The L3G4200D output value is an angular rate measured in degrees per second (dps).
The HMC5883L output value is scaled in degrees. From 0 to 359.9 degrees.
- If it points to the North, the heading value should be 0.
- If it points to the East, the heading value should be 90.
- If it points to the South, the heading value should be 180.
- If it points to the West, the heading value should be 270.
The LSM330 accelerometer output value is a linear acceleration measured in g.
The LSM330 gyro output value is an angular rate measured in degrees per second (dps).
The attitude value is in degrees. The attitude is calculated with quaternions but displayed as Euler angles for better understanding.
- Michaël Fayad
- Raphaël Guimond
- Guillaume Carrier