Accel
Dependencies: mbed PowerControl SDFileSystem
Fork of HeptaAccel by
Revision 1:63c3921c608c, committed 2016-12-13
- Comitter:
- tomoya123
- Date:
- Tue Dec 13 07:51:40 2016 +0000
- Parent:
- 0:d721efd58e4e
- Commit message:
- Accel
Changed in this revision
hepta_sat/HeptaAccel.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/hepta_sat/HeptaAccel.cpp Fri Dec 09 03:40:15 2016 +0000 +++ b/hepta_sat/HeptaAccel.cpp Tue Dec 13 07:51:40 2016 +0000 @@ -149,7 +149,7 @@ float az; accel.start(); accel.write(addr); - accel.write(0x2C); + accel.write(0x05); accel.start(); accel.write(addr|0x01); _zmsb = accel.read(0); @@ -167,6 +167,7 @@ acc -= UINT14_MAX; } az = acc/4096.0*9.81; + //printf("az=%f\r\n",az); return(az); } @@ -247,6 +248,7 @@ accel.start(); accel.write(addr|0x01); _xmsb = accel.read(0); + printf("xmsb=%d\r\n",_xmsb); accel.stop(); accel.start(); accel.write(addr); @@ -261,6 +263,7 @@ a_u16[1]=a1[1]; a_u16[2]=a2[0]; a_u16[3]=a2[1]; + printf("a_u16_0=%c",a_u16[0]); *dsize = 4; } @@ -299,6 +302,7 @@ accel.start(); accel.write(addr|0x01); _zmsb = accel.read(0); + printf("zmsb=%d\r\n",_zmsb); accel.stop(); accel.start(); accel.write(addr); @@ -306,6 +310,7 @@ accel.start(); accel.write(addr|0x01); _zlsb = accel.read(0); + printf("zlsb=%d\r\n",_zlsb); accel.stop(); sprintf( a1, "%02X", ((_zmsb)) & 0xFF); sprintf( a2, "%02X", ((_zlsb)) & 0xFF);
--- a/main.cpp Fri Dec 09 03:40:15 2016 +0000 +++ b/main.cpp Tue Dec 13 07:51:40 2016 +0000 @@ -5,19 +5,14 @@ HeptaAccel accel(p28,p27,0x38); int main(){ - pc.baud(9600); - float ax2,ay2,az2; - char ax[4],ay[4],az[4]; - int dsize; - while(1){ + pc.baud(9600); + float ax,ay,az; + while(1){ pc.printf("Accel Sensor Mode\r\n"); - for(int i=0;i<10;i++){ - accel.sensing_u16(ax,ay,az,&dsize); - accel.sensing(&ax2,&ay2,&az2); - pc.printf("%c%c%c%c %c%c%c%c %c%c%c%c %c%c%c%c\r\n",ax[0],ax[1],ax[2],ax[3],ay[0],ay[1],ay[2],ay[3], - az[0],az[1],az[2],az[3]); - pc.printf("%f %f %f\r\n",ax2,ay2,az2); - wait(1.0); - } - } + for(int i=0;i<10;i++){ + accel.sensing(&ax,&ay,&az); + pc.printf("%f %f %f\r\n",ax,ay,az); + wait(1.0); + } + } } \ No newline at end of file