This is a project created by QINGHAO LIU. The basic idea is that:
The program of the system has two parts: Hardware(Embedded Board) and Software(PC).
This README Only talks about HARDWARE part.
We use an embedded board to read data from magnetometer and motion-sensor chip by I2C protocol.
If you are not familiar with I2C, we strongly recommend you to learn about it.
Embedded board:TI Cortex-M4 TM4C1294XL LaunchPad
Magnetometer: HMC5983
Motion sensor: MPU9250
10 I2C masters are used to drive 10 magnetometers and load data from magnetometers in sequence.
One of the 10 I2C masters is also used to drive the motion sensor, since the device addresses of motion-sensor and magenetometer are different, so there is no conflict.
Then the data loaded from sensors will be transferred to Serial Port by UART in format.
You can refer to Cortex-M4 TM4C1294XL LaunchPad User Guide
The pins on the front side is enough(Boosterpack 1 and 2 written in white).
xxxx | Debug port | xxxx | xxxx | xxxx |
---|---|---|---|---|
3.3V | 5V | PF1 | GND | |
PE4 | GND | PF2 | PM3 | |
PC4 | PE0 | PF3 | PH2 | |
PC5 | PE1 | PG0(I2C1 SCL) | PH3 | |
PC6 | PE2 | PL4 | ~RST | |
PE5 | PE3 | PL5 | PD1(I2C7' SDA) | |
PD3(I2C8' SDA) | PD7 | PL0(I2C2' SDA) | PD0(I2C7' SCL) | |
PC7 | PA6(I2C6 SCL) | PL1(I2C2' SCL) | PN2 | |
PB2(I2C0 SCL) | PM4 | PL2 | PN3 | |
PB3(I2C0 SDA) | PM5 | PL3 | PP2 | |
~ | ~ | ~ | ~ | ~ |
3.3V | 5V | PG1(I2C1 SDA) | GND | |
PD2(I2C8' SCL) | GND | PK4(I2C3 SCL) | PM7 | |
PP0 | PB4(I2C5 SCL) | PK5(I2C3 SDA) | PP5 | |
PP1 | PB5(I2C5 SDA) | PM0 | PA7(I2C6 SDA) | |
JP4(PD4/PA0(I2C9 SCL)) | PK0 | PM1 | ~RESET | |
JP5(PD5/PA1(I2C9 SDA)) | PK1 | PM2 | PQ2/PA3(I2C8 SCL) | |
PQ0 | PK2 | PH0 | PQ3/PA2(I2C8 SDA) | |
PP4 | PK3 | PH1 | PP3 | |
PN5(I2C2 SCL) | PA4(I2C7 SCL) | PK6(I2C4 SCL) | PQ1 | |
PN4(I2C2 SDA) | PA5(I2C7 SDA) | PK7(I2C4 SDA) | PM6 |
HMC5983 is a 3-Axis magnetometer chip made by Honeywell, which is very cheap and sensitive to magnetic field.
To get started with it. The pin-map and scheme-map below may help you.
For more details, you can refer to the data sheet of HMC5983 here
MPU9250 is a 6-Axis motion sensor chip made by InvenSense, which also include a magentometer.
To get started with it, the Scheme-map below may help you.
For more details, you can refer to the product specification and Register map
Pins of magnetometer from up to down.
- GND
- Sensor-0 SDA
- Sensor-0 SCL
- GND
- Sensor-1 SDA
- Sensor-1 SCL
- GND
- Sensor-2 SDA
- Sensor-2 SCL
- GND
- Sensor-3 SDA
- Sensor-3 SCL
- GND
- Sensor-4 SDA
- Sensor-4 SCL
- GND
- VDDIO of Motion Sensor(Please connect it to 3.3V)
- Motion Sensor SCL
- Motion Sensor SDA
- GND
- Sensor-5 SDA
- Sensor-5 SCL
- GND
- Sensor-6 SDA
- Sensor-6 SCL
- GND
- Sensor-7 SDA
- Sensor-7 SCL
- GND
- Sensor-8 SDA
- Sensor-8 SCL
- GND
- Sensor-9 SDA
- Sensor-9 SCL
- GND
- N/A
- N/A
- N/A
- 5V
- 5V
Connect 10 I2C masters to 10 magnetometers. Connect one of the 10 I2C masters to 1 motion-sensor.
Due to the problem of copyright. Ask your professor for the installation program, which may contains 5 files.
Installation program name | Details |
---|---|
MDK522.EXE | The main setup file of Keil 5.22 |
MDKCM522.EXE | The setup file for Keil legacy devices |
Keil.TM4C_DFP.1.1.0.pack | Tiva C Series device support and examples |
SW-EK-TM4C1294XL-2.1.4.178.exe | Firmware development package setup |
uniflash_sl.4.1.1250.exe | Uniflash setup(Maybe no use) |
- Download this repository to your PC.
- Find the MagWrist_ReadData.uvprojx file and open it with Keil. (picture here about the postion of the src file)
- Double click the MagWrist_ReadData.c file on the left side.
- Configuration.
- (Read Data Rate)
- (Measurement Scale)
- Click on the Rebuild button on the up-left side.
- If 0 Error(s), then Congratulations!(Ignore the warnings)
- If there is any error, try debug it by yourself first.
- Check whether there is any syntax error.(Maybe you tapped your keyboard by mistake)
- Right click Target1 on the left side and choose Options for Target 'Target 1'.
- Click Device and check you have chosen TM4C1294NCPDT.
- Click C/C++ and check Include Paths is
.\inc;.\driverlib_
.
- If you have no idea, ask your professor.
- Connect embedded board by USB and download the program into your embedded board.
- If you have some problem with downloading, please right click on the Target1 on the left side and click Options for Target 'Target 1' .... Choose Debug and follow the pictures below and try again:
8. If you still have some problems, please ask your professor. :)
The data loaded will be translated into ASCII and transferred to Serial Port by UART.
The format is as follows:
/* HMC5983 Part */
X_Axis_Data Y_Axis_Data Z_Axis_Data 0
X_Axis_Data Y_Axis_Data Z_Axis_Data 1
X_Axis_Data Y_Axis_Data Z_Axis_Data 2
X_Axis_Data Y_Axis_Data Z_Axis_Data 3
...
X_Axis_Data Y_Axis_Data Z_Axis_Data 9
/* MPU9250 Part */
Acc_X Acc_Y Acc_Z Gyr_X Gyr_Y Gyr_Z 0
Now you can receive data on your PC if you know how to read data from serial port of your PC.
If you have no idea, please refer to Software part of this project.
You can configure the resolution of the magnetometers(HMC5983). Higher the resolution you set, more sensitive the sensor is, smaller the range is. HMC5983 has 8 levels of resolution, which controlled by three higher bits of Configuration B Register. If you want to change the resolution, follow the steps below:
-
Open MagWrist_ReadData.c in Keil(or other editor).
-
Search for the function HMC5983_Config.
-
You can find this line:
I2C_WriteByte(I2C_Num,HMC5983_ADDRESS,HMC5983_CONFIG_B,0xE0);
- You can replace the hex according to the table below:
Hex | Range | Digtal Resolution(mGauss/LSb) | Output Number Range |
---|---|---|---|
0x00 | -0.88 ~ +0.88 Gauss | 0.73 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0x20 | -1.30 ~ +1.30 Gauss | 0.92 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0x40 | -1.90 ~ +1.90 Gauss | 1.22 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0x60 | -2.50 ~ +2.50 Gauss | 1.52 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0x80 | -4.00 ~ +4.00 Gauss | 2.27 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0xA0 | -4.70 ~ +4.70 Gauss | 2.56 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0xC0 | -5.60 ~ +5.60 Gauss | 3.03 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
0xE0 | -8.10 ~ +8.10 Gauss | 4.35 | 0xF800 ~ 0x07FF(-2048 ~ 2047) |
- Rebuild and download.
The head files and functions defined except MagWrist_ReadData.c are provided by Prof. Wei Liu Shanghai Jiaotong University.
The printed circuit board(Magnetometer Array) is designed and made by Prof. Hao He Shanghai Jiaotong University, supported by Prof. Hongzi Zhu Shanghai Jiaotong University.