![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
working code of bae with i2c
Fork of all_combined_week6 by
Diff: HK.cpp
- Revision:
- 6:82153349cc9b
- Parent:
- 4:79b97f9cab00
--- a/HK.cpp Sat Jul 12 07:27:15 2014 +0000 +++ b/HK.cpp Tue Jul 15 10:04:38 2014 +0000 @@ -29,11 +29,12 @@ x.ErrorFlag[0]=3; } +ShortBeacy Shortbeacon; void FUNC_HK_MAIN() { + printf("\nEntered function HK MAIN\n"); - ShortBeacy ShortBeacon; - init_beacon(ShortBeacon); + init_beacon(Shortbeacon); int LoopIterator; @@ -45,13 +46,13 @@ for(LoopIterator=0; LoopIterator<16; LoopIterator++) { if(LoopIterator%2==0) { - Sensor.Current[LoopIterator/2]=quantiz(cstart,cstep,(CurrentInput.read()/(50*rsens))); - Sensor.Voltage[LoopIterator/2]=quantiz(vstart,vstep,(VoltageInput.read()/5.37)); + Sensor.Current[LoopIterator/2]=quantiz(cstart,cstep,((CurrentInput.read()*3.18)/(50*rsens))); + Sensor.Voltage[LoopIterator/2]=quantiz(vstart,vstep,(VoltageInput.read()*3.18*5.37)); Sensor.Temperature[LoopIterator/2]=quantiz(tstart,tstep,(-90.7*3.18*TemperatureInput.read()+190.1543)); } else { - Sensor.Current[(LoopIterator-1)/2]=Sensor.Current[LoopIterator-1]<<4+quantiz(cstart,cstep,(CurrentInput.read()/(50*rsens))); - Sensor.Voltage[(LoopIterator-1)/2]=Sensor.Voltage[LoopIterator-1]<<4+quantiz(vstart,vstep,(VoltageInput.read()/5.37)); - Sensor.Temperature[(LoopIterator-1)/2]=Sensor.Temperature[LoopIterator-1]<<4+quantiz(tstart,tstep,(-90.7*3.18*TemperatureInput.read()+190.1543)); + Sensor.Current[(LoopIterator-1)/2]=(Sensor.Current[(LoopIterator-1)/2]<<4)+quantiz(cstart,cstep,((CurrentInput.read()*3.18)/(50*rsens))); + Sensor.Voltage[(LoopIterator-1)/2]=(Sensor.Voltage[(LoopIterator-1)/2]<<4)+quantiz(vstart,vstep,(VoltageInput.read()*3.18*5.37)); + Sensor.Temperature[(LoopIterator-1)/2]=(Sensor.Temperature[(LoopIterator-1)/2]<<4)+quantiz(tstart,tstep,(-90.7*3.18*TemperatureInput.read()+190.1543)); } // The following lines are used to iterate the select lines from 0 to 15 SelectLine0=!(SelectLine0); @@ -68,5 +69,12 @@ wait_us(10.0); // A delay of 10 microseconds between each sensor output. Can be changed. } - + for(int i=0;i<8;i++) + { + printf("\nVoltage %d is %u\n",i,Sensor.Voltage[i]); + printf("\nCurrent %d is %u\n",i,Sensor.Current[i]); + printf("\nTemperature %d is %u\n",i,Sensor.Temperature[i]); + } + + printf("\nExited function HK MAIN\n"); } \ No newline at end of file