
LCD Accelerometer with interrupt fault
Revision 0:298e8a54dc2d, committed 2010-05-12
- Comitter:
- Aubs
- Date:
- Wed May 12 20:40:52 2010 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r 298e8a54dc2d Graphical.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Graphical.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,55 @@ +#include "header.h" +#include "MobileLCD.h" +// Graphical Mode + +extern float xout; +extern float yout; +extern float zout; +extern float xball; +extern float yball; +extern long ball; +extern long a; +extern long b; +extern long a2; +extern long b2; +extern long k; +extern long red; +extern long blue; +extern long green; +extern long col; + +void Graphic(void){ +lcd.cls(); +while(1){ + +SigCon(); + xball=((xout*64)+64); + yball=((yout*64)+64); + b2 = (xball-20); + a2 = (yball-20); + + for (a = a2; a < a2+39; a++) { // this loop draws rows + + for (b = b2; b < b2+39; b++) {// this loop draws columns + + ball = bmp[k]; + + if (ball !=0x00FF00) { + red = ball << 16; + red = red & 0xE00000; + green = ball << 11; + green = green & 0xE000; + blue = ball << 6; + blue = blue & 0xC0; + + col = blue | green | red; + } + k++; + lcd.pixel(a,b,col); + } + } + k=0; + but2.fall (&menuscreen); + } + + } \ No newline at end of file
diff -r 000000000000 -r 298e8a54dc2d Menu.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Menu.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,51 @@ +#include "header.h" + +extern int menu; + +// Menu Counter +void menuscroll(void){ + if (menu<4){ + menu++;} + if (menu==3){ + menu=0;} + } + +// Select + void Select(void){ + if (menu==0){ + lcd.background(0xFFFFFF); + Graphic(); + } + if (menu==1){ + lcd.background(0x000000); + Precise(); + } + if (menu==2){ + lcd.background(0x800080); + calibrate(); + + } + } + +//Menu +void menuscreen(void){ +while(1){ +lcd.cls(); +but1.fall(&menuscroll); +if(menu==0){ + lcd.locate(0,14); + lcd.printf("Graphical Mode"); + } +if(menu==1){ + lcd.locate(0,14); + lcd.printf("Precision Mode"); + } +if(menu==2){ + lcd.locate(0,14); + lcd.printf("Calibration Mode",0xE00000); + } + +// Select Button +but2.fall(&Select); + } + } \ No newline at end of file
diff -r 000000000000 -r 298e8a54dc2d Precision.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Precision.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,25 @@ +#include "header.h" + + +extern float X; +extern float Y; +extern float Z; +extern float xout; +extern float yout; +extern float zout; + +// Precision Mode +void Precise(void){ + lcd.cls(); + while(1){ + SigCon(); + lcd.locate(1,1); lcd.printf("X="); lcd.printf("%.2f",X); //print to screen + lcd.locate(1,3); lcd.printf("Y="); lcd.printf("%.2f",Y); + lcd.locate(1,5); lcd.printf("Z="); lcd.printf("%.2f",Z); //only for testing + lcd.locate(1,7); lcd.printf("%.2f" ,xout); // help with fine tuning by showing accelerations + lcd.locate(1,9); lcd.printf("%.2f" ,yout); + lcd.locate(1,11); lcd.printf("%.2f" ,zout); //dont know why but out by factor of 10 + wait_ms(5); + but3.fall(&menuscreen); + } + } \ No newline at end of file
diff -r 000000000000 -r 298e8a54dc2d SignalConditioning.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SignalConditioning.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,72 @@ +#include "header.h" +extern float per_old; +extern float per_new; +const double PI = 3.141592; +extern float Xave; +extern float Yave; +extern float Zave; +extern float Xtemp; //sample hold +extern float Xtest; +extern float Ytemp; +extern float Ytest; +extern float Ztemp; +extern float Ztest; +extern float xout; +extern float yout; +extern float zout; + +extern float Xund; +extern float Yund; +extern float Zund; +extern float Ax2; +extern float Ay2; +extern float Az2; + +extern float X; +extern float Y; +extern float Z; +extern float Xoff; //CHANGE TO ZERO BALL POSITION +extern float Yoff; //CHANGE TO ZERO BALL POSITION +extern float Zoff; //CHANGE TO ZERO BALL + +//Signal Conditioning + +void SigCon(void){ +// averaging using recursive method, a percentage of last iteration data + percentage of raw data + Xave=((Xave)*(per_old))+((acc.x())*(per_new)); + Yave=((Yave)*(per_old))+((acc.y())*(per_new)); + Zave=((Zave)*(per_old))+((acc.z())*(per_new)); + + xout=(Xave+Xoff); + yout=(Yave+Yoff); + zout=(Zave+Zoff); + + Xtest=((Xtemp)-(xout)); //stabalisation routine + Ytest=((Ytemp)-(yout)); + Ztest=((Ztemp)-(zout)); + + if (Xtest>-0.04 && Xtest<0.04){xout=Xtemp;} + if (Ytest>-0.04 && Ytest<0.04){yout=Ytemp;} + if (Ztest>-0.04 && Ztest<0.04){zout=Ztemp;} + + Ax2= pow(xout,2); // first stage calculations square value + Ay2= pow(yout,2); + Az2= pow(zout,2); + + Xund= sqrt(Ay2+Az2); // performs first part equation + Yund= sqrt(Ax2+Az2); + Zund= sqrt(Ax2+Ay2); + + float Xrads = atan(xout/Xund); //calculates andgles in radians + float Yrads = atan(yout/Yund); + float Zrads = atan(zout/Zund); + + X = ((Xrads*180)/PI); // convert from radians to degrees + Y = ((Yrads*180)/PI); + Z = ((Zrads*180)/PI); + + Xtemp=xout; + Ytemp=yout; + Ztemp=zout; + } +
diff -r 000000000000 -r 298e8a54dc2d bmp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bmp.h Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,129 @@ +const unsigned char bmp [] = { + + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
diff -r 000000000000 -r 298e8a54dc2d calibrate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calibrate.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,45 @@ +#include "header.h" + +extern float Xcal; +extern float Ycal; +extern float Zcal; +extern int i; +extern float per_old; +extern float per_new; +extern float sumx; +extern float sumy; +extern float sumz; +extern float Xoff; +extern float Yoff; +extern float Zoff; + +void calibrate(void){ + while (1){ + lcd.locate(1,11); lcd.printf("Press Select to Confirm"); + + sumx=0; + sumy=0; + sumz=0; + + for(i=0; i<199; i++) { + Xcal=((Xcal)*(per_old))+((acc.x())*(per_new)); + Ycal=((Ycal)*(per_old))+((acc.y())*(per_new)); + Zcal=((Zcal)*(per_old))+((acc.z())*(per_new)); + lcd.locate(1,9); lcd.printf("Calibrate"); lcd.printf("%i",(200-i)); + sumx += Xcal; + sumy += Ycal; + sumz += Zcal; + + } + Xoff=0-(sumx/200); + Yoff=0-(sumy/200); + Zoff=1-(sumz/200); + + lcd.locate(1,1); lcd.printf("X="); lcd.printf("%0.5f",Xoff); + lcd.locate(1,3); lcd.printf("Y="); lcd.printf("%0.5f",Yoff); + lcd.locate(1,5); lcd.printf("Z="); lcd.printf("%0.5f",Zoff); + + but2.fall(&menuscreen); + } + +} \ No newline at end of file
diff -r 000000000000 -r 298e8a54dc2d header.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/header.h Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,29 @@ +#ifndef MBED_HEADER_H +#define MBED_HEADER_H + +//Libraries +#include "mbed.h" +#include "LIS302.h" +#include "MobileLCD.h" +#include "BitmapFile.h" +#include "bmp.h" + +static LIS302 acc(p11,p12,p13,p14); //define pinouts for accelerometer +static MobileLCD lcd(p5,p6,p7,p8,p9); //define pinouts for LCD +static Serial pc(USBTX,USBRX); //define pinouts for USB comms if needed +static InterruptIn but1 (p21); +static InterruptIn but2 (p22); +static InterruptIn but3 (p23); + +//Master Function List +void Graphic(void); +void menuscroll(void); +void Select(void); +void menuscreen(void); +void Precise(void); +void SigCon(void); +void calibrate(void); + +#endif + +
diff -r 000000000000 -r 298e8a54dc2d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,71 @@ +//Modules +#include "header.h" +float per_old =0.895; +float per_new =(1-per_old); + + +float xsub=0; +float ysub=0; +float zsub=0; +int menu; +int i; +int j; +int Xa = 0; +int Za = 0; +int Ya = 0; +float Ax2; +float Ay2; +float Az2; +float Xund; +float Yund; +float Zund; + +float X=0; +float Y=0; +float Z=0; + +float Xave; +float Yave; +float Zave; +float Xtemp; //sample hold +float Xtest; +float Ytemp; +float Ytest; +float Ztemp; +float Ztest; +float xball; +float yball; +float xout=0; +float yout=0; +float zout=0; +long ball; +long a; +long b; +long a2; +long b2; +long k; +long red; +long blue; +long green; +long col; +float Xoff =0; //CHANGE TO ZERO BALL POSITION +float Yoff =0; //CHANGE TO ZERO BALL POSITION +float Zoff =0; //CHANGE TO ZERO BALL POSITION +float Xcal; +float Ycal; +float Zcal; +float sumx; +float sumy; +float sumz; +int main() { + + while (1) { + + menuscreen(); + + } +} + + + +
diff -r 000000000000 -r 298e8a54dc2d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 12 20:40:52 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0