![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Control up to two motors using filtered EMG signals and a PID controller
Dependencies: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
main.cpp@12:0462757e1ed2, 2017-09-21 (annotated)
- Committer:
- tvlogman
- Date:
- Thu Sep 21 08:35:44 2017 +0000
- Revision:
- 12:0462757e1ed2
- Parent:
- 11:d1692be2de30
- Child:
- 13:83e3672b24ee
Now counts revolutions as well.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | #include "MODSERIAL.h" |
tvlogman | 8:0067469c3389 | 3 | #include "HIDScope.h" |
tvlogman | 9:5f0e796c9489 | 4 | #include "QEI.h" |
tvlogman | 8:0067469c3389 | 5 | |
tvlogman | 12:0462757e1ed2 | 6 | QEI Encoder(D12,D13,NC,64, QEI::X4_ENCODING); |
tvlogman | 10:e23cbcdde7e3 | 7 | MODSERIAL pc(USBTX, USBRX); |
tvlogman | 8:0067469c3389 | 8 | |
tvlogman | 10:e23cbcdde7e3 | 9 | Ticker encoderTicker; |
tvlogman | 10:e23cbcdde7e3 | 10 | volatile int counts = 0; |
tvlogman | 12:0462757e1ed2 | 11 | volatile float revs = 0.00; |
tvlogman | 7:1bffab95fc5f | 12 | |
tvlogman | 10:e23cbcdde7e3 | 13 | void readEncoder(){ |
tvlogman | 10:e23cbcdde7e3 | 14 | counts = Encoder.getPulses(); |
tvlogman | 12:0462757e1ed2 | 15 | revs = counts/64.0f; |
tvlogman | 12:0462757e1ed2 | 16 | pc.printf("%i pulses \r\n", counts); |
tvlogman | 12:0462757e1ed2 | 17 | pc.printf("%f revolutions \r\n", revs); |
tvlogman | 10:e23cbcdde7e3 | 18 | } |
vsluiter | 0:c8f15874531b | 19 | |
tvlogman | 7:1bffab95fc5f | 20 | |
vsluiter | 0:c8f15874531b | 21 | int main() |
tvlogman | 10:e23cbcdde7e3 | 22 | { |
vsluiter | 0:c8f15874531b | 23 | pc.baud(115200); |
tvlogman | 12:0462757e1ed2 | 24 | encoderTicker.attach(readEncoder, 1.0); |
tvlogman | 10:e23cbcdde7e3 | 25 | pc.printf("Encoder ticker attached and baudrate set"); |
tvlogman | 11:d1692be2de30 | 26 | |
vsluiter | 0:c8f15874531b | 27 | } |
tvlogman | 7:1bffab95fc5f | 28 |