Hello program for StepperMotorUni library

Dependencies:   StepperMotorUni mbed

Dependents:   StepperMotorUni_Hello

Sample code for stepper motor operation with StepperMotorUni library

4 output pin generates signal for stepper motor driver.

/media/uploads/okano/unipolar-steppermotor-sample.png

This library can operate in parallel for multiple stepper motors.


The mbed generates pulses on 4 output pins for external driver stage.
The StepperMotorUni library can generate 3 types of pulses.

1 phase drive (wave drive)

#include "mbed.h"
#include "StepperMotorUni.h"
 
StepperMotorUni motor( p26, p25, p24, p23 );
 
int main()
{
    motor.set_operation_phase_mode( StepperMotorUni::ONE_PHASE );
    ...
    ...

/media/uploads/okano/1phase_drive.gif

2 phase drive

#include "mbed.h"
#include "StepperMotorUni.h"
 
StepperMotorUni motor( p26, p25, p24, p23 );
 
int main()
{
    motor.set_operation_phase_mode( StepperMotorUni::TWO_PHASE );
    ...
    ...

/media/uploads/okano/2phase_drive.gif

1-2 phase (half step) drive

#include "mbed.h"
#include "StepperMotorUni.h"
 
StepperMotorUni motor( p26, p25, p24, p23 );
 
int main()
{
    motor.set_operation_phase_mode( StepperMotorUni::HALFSTEP );
    ...
    ...

/media/uploads/okano/halfstep_drive.gif

Components pages

Components pages are available for bipolar and unipolar motor libraries

A bipolar stepper motor driving pulse generator

A unipolar stepper motor driving pulse generator

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Wed Apr 22 03:26:01 2015 +0000
Parent:
0:ae2206213141
Child:
2:32e0b120ddb7
Commit message:
to include latest library

Changed in this revision

StepperMotorUni.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/StepperMotorUni.lib	Sun Jan 19 11:01:48 2014 +0000
+++ b/StepperMotorUni.lib	Wed Apr 22 03:26:01 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/okano/code/StepperMotorUni/#5d0abdf92786
+http://mbed.org/users/okano/code/StepperMotorUni/#6909efe4c8ac
--- a/main.cpp	Sun Jan 19 11:01:48 2014 +0000
+++ b/main.cpp	Wed Apr 22 03:26:01 2015 +0000
@@ -14,13 +14,14 @@
 
 int main()
 {
-    motor.set_pps( 50 );
+    motor.set_operation_phase_mode( StepperMotorUni::HALFSTEP );
+    motor.set_pps( 200 );
 
     while ( 1 ) {
-        motor.move_steps( 24 );
+        motor.move_steps( 48 );
         wait( 1 );
 
-        motor.move_steps( -24 );
+        motor.move_steps( -48 );
         wait( 1 );
     }
 }