Functions |
void | calibrateSensors () |
| Calibrate all the sensors (proximity, ground and accelerometer). Pay attention for the robot to be positionated in a flat surface and that no objects obstruct the sensors. Peripherals need to be already initialized before calling this function.
|
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 | readAccelXYZ_1 () |
void | readAccelXYZ_2 () |
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.
|
Sensors module.
- Author:
- Stefano Morgani <stefano@gctronic.com>
- Version:
- 1.0
- Date:
- 01.02.12
- Copyright:
- GNU GPL v3
General module that contains functions to interact with the sensors mounted on the robot (proximity, ground, accelerometer). 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.