no beacon yes yes beacon no

Dependencies:   mbed-rtos mbed

Fork of all_combined_week6 by green rosh

Committer:
viswachaitanya
Date:
Fri Sep 19 10:35:04 2014 +0000
Revision:
8:772ec80d9c29
Parent:
7:b3f876f605d9
updated one

Who changed what in which revision?

UserRevisionLine numberNew contents of line
greenroshks 4:79b97f9cab00 1 #include "HK.h"
greenroshks 4:79b97f9cab00 2
greenroshks 4:79b97f9cab00 3 DigitalOut SelectLine3 (p24); // MSB of Select Lines
greenroshks 4:79b97f9cab00 4 DigitalOut SelectLine2 (p23);
greenroshks 4:79b97f9cab00 5 DigitalOut SelectLine1 (p22);
greenroshks 4:79b97f9cab00 6 DigitalOut SelectLine0 (p21); // LSB of Select Lines
greenroshks 4:79b97f9cab00 7
greenroshks 4:79b97f9cab00 8 AnalogIn CurrentInput(p15); // Input from Current Multiplexer
greenroshks 4:79b97f9cab00 9 AnalogIn VoltageInput(p16); // Input from Voltage Multiplexer
greenroshks 4:79b97f9cab00 10 AnalogIn TemperatureInput(p17); // input from Temperature Multiplexer
greenroshks 4:79b97f9cab00 11
greenroshks 4:79b97f9cab00 12 SensorData Sensor;
greenroshks 4:79b97f9cab00 13 int quantiz(float start,float step,float x)
greenroshks 4:79b97f9cab00 14 {
greenroshks 4:79b97f9cab00 15 int y=(x-start)/step;
greenroshks 4:79b97f9cab00 16 if(y<=0)y=0;
greenroshks 4:79b97f9cab00 17 if(y>=15)y=15;
greenroshks 4:79b97f9cab00 18 return y;
greenroshks 4:79b97f9cab00 19 }
greenroshks 7:b3f876f605d9 20 ShortBeacy Shortbeacon;
greenroshks 4:79b97f9cab00 21 void init_beacon(ShortBeacy x){
greenroshks 7:b3f876f605d9 22 ;
greenroshks 4:79b97f9cab00 23 }
greenroshks 4:79b97f9cab00 24
greenroshks 7:b3f876f605d9 25
greenroshks 4:79b97f9cab00 26 void FUNC_HK_MAIN()
greenroshks 4:79b97f9cab00 27 {
greenroshks 6:82153349cc9b 28 printf("\nEntered function HK MAIN\n");
greenroshks 4:79b97f9cab00 29
greenroshks 7:b3f876f605d9 30 Shortbeacon.Voltage[0]=1;
greenroshks 7:b3f876f605d9 31 Shortbeacon.AngularSpeed[0]=2;
greenroshks 7:b3f876f605d9 32 Shortbeacon.AngularSpeed[1]=3;
greenroshks 7:b3f876f605d9 33 Shortbeacon.SubsystemStatus[0]=145;
greenroshks 7:b3f876f605d9 34 Shortbeacon.Temp[0]=1;
greenroshks 7:b3f876f605d9 35 Shortbeacon.Temp[1]=2;
greenroshks 7:b3f876f605d9 36 Shortbeacon.Temp[2]=3;
greenroshks 7:b3f876f605d9 37 Shortbeacon.ErrorFlag[0]=3;
greenroshks 4:79b97f9cab00 38
greenroshks 4:79b97f9cab00 39 int LoopIterator;
greenroshks 4:79b97f9cab00 40
greenroshks 4:79b97f9cab00 41 SelectLine0=0;
greenroshks 4:79b97f9cab00 42 SelectLine1=0;
greenroshks 4:79b97f9cab00 43 SelectLine2=0;
greenroshks 4:79b97f9cab00 44 SelectLine3=0;
greenroshks 4:79b97f9cab00 45
greenroshks 4:79b97f9cab00 46 for(LoopIterator=0; LoopIterator<16; LoopIterator++) {
greenroshks 4:79b97f9cab00 47
greenroshks 4:79b97f9cab00 48 if(LoopIterator%2==0) {
greenroshks 6:82153349cc9b 49 Sensor.Current[LoopIterator/2]=quantiz(cstart,cstep,((CurrentInput.read()*3.18)/(50*rsens)));
greenroshks 6:82153349cc9b 50 Sensor.Voltage[LoopIterator/2]=quantiz(vstart,vstep,(VoltageInput.read()*3.18*5.37));
greenroshks 4:79b97f9cab00 51 Sensor.Temperature[LoopIterator/2]=quantiz(tstart,tstep,(-90.7*3.18*TemperatureInput.read()+190.1543));
greenroshks 4:79b97f9cab00 52 } else {
greenroshks 6:82153349cc9b 53 Sensor.Current[(LoopIterator-1)/2]=(Sensor.Current[(LoopIterator-1)/2]<<4)+quantiz(cstart,cstep,((CurrentInput.read()*3.18)/(50*rsens)));
greenroshks 6:82153349cc9b 54 Sensor.Voltage[(LoopIterator-1)/2]=(Sensor.Voltage[(LoopIterator-1)/2]<<4)+quantiz(vstart,vstep,(VoltageInput.read()*3.18*5.37));
greenroshks 6:82153349cc9b 55 Sensor.Temperature[(LoopIterator-1)/2]=(Sensor.Temperature[(LoopIterator-1)/2]<<4)+quantiz(tstart,tstep,(-90.7*3.18*TemperatureInput.read()+190.1543));
greenroshks 4:79b97f9cab00 56 }
greenroshks 4:79b97f9cab00 57 // The following lines are used to iterate the select lines from 0 to 15
greenroshks 4:79b97f9cab00 58 SelectLine0=!(SelectLine0);
greenroshks 4:79b97f9cab00 59
greenroshks 4:79b97f9cab00 60 if(LoopIterator%2==1)
greenroshks 4:79b97f9cab00 61 SelectLine1=!(SelectLine1);
greenroshks 4:79b97f9cab00 62
greenroshks 4:79b97f9cab00 63 if(LoopIterator%4==3)
greenroshks 4:79b97f9cab00 64 SelectLine2=!(SelectLine2);
greenroshks 4:79b97f9cab00 65
greenroshks 4:79b97f9cab00 66 if(LoopIterator%8==7)
greenroshks 4:79b97f9cab00 67 SelectLine3=!(SelectLine3);
greenroshks 4:79b97f9cab00 68
greenroshks 4:79b97f9cab00 69 wait_us(10.0); // A delay of 10 microseconds between each sensor output. Can be changed.
greenroshks 4:79b97f9cab00 70
greenroshks 4:79b97f9cab00 71 }
viswachaitanya 8:772ec80d9c29 72 /*for(int iii=0;iii<8;iii++)
viswachaitanya 8:772ec80d9c29 73 {
viswachaitanya 8:772ec80d9c29 74
viswachaitanya 8:772ec80d9c29 75 printf("\nVoltage is %u\n",Sensor.Voltage[iii]);
viswachaitanya 8:772ec80d9c29 76 printf("\nCurrent is %u\n",Sensor.Current[iii]);
viswachaitanya 8:772ec80d9c29 77 printf("\ntemperature is %u\n",Sensor.Temperature[iii]);
viswachaitanya 8:772ec80d9c29 78 }*/
greenroshks 6:82153349cc9b 79
greenroshks 6:82153349cc9b 80 printf("\nExited function HK MAIN\n");
greenroshks 7:b3f876f605d9 81 }