
Juggler Position Control Parsing
Dependencies: MODSERIAL mbed Servo
Fork of juggler_mbed_position_control by
Diff: main.cpp
- Revision:
- 8:b7a08dbbe1f9
- Parent:
- 7:7f6490ede6eb
--- a/main.cpp Mon Jan 16 04:20:35 2017 +0000 +++ b/main.cpp Mon Jan 16 21:48:18 2017 +0000 @@ -9,6 +9,7 @@ #define POWER_OFF 32768 #define BACKWARD_MAX 0 #define FORWARD_MAX USHRT_MAX +#define SEND_PERIOD_TIME_S 0.002 MODSERIAL pcSerial(USBTX, USBRX); @@ -29,6 +30,10 @@ SerialComm serialComm(&pcSerial); bool readyToSendNext; +void timerFcn() +{ + readyToSendNext = true; +} int main(void) { @@ -52,9 +57,9 @@ pcSerial.printf("Start!\n"); readyToSendNext = false; - /* - aTimer.attach(&timerFcn, 0.002); // the address of the function to be attached (flip) and the interval (2 seconds) - */ + + //aTimer.attach(&timerFcn, SEND_PERIOD_TIME_S ); // the address of the function to be attached (flip) and the interval (2 seconds) + while(1) { if(serialComm.checkIfNewMessage()) { // read message from PC in order to clear the buffer @@ -92,14 +97,16 @@ } if(readyToSendNext == true) { - led4 = 1; + //led4 = 1; // reading in current speed motorSpeedMeas = motorSpeed.read_u16(); //sending speed to host - serialComm.sendUnsignedShort(motorSpeedMeas); + //serialComm.sendUnsignedShort(motorSpeedMeas); + + serialComm.sendUnsignedShort(motorCommandReceived); readyToSendNext = false; - led4 = 0; + //led4 = 0; } }