PDA

View Full Version : Stepper Motor troubles



Fryin
- 21st March 2007, 01:44
Hi this is my first time posting. I am a student learning Microcode in school and I am having trouble making this program. My problem is I need to control a stepper motor using the pic16F84A and driving the stepper with ULN2003A. Now I have to make the program so I am able to chose using 3 pushbuttons for singlestep, doublestep or microstepping. I'm trying to use a lookup table for this and I just can't figure out what to do with the variable Motor once it has the lookup's value. I can show you what I have so far, which aint much and maybe you can give me some idea's on how to progress.

Motor Var byte
x var byte

TRISA = %00011100 'Pushbuttons on port 2,3 and 4
TRISB = %00000000


SingleStep:
Stepoffset = 0
StepLimit = 3
Return

DoubleStep:
Stepoffset = 4
Steplimit = 3
Return

MicroStep:
Stepoffset = 8
Steplimit = 7
return

Start:
gosub checksequence

For x = 0 to 17
PortB=Motor

Checksequence: 'Lookup table includes single, double and microstep all
'together
LookUp x,[1,2,4,8,3,6,12,9,1,3,2,6,4,12,8,9],Motor
return

End

skimask
- 21st March 2007, 01:56
Motor Var byte
x var byte

TRISA = %00011100 'Pushbuttons on port 2,3 and 4
TRISB = %00000000

SingleStep:
Stepoffset = 0:StepLimit = 3
Return

DoubleStep:
Stepoffset = 4:Steplimit = 3
Return

MicroStep:
Stepoffset = 8:Steplimit = 7
return

Start:
gosub checksequence

For x = 0 to 17
PortB=Motor

Checksequence: 'Lookup table includes single, double and microstep all
'together
LookUp x,[1,2,4,8,3,6,12,9,1,3,2,6,4,12,8,9],Motor
return

End

What pins do you have your stepper motor connected to? (thru the '2003 of course).

Also, have you been able to make your motor step using only push button switches...in other words, are you sure your motor will step as long as the software works properly (push one button, steps one coil, push another button, steps another coil, and so on)? I'd get that working first to make sure you don't burn anything up and worry about the software control later...