Data Structures | |
| struct | TypeAccSpheric |
| struct to store the acceleration vector in spherical coord More... | |
| struct | TypeAccRaw |
| struct to store the acceleration raw data in carthesian coord More... | |
Defines | |
| #define | CST_RADIAN (180.0/3.1415) |
| #define | ANGLE_ERROR 666.0 |
| #define | FILTER_SIZE 5 |
| #define | ACCX_BUFFER 0 |
| #define | ACCY_BUFFER 1 |
| #define | ACCZ_BUFFER 2 |
Functions | |
| int | e_get_acc (unsigned int captor) |
| Read the last value of a given accelerator axes. | |
| int | e_get_acc_filtered (unsigned int captor, unsigned int filter_size) |
| Read the value of a channel, filtered by an averaging filter. | |
| TypeAccSpheric | e_read_acc_spheric (void) |
| calculate and return the accel. in spherical coord | |
| float | e_read_orientation (void) |
| calculate and return the orientation angle | |
| float | e_read_inclination (void) |
| calculate and return the inclination angle | |
| float | e_read_acc (void) |
| calculate and return the intensity of the acceleration | |
| TypeAccRaw | e_read_acc_xyz (void) |
| calculate and return acceleration on the x,y,z axis | |
| int | e_read_acc_x (void) |
| calculate and return acceleration on the x axis | |
| int | e_read_acc_y (void) |
| calculate and return acceleration on the y axis | |
| int | e_read_acc_z (void) |
| calculate and return acceleration on the z axis | |
| void | e_acc_calibr (void) |
| initialize de ad converter and calculate the zero values | |
| void | e_display_angle (void) |
| light the led according to the orientation angle | |
The functions of this file are made to deal with the accelerometer data. You can know the magnitude, the orientation, the inclination, ... of the acceleration that the e-puck is enduring.
Two structures are used:
A little exemple to read the accelerator.
#include <p30f6014A.h> #include <motor_led/e_epuck_ports.h> #include <motor_led/e_init_port.h> #include <a_d/advance_ad_scan/e_ad_conv.h> #include <a_d/advance_ad_scan/e_acc.h> int main(void) { int z; e_init_port(); e_init_ad_scan(); while(1) { long i; z = e_get_acc(2); if(z < 2100) //LED4 on if e-puck is on the back { LED0 = 0; LED4 = 1; } else //LED0 on if e-puck is on his wells { LED0 = 1; LED4 = 0; } for(i=0; i<100000; i++) { asm("nop"); } } }
| #define ACCX_BUFFER 0 |
| #define ACCY_BUFFER 1 |
| #define ACCZ_BUFFER 2 |
| #define ANGLE_ERROR 666.0 |
| #define CST_RADIAN (180.0/3.1415) |
| #define FILTER_SIZE 5 |
| void e_acc_calibr | ( | void | ) |
initialize de ad converter and calculate the zero values
It reads two times the average_size to avoid edge effects then it reads 100 values and average them to initiate the "zero" value of the accelerometer
| void e_display_angle | ( | void | ) |
light the led according to the orientation angle
| int e_get_acc | ( | unsigned int | captor | ) |
Read the last value of a given accelerator axes.
| captor | ID of the AD channel to read (must be 0 = x, 1 = y or 2 = z) |
| int e_get_acc_filtered | ( | unsigned int | captor, | |
| unsigned int | filter_size | |||
| ) |
Read the value of a channel, filtered by an averaging filter.
| captor | ID of the AD channel to read (must be 0 to 2) | |
| filter_size | size of the filter (must be between 1 and SAMPLE_NUMBER) |
| float e_read_acc | ( | void | ) |
calculate and return the intensity of the acceleration
| TypeAccSpheric e_read_acc_spheric | ( | void | ) |
calculate and return the accel. in spherical coord
| int e_read_acc_x | ( | void | ) |
calculate and return acceleration on the x axis
| TypeAccRaw e_read_acc_xyz | ( | void | ) |
calculate and return acceleration on the x,y,z axis
| int e_read_acc_y | ( | void | ) |
calculate and return acceleration on the y axis
| int e_read_acc_z | ( | void | ) |
calculate and return acceleration on the z axis
| float e_read_inclination | ( | void | ) |
calculate and return the inclination angle
| float e_read_orientation | ( | void | ) |
calculate and return the orientation angle
1.5.4