Unipolar stepper motor operation library
Dependents: LAB04_Oppgave1 test_stepper Stepper_Motor_Demo StepperMotorUni_Hello ... more
Unipolar stepper motor library
This library generates pulses on 4 digital output pins of the mbed. The pulses are generated by mbed's ticker function.
The mbed pins cannot drive the stepper motor directly. So it requires driver stage for the motor. The circuit may be like following diagram.
The driver stage should be chosen by requirement for the stepper motor.

The mbed generates pulses on 4 output pins for external driver stage.
This library can generate 3 types of pulses.
1 phase drive (wave drive)

2 phase drive

1-2 phase (half step) drive

Components pages
Components pages are available for bipolar and unipolar motor libraries
Revision 5:93f9ce526f38, committed 2015-04-27
- Comitter:
- okano
- Date:
- Mon Apr 27 01:16:51 2015 +0000
- Parent:
- 4:6909efe4c8ac
- Child:
- 6:007d0570ba4f
- Commit message:
- fixed: init_done behavior
Changed in this revision
| StepperMotorUni.cpp | Show annotated file Show diff for this revision Revisions of this file |
| StepperMotorUni.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/StepperMotorUni.cpp Wed Apr 22 03:24:21 2015 +0000
+++ b/StepperMotorUni.cpp Mon Apr 27 01:16:51 2015 +0000
@@ -2,8 +2,8 @@
*
* @class StepperMotorUni
* @author Tedd OKANO
- * @version 1.1.1
- * @date 22-Apr-2015
+ * @version 1.1.2
+ * @date 27-Apr-2015
*
* Copyright: 2010, 2014, 2015 Tedd OKANO
* Released under the Apache 2 license License
@@ -38,6 +38,7 @@
* version 1.0.1 (14-Apr-2015) // API document correction
* version 1.1 (21-Apr-2015) // ramp control function enabled
* version 1.1.1 (22-Apr-2015) // fixed: find_home_position compatibility with ramp control feature
+ * version 1.1.2 (27-Apr-2015) // fixed: init_done behavior
*/
#include "mbed.h"
@@ -50,6 +51,7 @@
PinName out_D,
PinName position_detect
) :
+ init_done( false ),
motor_out( out_A, out_B, out_C, out_D ),
position_detect_pin( position_detect ),
rot_mode( SHORTEST ),
@@ -59,7 +61,6 @@
pos_offset( 0 ),
target_pos( 0 ),
max_pps( MAX_PPS ),
- init_done( false ),
pause( false ),
power_ctrl( false ),
ramp_init_speed_rate( 1.0 ),
@@ -118,6 +119,8 @@
else
direction = 1;
+ init_done = false;
+
if ( prev_rot == NO_WRAPAROUND ) {
for ( int i = 0; i < (max_pos >> 1); i++ ) {
--- a/StepperMotorUni.h Wed Apr 22 03:24:21 2015 +0000
+++ b/StepperMotorUni.h Mon Apr 27 01:16:51 2015 +0000
@@ -2,8 +2,8 @@
*
* @class StepperMotorUni
* @author Tedd OKANO
- * @version 1.1.1
- * @date 22-Apr-2015
+ * @version 1.1.2
+ * @date 27-Apr-2015
*
* Copyright: 2010, 2014, 2015 Tedd OKANO
* Released under the Apache 2 license License
@@ -38,6 +38,7 @@
* version 1.0.1 (14-Apr-2015) // API document correction
* version 1.1 (21-Apr-2015) // ramp control function enabled
* version 1.1.1 (22-Apr-2015) // fixed: find_home_position compatibility with ramp control feature
+ * version 1.1.2 (27-Apr-2015) // fixed: init_done behavior
*/
#ifndef MBED_STEPPERMOTOR_UNIPOLAR
@@ -240,13 +241,15 @@
*
* This function enables the ramp-up and ramp-down of the motor behavior
*
- * @param initial_speed_rate speed rate. if the pps was set to 50pps and
- * initial_speed_rate is given like 0.1, the ramp-up-start and ramp-dowm-end
+ * @param initial_speed_rate speed rate. if the pps was set to 50pps and
+ * initial_speed_rate is given like 0.1, the ramp-up-start and ramp-dowm-end
* speed will be 5pps (= 0.1 * 50pps)
- * @param ramp_steps the steps for ramp-up and ramp-down.
+ * @param ramp_steps the steps for ramp-up and ramp-down.
*/
void set_ramp_control( float initial_speed_rate, int ramp_steps );
-
+
+ int init_done;
+
private:
Ticker t;
@@ -267,7 +270,6 @@
int target_pos;
float pps;
float max_pps;
- int init_done;
int pause;
int power_ctrl;
float ramp_init_speed_rate;