โปรแกรมของบอร์ด Motion
Dependencies: BEAR_Reciever Motor eeprom iSerial mbed
Fork of DogPID by
Diff: main.cpp
- Revision:
- 33:65cfa4b72195
- Parent:
- 32:1f81f3e83889
- Child:
- 36:1561b6d61095
--- a/main.cpp Tue Feb 02 01:31:15 2016 +0000 +++ b/main.cpp Wed Feb 03 14:23:47 2016 +0000 @@ -32,7 +32,7 @@ //-- Communication -- Serial PC(D1,D0); Bear_Receiver com(Tx,Rx,1000000); -int16_t MY_ID = 0x02; +int16_t MY_ID = 0x01; //-- Memorry -- EEPROM memory(PB_4,PA_8,0); uint8_t UpMargin[4]; @@ -102,11 +102,18 @@ 253, 252, 248, 232, 224, 226, 98, 96, 32, 33, 37, 53, 61, 60, 188, 190, 254, 126, 124, 116, 112, 113, 49, 48, 16, 144, 146, 154, 158, 30, 94, 95 }; - - while(Val != codes[i]) { - i++; + if ( MY_ID == 0x01 )//when it was left side + { + while(Val != codes[i]) { + i++; + } } - + if ( MY_ID == 0x02 )//when it was right side + { + while(Val != codes[127-i]) { + i++; + } + } return i; } @@ -746,9 +753,12 @@ Up_PID.setSetPoint(Upper_SetPoint); Low_PID.setSetPoint(Lower_SetPoint); + Read_Encoder(EncoderB); + Lower_Position = Get_EnValue(data); + PC.printf("position = %2f\n",Lower_Position); //Control Motor - Move_Upper(); - Move_Lower(); + //Move_Upper(); + //Move_Lower(); ///////////////////////////////////////////////////// stop =306us //uint8_t aaa[1]={10}; //com.sendBodyWidth(0x01,aaa);