Elisa3
accelerometer.c File Reference
#include "accelerometer.h"

Functions

void initAccelerometer ()
 Test which device is mounted on the robot and configure it.
unsigned char initMMA7455L ()
 Configure the MMA74565L accelerometer (2g sensitivity, 10 bits resolution).
unsigned char initADXL345 ()
 Configure the ADXL345 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.

Function Documentation

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.

Returns:
none

Test which device is mounted on the robot and configure it.

Returns:
none
unsigned char initADXL345 ( )

Configure the ADXL345 accelerometer (2g sensitivity, 10 bits resolution).

Return values:
0configuration ok
1communication error
unsigned char initMMA7455L ( )

Configure the MMA74565L accelerometer (2g sensitivity, 10 bits resolution).

Return values:
0configuration ok
1communication 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.

Returns:
none
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.

Returns:
none
 All Data Structures Files Functions Variables Typedefs Defines