#include <std.h>Go to the source code of this file.
Enumerations | |
| enum | AXDL_PINS { AXDL_311_X_OUT = ADC_CHANNEL_0, ADXL_311_Y_OUT = ADC_CHANNEL_1 } |
| The analog input pins on which the accelerometer is normally connected - may have to be changed accoring to current layout. More... | |
Functions | |
| long * | read_adxl311 () |
| long * | read_adxl311_meanof (int number) |
|
|
The analog input pins on which the accelerometer is normally connected - may have to be changed accoring to current layout.
Definition at line 43 of file adxl311je.h. 00044 {
00045 AXDL_311_X_OUT = ADC_CHANNEL_0,
00046 ADXL_311_Y_OUT = ADC_CHANNEL_1
00047 };
|
|
|
This function returns both adxl values at once. The duplicate analog reads result from a small problem with the Smart-Its board and because of this problem, a0 is hardwired to a2 and a1 is hardwired to a3. (analog inputs a0 to a8 are on the Smart-Its.) Call to this function: long * array_calling_read_adxl311 = read_adxl311(); access to variables with: array_calling_read_adxl311[0] and array_calling_read_adxl311[1]
comment out the Y_OUT+3 line if you are using a "normal" smart its board and comment in the next line. Definition at line 72 of file adxl311je.h. References ADXL_311_Y_OUT, and AXDL_311_X_OUT. Referenced by read_adxl311_meanof(). 00073 {
00074 long xaxis,yaxis,xaxis2,yaxis2;
00075 long retval[2];
00076 set_adc_channel(AXDL_311_X_OUT);//a0
00077 delay_us(50);
00078 xaxis = read_adc(ADC_START_AND_READ);
00079 delay_us(50);
00082 set_adc_channel(ADXL_311_Y_OUT+3);//a4 HIER
00083 //set_adc_channel(ADXL_311_Y_OUT);//a4 HIER
00084 delay_us(50);
00085 yaxis2 = read_adc(ADC_START_AND_READ);
00086 set_adc_channel(ADXL_311_Y_OUT);//a1
00087 delay_us(50);
00088 yaxis = read_adc(ADC_START_AND_READ);
00089 delay_us(50);
00090 set_adc_channel(AXDL_311_X_OUT);//a3
00091 delay_us(50);
00092 xaxis2 = read_adc(ADC_START_AND_READ);
00093 retval[0] = xaxis;
00094 retval[1] = yaxis;
00095 // xaxis2 and yaxis2 are not needed
00096 return (retval);
00097 }
|
|
|
Calculates the mean value during number of calls.
Definition at line 107 of file adxl311je.h. References read_adxl311(). 00108 {
00109 long xtemp, ytemp;
00110 long retval[2];
00111 int i=0;
00112
00113 retval[0] = retval[1] = 0;
00114 ytemp = xtemp = 0;
00115
00116 for (i=0;i < number;i++)
00117 {
00118 long * bla;
00119 bla = read_adxl311();
00120 xtemp = xtemp + bla[0];
00121 ytemp = ytemp + bla[1];
00122 }
00123 xtemp= xtemp / number;
00124 ytemp= ytemp / number;
00125
00126 retval[0] = (xtemp);
00127 retval[1] = (ytemp);
00128 return(retval);
00129 }
|
1.3.9.1