Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)
Fork of Motor by
Revision 6:a321d28cce9a, committed 2015-05-09
- Comitter:
- michal0074
- Date:
- Sat May 09 11:04:49 2015 +0000
- Parent:
- 5:71d7e9c17980
- Child:
- 7:d25073d59616
- Commit message:
- 2165;
Changed in this revision
Motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
Motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
--- a/Motor.h Thu May 07 11:05:06 2015 +0000 +++ b/Motor.h Sat May 09 11:04:49 2015 +0000 @@ -35,11 +35,12 @@ #define AUTO 1 /*QEI pins*/ +/* #define CH_A PTA2 #define CH_B PTA3 const int pPerRev = 10; const int max_pulse_rate = 300; //do policzenia!!!!!!!!!!!!!!!!!!! - +*/ /** Interface to control a standard DC motor * * with an H-bridge using a PwmOut and 2 DigitalOuts @@ -67,12 +68,13 @@ DigitalOut _rev; private: PID speedControl; - QEI encoder; + //QEI encoder; float set_speed; int pulses; float curr_speed; float prev_pulses; + }; #endif