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 MODSERIAL FastPWM biquadFilter
Diff: main.cpp
- Revision:
- 12:39ba69bb5a03
- Parent:
- 5:4b25551aeb6e
--- a/main.cpp Mon Mar 18 12:54:58 2019 +0000 +++ b/main.cpp Thu Apr 04 11:11:23 2019 +0000 @@ -11,10 +11,10 @@ MODSERIAL pc(USBTX, USBRX); //Motoren -DigitalOut direction1(D4); -PwmOut pwmpin1(D5); -PwmOut pwmpin2(D6); -DigitalOut direction2(D7); +DigitalOut direction1(D7); +PwmOut pwmpin1(D6); +PwmOut pwmpin2(D5); +DigitalOut direction2(D4); volatile float PWM1; volatile float PWM2; volatile float pwm2; @@ -22,7 +22,7 @@ //Encoder DigitalIn EncoderA(D13); DigitalIn EncoderB(D12); -QEI encoder2 (D13, D12, NC, 8400, QEI::X4_ENCODING); +QEI encoder2 (D13, D12, NC, 1200, QEI::X4_ENCODING); float Pulses2; float Degrees2; @@ -104,7 +104,7 @@ pc.printf("ElbowReference:%f\n", ElbowReference); pc.printf("pwm2=%f\r\n",pwm2); - Degrees2 = (Pulses2/8400)*360; + Degrees2 = (Pulses2/1200)*360; pc.printf("Degrees is:%f\n", Degrees2); direction2 = pwm2 < 0.0f; //positief = CW, negatief = CCW pwmpin2 = fabs(pwm2); @@ -127,6 +127,8 @@ Pot2 = pot.read(); pwm2 =(Pot2*2)-1; //scaling Pulses2 = encoder2.getPulses(); + pc.printf("Pulses is:%f\n", Pulses2); + wait(0.001); //pc.printf("%f\r\n",Pot2); }