Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@4:36e32ddf2443, 2019-10-02 (annotated)
- Committer:
- joostbonekamp
- Date:
- Wed Oct 02 12:49:05 2019 +0000
- Revision:
- 4:36e32ddf2443
- Parent:
- 3:e3d12393adb1
- Child:
- 5:aa8b5d5e632f
snelheid uitlezen met comments;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RobertoO | 0:67c50348f842 | 1 | #include "mbed.h" |
| RobertoO | 1:b862262a9d14 | 2 | #include "MODSERIAL.h" |
| joostbonekamp | 2:bbaa6fca2ab1 | 3 | #include "FastPWM.h" |
| joostbonekamp | 2:bbaa6fca2ab1 | 4 | #include "QEI.h" |
| RobertoO | 0:67c50348f842 | 5 | |
| joostbonekamp | 4:36e32ddf2443 | 6 | MODSERIAL pc(USBTX, USBRX); //verbinden met pc |
| joostbonekamp | 4:36e32ddf2443 | 7 | DigitalOut motor2_direction(D4); //verbinden met motor 2 op board (altijd d4) |
| RobertoO | 0:67c50348f842 | 8 | |
| joostbonekamp | 4:36e32ddf2443 | 9 | QEI encoder (D11, D12, NC, 8400, QEI::X4_ENCODING); //encoder gebruiken |
| joostbonekamp | 3:e3d12393adb1 | 10 | |
| joostbonekamp | 3:e3d12393adb1 | 11 | int enc_count; |
| joostbonekamp | 3:e3d12393adb1 | 12 | int prev_count = 0; |
| joostbonekamp | 3:e3d12393adb1 | 13 | |
| joostbonekamp | 2:bbaa6fca2ab1 | 14 | int main() { |
| joostbonekamp | 3:e3d12393adb1 | 15 | pc.baud(115200); |
| joostbonekamp | 3:e3d12393adb1 | 16 | pc.printf("initializing\r\n"); |
| joostbonekamp | 3:e3d12393adb1 | 17 | |
| RobertoO | 0:67c50348f842 | 18 | while (true) { |
| joostbonekamp | 4:36e32ddf2443 | 19 | enc_count = encoder.getPulses(); //kijkt op welke stand hij nu staat |
| joostbonekamp | 4:36e32ddf2443 | 20 | pc.printf("%f\r\n", float(enc_count-prev_count)*360/(8400*0.025)); //verschil met vorige stap in graden per stap gedeeld door tijd = snelheid |
| joostbonekamp | 3:e3d12393adb1 | 21 | prev_count = enc_count; |
| joostbonekamp | 3:e3d12393adb1 | 22 | wait_ms(25); |
| RobertoO | 0:67c50348f842 | 23 | } |
| RobertoO | 0:67c50348f842 | 24 | } |
| joostbonekamp | 2:bbaa6fca2ab1 | 25 |