With calibration routine and driving method

Fork of Stepper_Motor_X27168 by Hanbin Ying

Embed: (wiki syntax)

« Back to documentation index

StepperMotor_X27168 Class Reference

StepperMotor_X27168 Class Reference

Stepper Motor control class. More...

#include <StepperMotor_X27168.h>

Public Types

enum  Polarity
 

Constants for motor rotate control.

More...

Public Member Functions

 StepperMotor_X27168 (PinName A_f, PinName A_r, PinName B_f, PinName B_r)
 Create a stepper motor object connected to specified DigitalOut pins.
 StepperMotor_X27168 (PinName A_f, PinName A_r, PinName B_f, PinName B_r, int init_step_position)
 Create a stepper motor object connected to specified DigitalOut pins starting at specified position.
void set_speed (float s)
 Set the motor speed (i.e.
int get_speed ()
 Get the motor speed (i.e.
void set_max_position (int p)
 Set the maximum steps the motor should take (not degrees)
int get_max_position ()
 Get the motor maximum position (int steps not degress)
int step (int dir)
 Turn the motor one step (1/2 Degree)
void step_position (int pos)
 Turn the motor to a specific step.
void angle_position (float angle)
 Turn the motor to a specific degree angle with a resolution of 0.5 degrees.
void init ()
 Initialize the motor by rotating CW for full range and CCW for full range.

Detailed Description

Stepper Motor control class.

Stepper Motor control library.

Example:

  #include "mbed.h"
  #include "StepperMotor_X27168.h"

  StepperMotor_X27168 smotor(p25, p26, p23, p22);
  
  int main() {
  
      smotor.step_position(180);
      wait(0.5);
      
      smotor.step_position(100);
      wait(0.5);
      
      smotor.angle_position(270);
      wait(0.5);
      
      smotor.step_position(0);
      wait(0.5);
  }
Author:
Aditya Garg, Nisarg Himani
Version:
1.0 (Oct-19-2015)

This is the driver for Automotive Gauge Stepper Motor X27168

----------------------IMPORTANT-------------------- The API assumes motor is postioned at zero as there is no way to detect or control that in software ---------------------------------------------------

Definition at line 49 of file StepperMotor_X27168.h.


Member Enumeration Documentation

enum Polarity

Constants for motor rotate control.

Definition at line 54 of file StepperMotor_X27168.h.


Constructor & Destructor Documentation

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

Create a 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 3 of file Stepper_Motor_X27168.cpp.

StepperMotor_X27168 ( PinName  A_f,
PinName  A_r,
PinName  B_f,
PinName  B_r,
int  init_step_position 
)

Create a stepper motor object connected to specified DigitalOut pins starting at specified position.

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)
init_step_positionRotate of given initial step position

Definition at line 13 of file Stepper_Motor_X27168.cpp.


Member Function Documentation

void angle_position ( float  angle )

Turn the motor to a specific degree angle with a resolution of 0.5 degrees.

Parameters:
angledesired angle (0-(max_positon/2))

Definition at line 96 of file Stepper_Motor_X27168.cpp.

int get_max_position (  )

Get the motor maximum position (int steps not degress)

Returns:
maximum position

Definition at line 34 of file Stepper_Motor_X27168.cpp.

int get_speed (  )

Get the motor speed (i.e.

number of steps per second)

Returns:
steps per second

Definition at line 24 of file Stepper_Motor_X27168.cpp.

void init (  )

Initialize the motor by rotating CW for full range and CCW for full range.

Definition at line 100 of file Stepper_Motor_X27168.cpp.

void set_max_position ( int  p )

Set the maximum steps the motor should take (not degrees)

Parameters:
pmaximum_steps :(ignored if parameter is greater than 629, the physical limit of the motor)

Definition at line 28 of file Stepper_Motor_X27168.cpp.

void set_speed ( float  s )

Set the motor speed (i.e.

number of steps per second) Motor will malfuntion is speed is faster than the the maximum capability if the motor.

Parameters:
ssteps per second : lower number makes the turn slower (default = 1000)

Definition at line 20 of file Stepper_Motor_X27168.cpp.

int step ( int  dir )

Turn the motor one step (1/2 Degree)

Parameters:
dir0 CLOCKWISE/FORWARD 1 ANTI-CLOCKWISE/REVERSE 2 STOP
Returns:
current_position of the motor

Definition at line 38 of file Stepper_Motor_X27168.cpp.

void step_position ( int  pos )

Turn the motor to a specific step.

Parameters:
posdesired position in steps (0-max_position)

Definition at line 80 of file Stepper_Motor_X27168.cpp.