Hardware Reference
In-Depth Information
Example 4-5. Changes to bipolar code to drive a unipolar stepper motor
(unipolarStepperMotor.diff)
var controller = [ "P9_11" , "P9_13" , "P9_15" , "P9_17" ];
var states = [[ 1 , 1 , 0 , 0 ], [ 0 , 1 , 1 , 0 ], [ 0 , 0 , 1 , 1 ], [ 1 , 0 , 0 , 1 ]];
var curState = 0 ;
// Current state
var ms = 100 ,
// Time between steps, in ms
max = 22 ,
// Number of steps to turn before turning around
The code in this example makes the following changes:
controller is attached to the even -numbered pins on the P9 header rather
than the odd that the bipolar stepper used. (Doing this allows you to run both
types of stepper motors at the same time!)
▪ The states are different. Here, we have two pins high at a time.
▪ The time between steps ( ms ) is shorter, and the number of steps per direction
( max ) is bigger. The unipolar stepper I'm using has many more steps per rotation,
so I need more steps to make it go around.
Search WWH ::




Custom Search