oStepper Object
An Object that controls a stepper motor.
Description:
 

The oStepper Object is used to control the speed, direction and distance that a stepper motor will turn.  

Operation:
 

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 following table shows different configurations for the oStepper Object:

When these conditions are met:Mode property =00001111
Unsigned property =00110011
Direction property =XX010101
Value property =+-XXXXXX
This will occur:Stepper motor turns:FBFBFBFB
Direction property gets set to:01010101
Value property change:--++----++--++++
Stops turning when:ZZZZPPPP
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
Storage size & Availability:
 

The following table lists the size and availability of the oStepper Object:

ObjectSizeVersion
oStepper8 BytesB.1.0
Properties:
 

The following table lists the Properties of the oStepper Object:

PropertyDescription
Address

Returns a pointer to the address of the oStepper Object instance.

Data-Type: Address, ReadOnly

Data-Range: 0 - 127

Direction

A value that specifies the direction that the stepper will turn or indicates the direction that the stepper motor has turned. 

Setting the Direction property to "0" turns the stepper motor forward and a setting of "1" turns the stepper motor in reverse.  
If the Signed property is 1 and the Mode property is 0, then the Direction property is set based on the Value property.  If the Value property is a positive number, then Direction is set to 0. If the Value property is a negative number, then the value property is set to 1.

Note that "forward" and "reverse" are dependant on both the interface connection and the mounting of the stepper motor.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Direction

Turn

0Forward
1Reverse
Free

A value that specifies if the outputs are turned off. 

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. 

Data-Type: Bit, Flag

Data-Range: 0 - 1

Free

Stepper motor outputs

0Are engaged
1Are off 
(motor turns freely)
InvertOut

A value that specifies if the outputs are inverted. 

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).  

Data-Type: Bit

Data-Range: 0 - 1

InvertOut

Then the stepper motor outputs

0Active coils lines are at 5 volts.
1Active coils lines are at 0 volts.
IOGroup

A value that specifies which physical I/O Group to use.

Data-Type: Nibble

Data-Range: 0 - 3

Mode

A value that specifies if the stepper motor will travel the distance specified by the Value property or will turn continuously. 

When the Mode property is set to 0 the motor will travel the distance specified by the Value property and then stop.  Each phase movement of the stepper motor will decrement the Value property towards 0. If the Value property is a negative number, it will increment the Value 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 Value property.

Data-Type: Bit

Data-Range: 0 - 1

ModeAction
0turn distance specified
1turn continuously
Nibble

A value that specifies which side of the IOGroup to use.

Data-Type: Bit

Data-Range: 0 - 1

NonZero

Specifies if the Value property is 0 or not. 

When the Value property is 0 the NonZero property is set to 0. When the Value property is not zero the NonZero property is set to 1.
While in Mode 0 this property can be used to determine if the stepper motor is currently turning.

Data-Type: Bit, Flag, Read-Only

Data-Range: 0 - 1

NonZeroThis indicates
0Value=0
1Value<>0
Operate

A value that specifies whether or not the stepper motor will be moved.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Phasing

A value that specifies the output's phase pattern.

The phase pattern for the active coils on the stepper motor is set by the Phasing property.  Each time the Value property changes the next coil(s) in the Phase Pattern becomes the active one.
If Phasing is set to 0   1 of the 4 coils is active while the other 3 are inactive.  
If Phasing is set to 1   2 of the 4 coils are active while the other 2 are inactive.  
If Phasing is set to 2   Alternates 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.
If Phasing is set to 3   A similar pattern to Phasing 2 is used but with only 3 lines being used for 3-Phase motors. 

Data-Type: Nibble

Data-Range: 0 - 3

PhasingConstantPhase Pattern
0 
1 
2 
3 
Rate

A value that specifies how fast the stepper motor will turn. 

The Rate property is a clock divider that divides a base frequency of  1132.246Hz.
The Phase frequency calculation is: (1132.246 / (128 - Rate))

Data-Type: Byte

Data-Range: 0 - 127

Unsigned

A value that specifies whether or not the Value property can be a negative number. 

If Unsigned is set to 0 Value can be a negative number. 
If Unsigned is set to 1 Value is always a positive number

Data-Type: Bit

Data-Range: 0 - 1

UnsignedValue range
0 -32768 to +32767
10 to 65535
Value

A value that specifies how far to move the stepper motor or how far the stepper motor has moved.

If Mode = 0 the Value property is used to specify how far to move the stepper motor.
If Mode = 1 A value that indicates how far the stepper motor has moved.

Data-Type: Word, Default

Data-Range:  if Unsigned=0 then -32768 to 32767.  If Unsigned=1 then 0 to 65535.

Example:
 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.IOGroup = 1
  A.Nibble = 0
  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.IOGroup = 1
  A.Nibble = 0
  A.Rate = 124
  A.Mode = 1
  A.Operate = 1
  OOPic.Delay = 100
  A.Operate = 0
End Sub
See Also:
 

oStepperSP - An Object that uses URCP speed values to control a stepper motor.
oDCMotor
- An Object that controls a DC Motor.