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: inc/example2.h
- Revision:
- 3:b7d951c6f551
- Child:
- 4:d69f22061c03
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/example2.h Tue Jul 05 14:27:56 2011 +0000
@@ -0,0 +1,73 @@
+
+#include "mbed.h"
+#include "SimpleTLE5206Profiler.h"
+
+Serial pc(USBTX, USBRX);
+
+/* See example1.h for basic notes.
+ *
+ * This example shows how to use the acceleration and deceleration
+ * profiler to manage changing speed in a simple linear fashion.
+ *
+ * The default accel and decel rates are 0.01/10ms. So when a speed
+ * of say +1.0 is demanded, it actually takes 1seond to reach that
+ * target desired speed due to the acceleration profiler. Likewise
+ * for deceleration.
+ *
+ * You can adjust the rates by altering the "poll interval" and the
+ * step change size.
+ */
+
+#define DUTY_CYCLE_IN_HERTZ 50
+
+// Create a motor "A", driven by a TLE5206 on pins 21 and 22 (attach scope first, not a motor!)
+SimpleTLE5206Output Ain1(p21); // TLE5206 In1 is connected to p21
+SimpleTLE5206Output Ain2(p22); // TLE5206 In2 is connected to p22
+SimpleTLE5206Profiler motorA(&Ain1, &Ain2, DUTY_CYCLE_IN_HERTZ); // Create the TLE5206 controller.
+
+int main() {
+
+ pc.baud(115200);
+
+ while(1) {
+ // Start from stationary.
+ motorA.setSpeed(0);
+ wait(1);
+
+ // Command full desired speed CW
+ motorA.setSpeed(1.0);
+
+ // Wait for it to reach that speed.
+ while( motorA.getSpeed() != 1.0) ;
+
+ // Wait for 3seconds
+ wait(3);
+
+ // Stop the motor
+ motorA.setSpeed(0.0);
+ while( motorA.getSpeed() != 0.0) ;
+
+ // Wait for 3seconds
+ wait(3);
+
+ // Command full desired speed CCW
+ motorA.setSpeed(-1.0);
+
+ // Wait for it to reach that speed.
+ while( motorA.getSpeed() != -1.0) ;
+
+ // Wait for 3seconds
+ wait(3);
+
+ // Stop the motor
+ motorA.setSpeed(0.0);
+ while( motorA.getSpeed() != 0.0) ;
+
+ // Wait for 3seconds
+ wait(3);
+
+ // repeat the cycle.
+ }
+}
+
+