statemachine
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@8:b2e57b815f68, 2019-09-20 (annotated)
- Committer:
- boydmartherus
- Date:
- Fri Sep 20 10:16:14 2019 +0000
- Revision:
- 8:b2e57b815f68
- Parent:
- 6:c2608dedfd70
merge_poging2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobertoO | 0:67c50348f842 | 1 | #include "mbed.h" |
Mortimerz | 3:ea5f67f11825 | 2 | #include "MODSERIAL.h"; |
Mortimerz | 3:ea5f67f11825 | 3 | #include "FastPWM.h" ; |
MarliesWeggemans | 4:3e9a8f5d9a1a | 4 | #include "QEI.h"; |
Mortimerz | 3:ea5f67f11825 | 5 | |
Mortimerz | 3:ea5f67f11825 | 6 | Serial pc(USBTX,USBRX); |
boydmartherus | 6:c2608dedfd70 | 7 | |
boydmartherus | 8:b2e57b815f68 | 8 | // motor control |
boydmartherus | 8:b2e57b815f68 | 9 | AnalogIn pot(PTB2); |
boydmartherus | 6:c2608dedfd70 | 10 | FastPWM motor(D5); |
MarliesWeggemans | 4:3e9a8f5d9a1a | 11 | |
boydmartherus | 6:c2608dedfd70 | 12 | // Encoding |
boydmartherus | 6:c2608dedfd70 | 13 | int pulses = 131; |
MarliesWeggemans | 5:9ebcbd39ec3f | 14 | QEI wheel (D13,D12,NC, pulses); |
Mortimerz | 3:ea5f67f11825 | 15 | |
boydmartherus | 6:c2608dedfd70 | 16 | |
boydmartherus | 8:b2e57b815f68 | 17 | int main() |
boydmartherus | 8:b2e57b815f68 | 18 | { |
MarliesWeggemans | 5:9ebcbd39ec3f | 19 | while(1){ |
MarliesWeggemans | 5:9ebcbd39ec3f | 20 | wait(0.1); |
boydmartherus | 8:b2e57b815f68 | 21 | printf("motor relative speed is (%f)\n\r",pot.read()); |
boydmartherus | 8:b2e57b815f68 | 22 | wait(0.1); |
boydmartherus | 8:b2e57b815f68 | 23 | motor.write(pot); |
MarliesWeggemans | 5:9ebcbd39ec3f | 24 | } |
boydmartherus | 8:b2e57b815f68 | 25 | while(true){ |
boydmartherus | 8:b2e57b815f68 | 26 | wait(0.1); |
boydmartherus | 8:b2e57b815f68 | 27 | pc.printf("Pulses is: %i\n", wheel.getPulses()); |
boydmartherus | 8:b2e57b815f68 | 28 | wait(0.1); |
boydmartherus | 8:b2e57b815f68 | 29 | } |