Alles in 1
Dependencies: Encoder HIDScope MODSERIAL QEI mbed
Fork of RoboBird3 by
Diff: main.cpp
- Revision:
- 7:2042e359bfc3
- Parent:
- 6:cf20f04dbab4
- Child:
- 8:a2b725b502d8
diff -r cf20f04dbab4 -r 2042e359bfc3 main.cpp --- a/main.cpp Mon Sep 28 18:47:56 2015 +0000 +++ b/main.cpp Mon Sep 28 18:48:19 2015 +0000 @@ -1,6 +1,5 @@ #include "mbed.h" #include "QEI.h" -#include "math.h" DigitalOut Direction(D4); //1 = CCW - 0 = CW PwmOut PowerMotor(D5); //van 0 tot 1 @@ -8,24 +7,13 @@ QEI Encoder(D13,D12,NC,32,QEI::X2_ENCODING); //Encoder Serial pc(USBTX, USBRX); Ticker Pot; -Ticker PC; double z=0; -const double twopi = 6.2831853071795; -const double pi = pi/2; -int Pulses; -double Rotatie; -double Rotatietwopi; + void readpot() { - z = PotMeter.read(); -} - -void print() -{ - //pc.printf ("Potmeter = %f\n", z); // het weergeven van de waarde waar z (PotMeter) op dat moment is - //pc.printf ("Rotatie = %f [pi radialen] \n", Rotatietwopi); + z = PotMeter.read()/10; } int main() @@ -33,13 +21,9 @@ pc.baud(115200); PowerMotor.write(0); Pot.attach(readpot,0.1); // Deze ticker moet de waarde uitlezen van de PotMeter 10 keer per seconde - //PC.attach(print,0.5); while (true) { + pc.printf ("Potmeter = %f\n", z); // het weergeven van de waarde waar z (PotMeter) op dat moment is PowerMotor.write(z); - // Pulses = Encoder.getPulses(); -// Rotatie = (Pulses*twopi)/4192; -// Rotatietwopi = fmod(Rotatie,twopi); } } -