Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)
Fork of Motor by
Diff: Motor.cpp
- Revision:
- 6:a321d28cce9a
- Parent:
- 5:71d7e9c17980
- Child:
- 7:d25073d59616
--- a/Motor.cpp Thu May 07 11:05:06 2015 +0000 +++ b/Motor.cpp Sat May 09 11:04:49 2015 +0000 @@ -24,7 +24,7 @@ #include "mbed.h" Motor::Motor(PinName pwm, PinName fwd, PinName rev) : -_pwm(pwm), _fwd(fwd), _rev(rev), speedControl(K, Ti, Td, itv), encoder(CH_A, CH_B, NC, pPerRev) +_pwm(pwm), _fwd(fwd), _rev(rev), speedControl(K, Ti, Td, itv)//, encoder(CH_A, CH_B, NC, pPerRev) { // Set initial condition of PWM @@ -43,7 +43,7 @@ } void Motor::speed(float speed) { - +/* if (speed != set_speed){ speedControl.setSetPoint(speed); set_speed = speed; @@ -55,7 +55,7 @@ speedControl.setProcessValue(curr_speed); speed = speedControl.compute(); - +*/ _fwd = (speed > 0.0); _rev = (speed < 0.0);