DC motor control program using TA7291P type driver and rotary encoder with A, B phase.
Dependencies: QEI mbed-rtos mbed
Revision 17:10be89ff33e8, committed 2012-12-08
- Comitter:
- kosaka
- Date:
- Sat Dec 08 05:57:32 2012 +0000
- Parent:
- 16:759d6f647c83
- Commit message:
- debug;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 759d6f647c83 -r 10be89ff33e8 main.cpp --- a/main.cpp Sat Dec 08 05:27:35 2012 +0000 +++ b/main.cpp Sat Dec 08 05:57:32 2012 +0000 @@ -1,5 +1,5 @@ // DC motor control program using H-bridge driver (ex. TA7291P) and 360 resolution rotary encoder with A, B phase. -// ver. 121208b by Kosaka lab. +// ver. 121208c by Kosaka lab. #include "mbed.h" #include "rtos.h" #include "QEI.h" @@ -109,6 +109,7 @@ float duty; unsigned int f_deadtime, f_in, r_in; +// u=-u; // Set PWM Minus logic for smooth shunt current if( u > 0 ){ // forward: rotate to plus u += DEADZONE_PLUS; // deadzone compensation duty = u/3.3; // Vref @@ -141,6 +142,7 @@ } #ifdef USE_PWM // H bridge PWM mode: Vref=Vcc, FIN,2 = PWM or 0 FIN = duty*(float)f_in; RIN = duty*(float)r_in; // setting pwm FIN & RIN +// FIN = (1-duty*(float)f_in); RIN = (1-duty*(float)r_in); // setting pwm FIN & RIN. Minus logic for smooth shunt current analog_out = 1; // setting Vref=UMAX, but Vref=Vcc is better. #else // Analog mode: Vref=analog, FIN, RIN = 1 or 0) FIN = f_in; RIN = r_in; // setting FIN & RIN @@ -420,8 +422,8 @@ pc.printf("Control start!!\r\n"); motor_control(); // motor control ON for TMAX seconds. pc.printf("Control completed!!\r\n\r\n"); - ThreadTimerTS3.terminate(); - ThreadTimerTS4.terminate(); +// ThreadTimerTS3.terminate(); +// ThreadTimerTS4.terminate(); // Change parameters using tera term #if CONTROL_MODE>=1 // frequency response, or Step response