pot controller voor positie, kp handmatig instellen, werkt met motor 1 en 2
Dependencies: MODSERIAL QEI mbed-dsp mbed
Fork of PI_controller_verbeteringen by
Diff: main.cpp
- Revision:
- 8:9b517db94f49
- Parent:
- 7:e21056555296
- Child:
- 9:466dff9ae128
--- a/main.cpp Tue Sep 25 11:55:40 2018 +0000 +++ b/main.cpp Mon Oct 01 12:47:32 2018 +0000 @@ -32,9 +32,12 @@ while (true) { - pwmpin.write(pot1.read()); - direct = 1; - pc.printf("potmeter: %f, encoder: %i \r\n", pot1.read(), encoder.getPulses()); + float pot1_float = pot1.read(); + float pot1_motor = (pot1_float * 2.0f) - 1.0f; + int mot1_direction = pot1_motor >= 0; + pwmpin.write(fabs(pot1_motor)); + direct = mot1_direction; + pc.printf("potmeter: %f, encoder: %i \r\n", pot1_motor, encoder.getPulses()); wait(0.2f); } }