green rosh
/
RTOS_BAE_IITMSAT
Rtos code for BAE microcontroller, IITMSAT
Diff: HK.cpp
- Revision:
- 2:1792c9cda669
- Child:
- 3:307c56629df0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HK.cpp Fri Jul 04 11:30:40 2014 +0000 @@ -0,0 +1,63 @@ + +#include "HK.h" + + SensorData Sensor; + + DigitalOut SelectLine3 (p24); // MSB of Select Lines + + DigitalOut SelectLine2 (p23); + + DigitalOut SelectLine1 (p22); + + DigitalOut SelectLine0 (p21); // LSB of Select Lines + + AnalogIn AnalogInput(p15); // Input from Multiplexer + + + +void FUNC_HK_MAIN() +{ + + int LoopIterator; + printf("\nHK invoked\n"); + SelectLine0=0; + SelectLine1=0; + SelectLine2=0; + SelectLine3=0; + + for(LoopIterator=0; LoopIterator<16; LoopIterator++) { + + float SignalValue= AnalogInput.read()*3.180; // Calculation using ADC Reference + float Temperature=-90.7*SignalValue+190.1543; // Linear Equation for Temperature Sensor + + + if(LoopIterator%3==0) + Sensor.Current[LoopIterator/3]=SignalValue/4.37; // Equation for Current Sensor + + if(LoopIterator%3==1) + Sensor.Voltage[LoopIterator/3]=SignalValue*4.64; // Equation for Voltage Sensor || GAIN NEEDS TO BE CHANGED || + + + if(LoopIterator%3==2) + Sensor.Temp[LoopIterator/3]=Temperature; + + + // The following lines are used to iterate the select lines from 0 to 15 + SelectLine0=!(SelectLine0); + + if(LoopIterator%2==1) + SelectLine1=!(SelectLine1); + + if(LoopIterator%4==3) + SelectLine2=!(SelectLine2); + + if(LoopIterator%8==7) + SelectLine3=!(SelectLine3); + + wait_us(10.0); // A delay of 10 microseconds between each sensor output. Can be changed. + } + +} + + +