lyre liu / Mbed 2 deprecated project1

Dependencies:   mbed

Revision:
17:688db5210e6b
Parent:
16:3cf10425a0f1
Child:
18:66c692073c2c
--- a/main.cpp	Tue Mar 08 15:01:15 2016 +0000
+++ b/main.cpp	Thu Mar 10 15:02:45 2016 +0000
@@ -1,5 +1,5 @@
 #include "mbed.h"
-#define RATIO 1                      //The amplified factor of the OA
+#define RATIO 2000                      //The amplified factor of the OA
 #define SAMPLE_TIME 500             // Sample time, default is 100ms
 void MassCompute(float);            // The function of computing mass from voltage.
 void SerialInit(void);              // The function fo serial initial
@@ -14,7 +14,7 @@
 DigitalOut low_pin(p6);             //test pin, p6 is the low level pin
                                     
 float mass;                         // The mass of the object
-unsigned char mass_trans_high; // A 8 bits mass used for transmitting
+unsigned char mass_trans_high;      // A 8 bits mass used for transmitting
 unsigned char mass_trans_low;
 
 unsigned short int test;
@@ -45,7 +45,7 @@
     
     vol_ref = 3.3;
     
-    mass = 3000*vol_ref*vol/RATIO + 0.3;        //The compute function of mass from the voltage
+    mass = 333.3333*vol_ref*vol/RATIO ;        //The compute function of mass from the voltage
 }
 
 void SerialInit(void)
@@ -61,20 +61,20 @@
     end   = '$';
 
 
-    if(mass>3)
-        mass =3;
+    if(mass>0.3)
+        mass =0.3;
     mass_trans_low = (unsigned int)(mass*10000);
     mass_trans_high = (unsigned int)(mass*10000)>>8;
-    voltage_test = (unsigned int)voltage_measure*10;
+    //voltage_test = (unsigned int)voltage_measure*10;
     
-    voltage_high = (unsigned int)(voltage_measure*10000)>>8;
-    voltage_low  = (unsigned int)(voltage_measure*10000);
+    //voltage_high = (unsigned int)(voltage_measure*10000)>>8;
+   // voltage_low  = (unsigned int)(voltage_measure*10000);
     
     pc.printf("%c",start);
-    //pc.printf("%c",mass_trans_high);
-    //pc.printf("%c",mass_trans_low);
+    pc.printf("%c",mass_trans_high);
+    pc.printf("%c",mass_trans_low);
     
-    pc.printf("%c",voltage_high);
-    pc.printf("%c",voltage_low);
+    //pc.printf("%c",voltage_high);
+    //pc.printf("%c",voltage_low);
     pc.printf("%c",end);
 }
\ No newline at end of file