Elisa3
|
Accelerometer module. More...
Go to the source code of this file.
Functions | |
void | initAccelerometer () |
Test which device is mounted on the robot and configure it. | |
unsigned char | initADXL345 () |
Configure the ADXL345 accelerometer (2g sensitivity, 10 bits resolution). | |
unsigned char | initMMA7455L () |
Configure the MMA74565L accelerometer (2g sensitivity, 10 bits resolution). | |
void | readAccelXY () |
Request the X and Y values (10 bit data, 2's complement) and save them in their respective global variables accX and accY. | |
void | readAccelXYZ () |
Request the X, Y and Z values (10 bit data, 2's complement) and save them in their respective global variables accX, accY and accZ. | |
void | computeAngle () |
Compute the angle of the robot using the X and Y axes; the resulting angle is saved in the global variable "currentAngle". The angle refers to a classical reference system where the 0 points to the right, 90 to the top, 180 to the left and 270 to the bottom in a vertical wall. In order for the angle to be computed correctly, the robot has to be calibrated leaving it flat on the ground. Moreover this function update the robot motion plane (horizontal or vertical) based on the Z axis; this information is then used to switch between horizontal and vertical speed controller. |
Accelerometer module.
The I2C communication is initialized to work with the accelerometer. There are functions to work with both the Freescale MMA7455 and the Analog Device ADXL345 accelerometers.
void computeAngle | ( | ) |
Compute the angle of the robot using the X and Y axes; the resulting angle is saved in the global variable "currentAngle". The angle refers to a classical reference system where the 0 points to the right, 90 to the top, 180 to the left and 270 to the bottom in a vertical wall. In order for the angle to be computed correctly, the robot has to be calibrated leaving it flat on the ground. Moreover this function update the robot motion plane (horizontal or vertical) based on the Z axis; this information is then used to switch between horizontal and vertical speed controller.
void initAccelerometer | ( | ) |
Test which device is mounted on the robot and configure it.
unsigned char initADXL345 | ( | ) |
Configure the ADXL345 accelerometer (2g sensitivity, 10 bits resolution).
0 | configuration ok |
1 | communication error |
unsigned char initMMA7455L | ( | ) |
Configure the MMA74565L accelerometer (2g sensitivity, 10 bits resolution).
0 | configuration ok |
1 | communication error |
void readAccelXY | ( | ) |
Request the X and Y values (10 bit data, 2's complement) and save them in their respective global variables accX and accY.
void readAccelXYZ | ( | ) |
Request the X, Y and Z values (10 bit data, 2's complement) and save them in their respective global variables accX, accY and accZ.