oBitShifter Object

Back to top of page Description:
 The oBitShifter Object output four signals where the "on" signals shift in a round robin fashion.  The shifting can be configured to shift continuously or a specific number of shifts can be specified.
 The following table lists the size and availability of the oBitShifter Object.
 ObjectSizeDescriptionA1A2B1B2C1
oBitShifter8 BytesAn Object that outputs a bit pattern that shifts.xxx
Back to top of page Operation:
 

 

The following table shows different configurations for the oBitShifter 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
Back to top of page Properties:

The following table lists the properties of the oBitShifter Object:

Property

Description

Distance
If Mode = 0, A value that specifies how many times to shift the bits.
If Mode = 1, A value that indicates how many times the bits have been shifted.
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 used to output the bits.
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 shifts will be made.
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))
Clear
A value that selects if the outputs are turned off.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0

Free

outputs

0Are active
1Are all off 
InvertOut
A value that selects if the outputs are inverted.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0

InvertOut

Then the stepper motor outputs

0Active bit lines are at 5 volts.
1Active bit lines are at 0 volts.
Phasing
A value that selects the bit pattern to output.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
The phase pattern for the active bits is set by the Phasing property.  Each time the Distance property changes the next Phase Pattern dictates the active outputs.
PhasingPhase PatternDescription
01 of the 4 bits is active while the other 3 are inactive.  
12 of the 4 bits are active while the other 2 are inactive.  
2Alternates between 1 and 2 active bits. 
First: 2 of the 4 bits are active while the other 2 are inactive
Second: 1 of the 4 bits is active while the other 3 are inactive. 
3A similar pattern to Phasing 2 is used but with only 3 bits being used.
Mode
A value that selects if the bit pattern is to shift continuously.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0

A value that specifies if the bits shift the number of times specified by the Distance property or will shift continuously. 

When the Mode property is set to 0 the bits will shift the number of times specified by the Distance property and then stop.  Each phase outputted 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
Direction
A value that specifies the direction that the shifts will be made in.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
If the Mode property is 0, then the Direction property is set based on the Distance property.  If the Distance property is a positive number, then Direction is set to 0. If the Distance property is a negative number, then the Distance property is set to 1.

Direction

Turn

0Left Shift (Toward MSB)
1Right Shift (Towards LSB)
Operate
A value that specifies whether or not the bits are outputted.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOff

The bits are not outputted.

1cvOn

The bits are outputted.

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 oBitShifter 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 oBitShifter  

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 oBitShifter  

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 page Related Items:

 The following table lists objects that use the oBitShifter Object.
 ObjectDescriptionA1A2B1B2C1
oChaser4Controls a series of chasing lights.xx
oStepperControls a stepper motor.xxx
oStepperSPControls a stepper motors speedxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oDCMotorControls a DC motor that is driven by an LMD18200 H-Bridge driver.xxx
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.