โปรแกรมของบอร์ด Motion

Dependencies:   BEAR_Reciever Motor eeprom iSerial mbed

Fork of DogPID by Digital B14

Revision:
7:bf239d051e8c
Parent:
6:98871feebea0
Child:
10:3b3d6bc88677
--- a/main.cpp	Sat Jan 16 01:17:21 2016 +0000
+++ b/main.cpp	Sat Jan 16 03:17:33 2016 +0000
@@ -42,14 +42,22 @@
 //*****************************************************/
 void Read_Encoder(PinName Encoder)
 {
-    Enc.format(8,0);
-    Enc.frequency(200000);//due to rising time,have to decrease clock from 1M - 240k
+    ENC.format(8,0);
+    ENC.frequency(200000);//due to rising time,have to decrease clock from 1M - 240k
 
-    Encoder = 0;
-    Enc.write(0x41);
-    Enc.write(0x09);
-    data = Enc.write(0x00);
-    Encoder = 1;
+    if(Encoder == EncoderA) {
+        EncA = 0;
+    } else {
+        EncB = 0;
+    }
+    ENC.write(0x41);
+    ENC.write(0x09);
+    data = ENC.write(0x00);
+    if(Encoder == EncoderA) {
+        EncA = 1;
+    } else {
+        EncB = 1;
+    }
 
 }
 //*****************************************************/
@@ -98,13 +106,13 @@
 
     Up_PID.setProcessValue(Upper_Position);
 
-    if(Upper_Position - Uppper_SetPoint > 0 ) {
+    if(Upper_Position - Upper_SetPoint > 0 ) {
         dir = 1;
     }
-    if(Upper_Position - Uppper_SetPoint < 0 ) {
+    if(Upper_Position - Upper_SetPoint < 0 ) {
         dir = -1;
     }
-    Upper.speed(LU_PID.compute() * dir);
+    Upper.speed(Up_PID.compute() * dir);
 }
 //******************************************************/
 void Move_Lower()
@@ -120,7 +128,7 @@
     if(Lower_Position - Lower_SetPoint < 0 ) {
         dir = -1;
     }
-    Lower.speed(LU_PID.compute() * dir);
+    Lower.speed(Low_PID.compute() * dir);
 }
 //******************************************************/