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
- Committer:
- joostbonekamp
- Date:
- 2019-10-02
- Revision:
- 3:e3d12393adb1
- Parent:
- 2:bbaa6fca2ab1
- Child:
- 4:36e32ddf2443
File content as of revision 3:e3d12393adb1:
#include "mbed.h"
#include "MODSERIAL.h"
#include "FastPWM.h"
#include "QEI.h"
MODSERIAL pc(USBTX, USBRX);
DigitalOut motor2_direction(D4);
PwmOut motor2_pwm(D5);
QEI encoder (D11, D12, NC, 8400, QEI::X4_ENCODING);
int enc_count;
int prev_count = 0;
int main() {
pc.baud(115200);
pc.printf("initializing\r\n");
while (true) {
enc_count = encoder.getPulses();
pc.printf("%f\r\n", float(enc_count-prev_count)*360/(8400*0.025));
prev_count = enc_count;
wait_ms(25);
}
}