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.
Fork of GainController by
Diff: GainControl.cpp
- Revision:
- 0:8d7b6e55609a
- Child:
- 1:d4c2e72540db
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GainControl.cpp Tue Mar 24 13:13:00 2015 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "QEI.h"
+
+PwmOut turret_speed(p21);
+DigitalOut turret_direction(p22);
+
+QEI myEncoder (p16,p15, NC, 1600);
+Timer t;
+
+int main()
+{
+int input_dc =50;
+int user_direction = 0;
+float duty_cycle = 0.6;
+int pulses = 0;
+float theta = 0.0;
+float time =0.0;
+
+while(1)
+ {
+ printf("Enter duty cycle, 0 to 100:\n");
+ scanf("%d", &input_dc);
+ duty_cycle = input_dc/100.0;
+
+ printf("%f duty cycle set. Enter 0 for CCW or 1 for CW spin direction:\n",duty_cycle);
+ scanf("%d", &user_direction);
+
+ printf("it's starting... move the thing!\n");
+ t.start();
+ turret_speed = duty_cycle;
+ turret_direction = user_direction;
+
+ pulses = myEncoder.getPulses();
+ theta = ((float)pulses/ (1600.0*2.0))*-2.0*3.14;
+ time = t.read();
+
+ printf("time = %.5f;\n",time);
+ printf("theta = %.5f;\n",theta);
+ printf("%f duty cycle. %d spin.\n", duty_cycle, user_direction);
+
+ }
+}
\ No newline at end of file
