![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
br g5
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@6:c2608dedfd70, 2019-09-20 (annotated)
- Committer:
- boydmartherus
- Date:
- Fri Sep 20 09:41:43 2019 +0000
- Revision:
- 6:c2608dedfd70
- Parent:
- 5:9ebcbd39ec3f
- Child:
- 7:d5e07647dfea
- Child:
- 8:b2e57b815f68
merge motor control en encoding
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 | AnalogIn pot(PTB2); |
Mortimerz | 3:ea5f67f11825 | 7 | Serial pc(USBTX,USBRX); |
boydmartherus | 6:c2608dedfd70 | 8 | |
boydmartherus | 6:c2608dedfd70 | 9 | FastPWM motor(D5); |
MarliesWeggemans | 4:3e9a8f5d9a1a | 10 | |
boydmartherus | 6:c2608dedfd70 | 11 | // Encoding |
boydmartherus | 6:c2608dedfd70 | 12 | int pulses = 131; |
MarliesWeggemans | 5:9ebcbd39ec3f | 13 | QEI wheel (D13,D12,NC, pulses); |
Mortimerz | 3:ea5f67f11825 | 14 | |
boydmartherus | 6:c2608dedfd70 | 15 | |
Mortimerz | 3:ea5f67f11825 | 16 | int main(){ |
MarliesWeggemans | 5:9ebcbd39ec3f | 17 | while(1){ |
MarliesWeggemans | 5:9ebcbd39ec3f | 18 | wait(0.1); |
MarliesWeggemans | 5:9ebcbd39ec3f | 19 | pc.printf("Pulses is: %i\n", wheel.getPulses()); |
boydmartherus | 6:c2608dedfd70 | 20 | printf("motor relative speed is (%f)\n\r",pot.read()); |
boydmartherus | 6:c2608dedfd70 | 21 | motor.write(pot); |
MarliesWeggemans | 5:9ebcbd39ec3f | 22 | } |
MarliesWeggemans | 5:9ebcbd39ec3f | 23 | |
boydmartherus | 6:c2608dedfd70 | 24 | } |