Basic DC motor control test, rpm feedback by simple impulse signal, PID speed control.
Dependencies: FastPWM mbed FastIO MODSERIAL
Diff: main.cpp
- Revision:
- 2:70918f7f8451
- Parent:
- 1:70c514e10598
- Child:
- 3:f6c30ada5370
diff -r 70c514e10598 -r 70918f7f8451 main.cpp --- a/main.cpp Thu Mar 22 11:23:31 2018 +0000 +++ b/main.cpp Fri Mar 23 12:31:38 2018 +0000 @@ -1,22 +1,26 @@ #include "mbed.h" #include "FastPWM.h" +#include "FastIO.h" FastPWM mypwm(PWM_OUT); DigitalOut myled(LED1); +Serial pcLink(SERIAL_TX, SERIAL_RX); + int main() { mypwm.period_us(100); mypwm.write(0.0); - printf("pwm set to %.2f %%\n", mypwm.read() * 100); + pcLink.printf("pwm set to %.2f %%\n", mypwm.read() * 100); while(1) { int iCnt = 0; double dPwmDuty = 0.0; mypwm.write(dPwmDuty); + pcLink.printf("pwm set to %.2f %%\n", mypwm.read() * 100); if (10 < iCnt++) { iCnt = 0;