upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions
ULN200XA Class Reference

UPM module for the ULN200XA Darlington Stepper Driver. More...

Detailed Description

This module was developed on a ULN2003A Stepper Driver. It should also support the ULN2001A, ULN2002A, and ULN2004A devices, when using to drive the 28BYJ-48 unipolar stepper motor.

uln200xa.jpg

Example driving a stepper motor

// Instantiate a Stepper motor on a ULN200XA Dual H-Bridge.
// This was tested with the Grove Gear Stepper Motor with Driver
// Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and
// I4 is pin D11
upm::ULN200XA* uln200xa = new upm::ULN200XA(4096, 8, 9, 10, 11);
uln200xa->setSpeed(5);
uln200xa->setDirection(upm::ULN200XA::DIR_CW);
cout << "Rotating 1 revolution clockwise." << endl;
uln200xa->stepperSteps(4096);
cout << "Sleeping for 2 seconds..." << endl;
sleep(2);
cout << "Rotating 1/2 revolution counter clockwise." << endl;
uln200xa->setDirection(upm::ULN200XA::DIR_CCW);
uln200xa->stepperSteps(2048);
// turn off the power
uln200xa->release();

Public Types

enum  ULN200XA_DIRECTION_T { DIR_CW = 0x01, DIR_CCW = 0x02 }
 

Public Member Functions

 ULN200XA (int stepsPerRev, int i1, int i2, int i3, int i4)
 
 ~ULN200XA ()
 
uint32_t getMillis ()
 
void initClock ()
 
void setSpeed (int speed)
 
void setDirection (ULN200XA_DIRECTION_T dir)
 
void stepperSteps (unsigned int steps)
 
void release ()
 

Member Enumeration Documentation

Enum to specify the direction of a motor

Constructor & Destructor Documentation

ULN200XA ( int  stepsPerRev,
int  i1,
int  i2,
int  i3,
int  i4 
)

ULN200XA constructor

Parameters
stepsPerRevNumber of steps per full revolution
i1Digital pin to use for stepper input 1
i2Digital pin to use for stepper input 2
i3Digital pin to use for stepper input 3
i4Digital pin to use for stepper input 4
~ULN200XA ( )

ULN200XA destructor

Member Function Documentation

uint32_t getMillis ( )

Returns the number of milliseconds elapsed since initClock() was last called.

Returns
Elapsed milliseconds
void initClock ( )

Resets the clock

void setSpeed ( int  speed)

Sets the speed of the stepper motor in revolutions per minute (RPM)

Parameters
speedSpeed to set the motor to, in RPM
void setDirection ( ULN200XA_DIRECTION_T  dir)

Sets the direction of the motor, clockwise or counterclockwise

Parameters
dirDirection to set the motor to
void stepperSteps ( unsigned int  steps)

Steps the stepper motor a specified number of steps

Parameters
stepsNumber of steps to move the stepper motor
void release ( )

Releases the stepper motor by removing power


The documentation for this class was generated from the following files: