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.
Diff: main.cpp
- Revision:
- 0:70a6fd5751a6
- Child:
- 1:c855dee2c6d4
diff -r 000000000000 -r 70a6fd5751a6 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Sep 28 09:55:41 2015 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "QEI.h"
+
+Serial pc(USBTX, USBRX);
+QEI wheel (PTC10, PTC11, NC, 624); // Pin for counting (analog in)
+
+// Define pin for motor control
+DigitalOut directionPin(D4);
+PwmOut PWM(D5);
+
+
+
+// 8400 counts per revolution
+// so 8400 / (2 *pi) is counts/pi
+
+
+Ticker tellen;
+bool stoppen = false;
+
+void GOTO()
+{
+double resolution = 8400 / (2 * 3.14592);
+double Rotation = 4; // rotation in pi
+double movement = Rotation * resolution;
+
+ // pc.printf("The number of real rotation is %i \n",Rotation);
+
+
+ if (wheel.getPulses() <= movement) {
+ directionPin.write(1);
+ PWM.write(0.3);
+ pc.printf("Pulses is: %i\n", wheel.getPulses());
+ } else {
+ PWM.write(0);
+ //pc.printf("The motor turned %i rotations \n",Rotation);
+ pc.printf("Pulses is: %i\n The motor turned %.2f rotations\n", wheel.getPulses(),Rotation);
+ stoppen = true;
+
+
+ }
+
+
+
+
+}
+
+
+
+int main()
+{
+ int proberen = 1000;
+ pc.printf("The number of rotation is %i \n",proberen);
+
+
+
+
+
+ tellen.attach(&GOTO, 0.1);
+
+
+
+
+
+
+
+
+
+}