Michael Marzano / Mbed 2 deprecated Linear_Stepper_Motor_Nema17

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

LinStepMtr Class Reference

LinStepMtr Class Reference

Linear Stepper Motor control class. More...

#include <lin_step_mtr.h>

Public Types

enum  Direction
 

Direction Control.

More...
enum  Step_Num
 

Steps of motor for movement * In form A B A' B'.

More...

Public Member Functions

 LinStepMtr (PinName A_f, PinName A_r, PinName B_f, PinName B_r)
 Create a linear stepper motor object connected to specified DigitalOut pins.
 LinStepMtr (PinName A_f, PinName A_r, PinName B_f, PinName B_r, int m_rpm)
 Create a linear stepper motor object connected to specified DigitalOut pins.
 ~LinStepMtr ()
 Destructor.
float get_speed ()
 Gets the current speed in RPM.
void set_speed (float rpm)
 Sets the value of speed in RPM.
double get_rev ()
 Gets the number of revolutions since motor was initialized.
void set_min_rev_cnt (double rc)
 Sets the value of min_rev_cnt.
void set_max_rev_cnt (double rc)
 Sets the value of max_rev_cnt.
double get_min_rev_cnt ()
 Gets the value of the current minumum revolution count.
double get_max_rev_cnt ()
 Gets the value of the current maximum revolution count.
void RESET_rev_cnts ()
 Rests the revolution count limits to max/min of double.
Direction get_dir ()
 Gets the current direction.
double rotate (Direction d, float rev)
 NOT SUPORTED - Set the direction.

Detailed Description

Linear Stepper Motor control class.

Linear Stepper Motor control library.

Example:

  #include "mbed.h"
  #include "lin_step_mtr.h"
  
  // motor's leads for A,A',B,B' that are hooked upto a dual H-bridge
  LinStepMtr mtr(p20, p19, p17, p18);    
  
  int main() {
      // Rotates the motor Clockwise at 400 rpm for 10 revolutions
      mtr.set_speed(400);
      mtr.rotate(LinStepMtr::CW,10);
      
      // Rotates the motor Counterclockwise at 200 rpm for 5 revolutions
      mtr.set_speed(200);
      mtr.rotate(LinStepMtr::CCW, 5);  
  }
Author:
Mike Marzano
Version:
1.0 ()

This is the driver for A Nema 17 linear stepper motor

----------------------IMPORTANT--------------------

---------------------------------------------------

Definition at line 50 of file lin_step_mtr.h.


Member Enumeration Documentation

enum Direction

Direction Control.

Definition at line 55 of file lin_step_mtr.h.

enum Step_Num

Steps of motor for movement * In form A B A' B'.

Definition at line 62 of file lin_step_mtr.h.


Constructor & Destructor Documentation

LinStepMtr ( PinName  A_f,
PinName  A_r,
PinName  B_f,
PinName  B_r 
)

Create a linear stepper motor object connected to specified DigitalOut pins.

Parameters:
A_fDigitalOut pin for Forward Control of H-Brigde Port A (AIN1)
A_rDigitalOut pin for Reverse Control of H-Brigde Port A (AIN2)
B_fDigitalOut pin for Forward Control of H-Brigde Port B (BIN1)
B_rDigitalOut pin for Reverse Control of H-Brigde Port B (BIN2)

Definition at line 19 of file lin_step_mtr.cpp.

LinStepMtr ( PinName  A_f,
PinName  A_r,
PinName  B_f,
PinName  B_r,
int  m_rpm = MAX_RPM 
)

Create a linear stepper motor object connected to specified DigitalOut pins.

Parameters:
A_fDigitalOut pin for Forward Control of H-Brigde Port A (AIN1)
A_rDigitalOut pin for Reverse Control of H-Brigde Port A (AIN2)
B_fDigitalOut pin for Forward Control of H-Brigde Port B (BIN1)
B_rDigitalOut pin for Reverse Control of H-Brigde Port B (BIN2)
m_rpmSets the max speed in RPM of the motor

Definition at line 6 of file lin_step_mtr.cpp.

~LinStepMtr (  )

Destructor.

Definition at line 29 of file lin_step_mtr.cpp.


Member Function Documentation

LinStepMtr::Direction get_dir (  )

Gets the current direction.

Returns:
the current direction of motion

Definition at line 80 of file lin_step_mtr.cpp.

double get_max_rev_cnt (  )

Gets the value of the current maximum revolution count.

Returns:
the current maximum revevolution count limit

Definition at line 69 of file lin_step_mtr.cpp.

double get_min_rev_cnt (  )

Gets the value of the current minumum revolution count.

Returns:
the current minimum revevolution count limit

Definition at line 64 of file lin_step_mtr.cpp.

double get_rev (  )

Gets the number of revolutions since motor was initialized.

Positive means more CW than CCW movement, negative is opposite

Returns:
revolution count

Definition at line 43 of file lin_step_mtr.cpp.

float get_speed (  )

Gets the current speed in RPM.

Returns:
motor's speed in RPM

Definition at line 34 of file lin_step_mtr.cpp.

void RESET_rev_cnts (  )

Rests the revolution count limits to max/min of double.

Definition at line 74 of file lin_step_mtr.cpp.

double rotate ( Direction  d,
float  rev = 1 
)

NOT SUPORTED - Set the direction.

Parameters:
dnew direction of motion Rotates the motor for a set number of rotations in the given direction
ddirection of rotation
revnumber of revolutions to rotate (defaults to 1 revolution)
Returns:
the current revolution count after rotation is complete

Definition at line 95 of file lin_step_mtr.cpp.

void set_max_rev_cnt ( double  rc )

Sets the value of max_rev_cnt.

This value is used as a software stop to prevent the motor from rotating any farther while going clockwise Defaults to the maximum value of a double.

Parameters:
rcnew maximum revolution count limit value

Definition at line 56 of file lin_step_mtr.cpp.

void set_min_rev_cnt ( double  rc )

Sets the value of min_rev_cnt.

This value is used as a software stop to prevent the motor from rotating any farther while going counterclockwise. Defaults to the minimum value of a double.

Parameters:
rcnew minimum revolution count limit value

Definition at line 48 of file lin_step_mtr.cpp.

void set_speed ( float  rpm )

Sets the value of speed in RPM.

Parameters:
rpmspeed in rpm (maximum value of 400 rpm, min value of 200 rpm)

Definition at line 39 of file lin_step_mtr.cpp.