test with PID control to screen on your computer
Dependencies: Motor_with_encoder MODSERIAL QEI mbed
Fork of Project_motor by
Diff: main.cpp
- Revision:
- 4:abdc2d24d0bc
- Parent:
- 3:4520d0ca4e56
- Child:
- 5:05d09e921b5d
--- a/main.cpp Fri Oct 06 12:14:32 2017 +0000 +++ b/main.cpp Mon Oct 09 14:47:16 2017 +0000 @@ -47,8 +47,8 @@ volatile float position = 0.0; void readpot(){ potvalue = pot.read(); - //position = motor1.getPosition(); - pc.printf("pos: %d, speed %f reference velocity = %.2f\r\n",motor1.getPosition(), motor1.getSpeed(), potvalue); + position = motor1.getPosition()/4200.00*6.28; + pc.printf("pos: %f, speed %f reference velocity = %.2f\r\n",position, motor1.getSpeed(), potvalue); motorspeed = potvalue; //motorpid = PID(potvalue - position, M1_KP, M1_KI, M1_KD, M1_TS, m1_err_int, m1_prev_err, m1_f_v1, m1_f_v2, M1_F_A1, M1_F_A2, M1_F_B0, M1_F_B1, M1_F_B2); }