I just started on a project and I need a little help. I am pretty new to the picaxe micro controllers and the programming of them.
Basically what I’m doing is using a bipolar stepper motor to turn the handle on a micrometer to certain positions.
I am using a 20m and a MC3479 to drive the stepper motor.
The first question I have is what commands are best for controlling the stepper motor? Below is what I’ve started with. It is something I just saw somewhere else and copied it.
I will have probably 6 push buttons and 6 led’s to come on when you push the buttons for forward fast, forward slow, reverse fast, reverse slow, start and beginning (which will probably be a later question).
Right now the pauses are in there just for testing. Ultimately what I want this thing to do is position the mic with the 4 position switches, hit the start button and the mic will move to a pre determined position, then wait for a signal and move to the next position etc.
Below is just the beginning of the code. I want to know if I’m going in the right direction.
Basically what I’m doing is using a bipolar stepper motor to turn the handle on a micrometer to certain positions.
I am using a 20m and a MC3479 to drive the stepper motor.
The first question I have is what commands are best for controlling the stepper motor? Below is what I’ve started with. It is something I just saw somewhere else and copied it.
I will have probably 6 push buttons and 6 led’s to come on when you push the buttons for forward fast, forward slow, reverse fast, reverse slow, start and beginning (which will probably be a later question).
Right now the pauses are in there just for testing. Ultimately what I want this thing to do is position the mic with the 4 position switches, hit the start button and the mic will move to a pre determined position, then wait for a signal and move to the next position etc.
Below is just the beginning of the code. I want to know if I’m going in the right direction.
Code:
'symbol revsl = pin0 'reverse motor slow
'symbol revfa = pin1 'reverse motor fast
'symbol forsl = pin2 'forward motor slow
'symbol forfa = pin3 'forward motor fast
'symbol start1 = pin4 'start sequence
'symbol begin = pin5 'move motor to start
'surface = 2 'take surface reading at .002
'minimum = 30 'take reading at minimum spec
'average = 33 'take reading .002 before average
'then take 5 more readings .001 appart
'maximum = 50 'take reading at maximum
'beginning = b4 'add upp all moves and move back that far to zero
start:
pause 3000
b2 = 5000 'stepmotor pause
b3 = 5000 'pause between steps
for b1=1 to 50
for b0=1 to 2
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 28
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 3
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 1
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 1
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 1
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 1
pulsout 1,100:pause 2
next b0
next b1
pause 10000
for b1=1 to 50
for b0=1 to 1
pulsout 1,100:pause 2
next b0
next b1
'goto start
'if pin0 = 1 then start
Last edited by a moderator: