Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp
- Committer:
- joostbonekamp
- Date:
- 2019-10-02
- Revision:
- 4:36e32ddf2443
- Parent:
- 3:e3d12393adb1
- Child:
- 5:aa8b5d5e632f
File content as of revision 4:36e32ddf2443:
#include "mbed.h" #include "MODSERIAL.h" #include "FastPWM.h" #include "QEI.h" MODSERIAL pc(USBTX, USBRX); //verbinden met pc DigitalOut motor2_direction(D4); //verbinden met motor 2 op board (altijd d4) QEI encoder (D11, D12, NC, 8400, QEI::X4_ENCODING); //encoder gebruiken int enc_count; int prev_count = 0; int main() { pc.baud(115200); pc.printf("initializing\r\n"); while (true) { enc_count = encoder.getPulses(); //kijkt op welke stand hij nu staat 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 prev_count = enc_count; wait_ms(25); } }