Biorobotics
/
Controller
Controller futhers (PI)
Diff: main.cpp
- Revision:
- 10:3796b6a6c239
- Parent:
- 9:ea9d35838861
- Child:
- 11:e2b2ea8a3be8
--- a/main.cpp Tue Oct 27 10:30:54 2015 +0000 +++ b/main.cpp Tue Oct 27 14:02:40 2015 +0000 @@ -2,12 +2,17 @@ #include "QEI.h" Serial pc(USBTX, USBRX); -QEI wheel (PTC10, PTC11, NC, 624); // Pin for counting (analog in) +//QEI wheel_one (PTC10, PTC11, NC, 624); // Pin for counting (analog in) +//QEI wheel_one (PTD3, PTD1, NC, 624); +QEI wheel_two (PTD0, PTD2, NC, 624); // Define pin for motor control DigitalOut directionPin_one(D4); PwmOut PWM_one(D5); +PwmOut PWM_two(D6); +DigitalOut directionPin_two(D7); + DigitalIn buttonccw(PTA4); DigitalIn buttoncw(PTC6); @@ -18,7 +23,8 @@ // define rotation direction and begin possition const int cw = 1; const int ccw = 0; -double setpoint = 0; //setpoint is in pulses +double setpoint_one = 0; //setpoint is in pulses +double setpoint_two = 0; //"" "" // saying buttons are not pressed const int Buttoncw_pressed = 0; @@ -95,7 +101,8 @@ else{ output = 0; } -PWM.write(output); // out of the if loop due to abs output + + PWM.write(output); // out of the if loop due to abs output } @@ -104,8 +111,11 @@ void counts_showing() { - double kijken = wheel.getPulses()/pulses_per_revolution; - pc.printf("ref %.2f rounds%.2f \n",setpoint/pulses_per_revolution,kijken); + //double kijken = wheel_one.getPulses()/pulses_per_revolution; + //pc.printf("ref %.2f rounds%.2f \n",setpoint_one/pulses_per_revolution,kijken); + + double kijken = wheel_two.getPulses()/pulses_per_revolution; + pc.printf("ref %.2f rounds%.2f \n",setpoint_two/pulses_per_revolution,kijken); } @@ -117,7 +127,8 @@ // to make the motor move if(flag_motor) { flag_motor = false; - motor1_Controller(directionPin, PWM, wheel, setpoint); + //motor1_Controller(directionPin_one, PWM_one, wheel_one, setpoint_one); + motor1_Controller(directionPin_two, PWM_two, wheel_two, setpoint_two); } if(flag_pcprint) { @@ -127,11 +138,16 @@ // Pussing buttons to get input signal - if(buttoncw.read() == Buttoncw_pressed){ - setpoint = making_setpoint(cw, setpoint); + if(buttoncw.read() == Buttoncw_pressed) + { + //setpoint_one = making_setpoint(cw, setpoint_one); + setpoint_two = making_setpoint(ccw, setpoint_two); } - if(buttonccw.read() == Buttonccw_pressed) { - setpoint = making_setpoint(ccw, setpoint); + + if(buttonccw.read() == Buttonccw_pressed) + { + //setpoint_one = making_setpoint(ccw, setpoint_one); + setpoint_two = making_setpoint(cw, setpoint_two); } }