integrated code with threads to be removed
Fork of BAE_vr3honeycomb1 by
Diff: ACS.cpp
- Revision:
- 3:89a09736acd3
- Parent:
- 2:edd107ea4740
diff -r edd107ea4740 -r 89a09736acd3 ACS.cpp --- a/ACS.cpp Fri Dec 26 06:12:09 2014 +0000 +++ b/ACS.cpp Wed Jan 28 17:35:45 2015 +0000 @@ -6,8 +6,8 @@ //PWM output comes from pins p6 Serial pc1(USBTX, USBRX); SPI spi_acs (PIN16, PIN17, PIN15); // mosi, miso, sclk PTE18,19,17 -DigitalOut SSN_MAG (PTC16); // ssn for magnetometer PTB11 -DigitalInOut DRDY (PTE3); // drdy for magnetometer PTA17 +DigitalOut SSN_MAG (PTA7); // ssn for magnetometer PTB11 +DigitalInOut DRDY (PTA6); // drdy for magnetometer PTA17 DigitalOut ssn_gyr (PTE2); //Slave Select pin of gyroscope PTB16 InterruptIn dr(PTC6); //Interrupt pin for gyro PTC5 PwmOut PWM1(D2); //Functions used to generate PWM signal @@ -31,7 +31,7 @@ float timep = 0.02 ; float Mx=M[0]; //Time period is set to 0.02s //Moment in x, y, z directions - + printf("\n the moment is %f",M[0]); ix = Mx * 0.3 ; //Moment and Current always have the linear relationship @@ -212,21 +212,21 @@ a = DRDY; printf("\n DRDY is %d\n",a); SSN_MAG=0; //enabling slave to measure the values - wait_ms(10); + wait_ms(100); spi_acs.write(0x82); //initiates measurement - wait_ms(10); + wait_ms(100); spi_acs.write(0x01); //selecting x,y and z axes, measurement starts now SSN_MAG=1; - wait_ms(10); + //wait_ms(10); trflag_mag=1; tr_mag.attach(&trsub_mag,1); //runs in background,makes trflag_mag=0 after 1s - DRDY.input(); + //DRDY.input(); while(trflag_mag) /*initially flag is 1,so loop is executed,if DRDY is high,then data is retrieved and programme ends,else loop runs for at the max 1s and if still DRDY is zero,the flag becomes 0 and loop is not executed and programme is terminated*/ { - wait_ms(5); + //wait_ms(5); if(DRDY==1) { printf("\nwth\n"); @@ -256,12 +256,13 @@ Bnewvalue[axis]=(float)Bvalue[axis]*22.0*pow(10.0,-3.0); //1 LSB=(22nT)...final value of field obtained in micro tesla wait_ms(10); + Bnewvalue[0] = 100.00; printf("\t%lf\n",Bnewvalue[axis]); } SSN_MAG=1; /* for test only to removed */ - Bnewvalue[0]=Bnewvalue[1]=Bnewvalue[2]=100; + //Bnewvalue[0]=Bnewvalue[1]=Bnewvalue[2]=100.0; return Bnewvalue; //return here? doubt.. break; }