Final Code For HK

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
nbharaths
Date:
Tue Jul 08 16:03:07 2014 +0000
Commit message:
HkFinal;

Changed in this revision

hkfinal.c Show annotated file Show diff for this revision Revisions of this file
hkfinal.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hkfinal.c	Tue Jul 08 16:03:07 2014 +0000
@@ -0,0 +1,53 @@
+struct SensorData {
+    char Voltage[10];
+    char Current[10];
+    char Temperature[10];
+    //float Battery[2];
+} SensorData;
+
+int quantiz(float start,float step,float x)
+{
+    int y=((x*3.18/65536)-start)/step;
+    if(y<=0)y=0;
+    if(y>=15)y=15;
+    return y;
+}
+
+void FUNC_HK_MAIN()
+{
+
+    int LoopIterator;
+
+    SelectLine0=0;
+    SelectLine1=0;
+    SelectLine2=0;
+    SelectLine3=0;
+
+    for(LoopIterator=0; LoopIterator<16; LoopIterator++) {
+
+        if(LoopIterator%2==0) {
+            SensorData.Current[LoopIterator]=quantiz(start,step,CurrentInput.read_u16());
+            SensorData.Voltage[LoopIterator]=quantiz(start,step,VoltageInput.read_u16());
+            SensorData.Temperature[LoopIterator]=quantiz(start,step,TemperatureInput.read_u16());
+        } else {
+            SensorData.Current[LoopIterator-1]=Current[LoopIterator-1]<<4+quantiz(start,step,CurrentInput.read_u16());
+            SensorData.Voltage[LoopIterator-1]=Voltage[LoopIterator-1]<<4+quantiz(start,step,VoltageInput.read_u16());
+            SensorData.Temperature[LoopIterator-1]=Temperature[LoopIterator-1]<<4+quantiz(start,step,TemperatureInput.read_u16());
+        }
+// 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.
+
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hkfinal.h	Tue Jul 08 16:03:07 2014 +0000
@@ -0,0 +1,12 @@
+DigitalOut SelectLine3 (p24); // MSB of Select Lines
+DigitalOut SelectLine2 (p23);
+DigitalOut SelectLine1 (p22);
+DigitalOut SelectLine0 (p21); // LSB of Select Lines
+
+AnalogIn CurrentInput(p15); // Input from Current Multiplexer
+AnalogIn VoltageInput(p16); // Input from Voltage Multiplexer
+AnalogIn TemperatureInput(p17); // input from Temperature Multiplexer
+
+void FUNC_HK_MAIN();
+
+int quantiz(float start,float step,float x);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jul 08 16:03:07 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file