oStepper Object

Back to top of page Description:
 An oStepper Object is a Hardware Object that controls the direction, speed, braking and distance traveled of a stepper motor.  It is capable of driving a stepper Motor at multiple speeds, in forward or reverse plus free spinning, and with active brakes.

The primary function of the oStepper Object is to allow a program to instruct a stepper motor to turn a specified distance in a specified direction at a specified rate.  Several different variations to the primary function can also be accomplished, including having the stepper motor turn indefinitely.

The oStepper Object uses four digital I/O lines to communicate with drivers which handles the voltage and current requirements of the stepper motor it is connected to.

How far the motor turns is controlled by the Distance property which that specifies how many steps to take at the speed specified.  A mode can also be selected where the motor turns continuously.  When the Distance property is 0, the motor is locked (with brakes on) at one position

How fast the motor turns is controlled by a single value with a range of  0 to 127.  The motor turns at the speed indicated by the value.  The higher the value, the faster the motor turns. 

Which direction the motor turns is controlled by the polarity of the Distance property.

A free-spinning mode (brakes off) can also be selected.

 The following table lists the size and availability of the oStepper Object.
 ObjectSizeDescriptionA1A2B1B2C1
oStepper8 BytesControls a stepper motor.xxx
Back to top of page Operation:
 The following table shows different configurations for the oStepper Object:
When these conditions are met:Mode property =0011
Direction property =XX01
Distance property =+-XX
This will occur:Stepper motor turns:FBFB
Direction property gets set to:0101
Distance property change:--++++--
Stops turning when:ZZPP
A value of 0
1A value of 1
XAny value
+A positive value
-A negative value
FTurns forward
BTurns backwards
--Value is decreased
++Value is increased
Value reaches 0
POperate is set to 0
The BitShifter property is an instance of the oBitShifter object which is created when the oStepper object is.  Attributes of the motor's operation can be adjusted by directly manipulating the BitShifter object. Note that doing so may change the way the chasing behaves to something different than the way described in this document.  (see oBitShifter object for more detail)
Back to top of page Properties:

The following table lists the properties of the oStepper Object:

Property

Description

Distance
If Mode = 0, A value that specifies how far to move the stepper motor.
If Mode = 1, A value that indicates how far the stepper motor has moved.
Object Class: oInt Value Range: -32768 to 32767
Data Type: Numeric Default Value: 0
IOPack
A value that specifies which pack of 4 I/O lines is connected to the Driver.
Object Class: oIOPack Value Range: 0 - 7
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOPack help file for details.
Rate
A value that specifies how fast the stepper motor will turn.
Object Class: oVar7 Value Range: 0 - 127
Data Type: Numeric Default Value: 0
The Rate property is a clock divider that divides a base frequency of  1132.246Hz.
The Phase frequency calculation is: (1132.246 / (128 - Rate))
Direction
A value that indicates the direction that the stepper motor has turned. 
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Free
A value that selects if the outputs are turned off.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Setting the Free property to "0" leaves the outputs on while a setting of "1" turns the outputs off. When the outputs are off the stepper motor can be turned freely by hand. 

Free

Stepper motor outputs

0Are engaged
1Are off 
(motor turns freely)
InvertOut
A value that selects if the outputs are inverted.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
When InvertOut is 0 the active coils of the stepper motor are activated by a High logical output (5 Volts).  
When InvertOut is 1 they are activated by a Low-Logic output (0 Volts).  

InvertOut

Then the stepper motor outputs

0Active coils lines are at 5 volts.
1Active coils lines are at 0 volts.
Mode
A value that selects if the stepper motor will travel the distance specified by the Distance property or will turn continuously. 
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
When the Mode property is set to 0 the motor will travel the distance specified by the Distance property and then stop.  Each phase movement of the stepper motor will decrement the Distance property towards 0. If the Distance property is a negative number, it will increment the Distance property towards 0.
When the Mode property is set to 1 the stepper motor will turn continuously and count the distance traveled.  Each phase movement of the stepper motor will increment (or decrement depending on the setting of the Direction property) the Distance property.
ModeAction
0turn distance specified
1turn continuously
Phasing
A value that selects the output's phase pattern.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
The phase pattern for the active coils on the stepper motor is set by the Phasing property.  Each time the Steps property changes the next coil(s) in the Phase Pattern become active.
PhasingPhase PatternDescription
01 of the 4 coils is active while the other 3 are inactive.
12 of the 4 coils are active while the other 2 are inactive.
2Alternates between 1 and 2 active coils.  First: 2 of the 4 coils are active while the other 2 are inactive   Second: 1 of the 4 coils is active while the other 3 are inactive.  Note: This Phase Pattern moves the stepper motor 1/2 the distance that Phase patterns 1 and 2 do.
3A similar pattern to Phasing 2 is used but with only 3 lines being used for 3-Phase motors. 
Operate
A value that selects whether or not the stepper motor will be moved.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Note that this is different than turning the coils of the stepper motor on and off which is controlled by the Free property.
OperateConstantDescription
0cvOffThe stepper motor is off.
1cvOnThe stepper motor is on.
BitShifter
The I/O function object used to control the stepper motor.
Object Class: oBitShifter Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Examples:
 In the following examples, the oStepper Object is used.
'This program turns a stepper motor
'200 step forward and then waits for
'The steps to be completed. Then it
'Moves the stepper motor 200 step
'in reverse.

Dim A As New oStepper  

Sub Main() 
  A.IOPack = 1
  A.Rate = 124
  A.Operate = 1
  Do 
    A.Value = 200
    Wait Until A.NonZero = 0
    A.Value = -200
    Wait Until A.NonZero = 0
  Loop
End Sub
'This program turns
'a stepper motor at 
'the specified rate 
'for 1 second.

Dim A As New oStepper  

Sub Main() 
  A.IOPack = 1
  A.Rate = 124
  A.Mode = 1
  A.Operate = 1
  ooPIC.Delay = 100
  A.Operate = 0
End Sub
Back to top of pageConnections:
 The L293D is a push-pull driver.  The IOPack property specifies which set of 4 I/O Lines to connect to the L293D.

Caution: Do NOT connect the outputs of the ooPIC directly to the Motor. The TTL circuitry of the ooPIC is not designed to drive the power requirements of a Motor.  Doing so can potentially damage the ooPIC's TTL outputs.
L293D Driver and a Stepper Motor.
IOPack:1234567Coil
I/O 0:816245122028a
I/O 1:917256132129b
I/O 2:1018267142230c
I/O 3:111927-152331d

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oDCMotorControls a DC motor that is driven by an LMD18200 H-Bridge driver.xxx
oStepperSPControls a stepper motors speedxx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.