Thank you
After much trial and tribulation, I got my "push-button" project to work exactly how I wanted to, with the help of you guys of course.
So I just want to say thanks to all the people that helped me.
Oh and if anyone wants to see my final program, just ask.
So I just want to say thanks to all the people that helped me.
Oh and if anyone wants to see my final program, just ask.
Comments
Let's see it!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not a complete idiot! Some of my parts are missing.
I feel embarrassed because it's so basic and simple (also a bit repetative)... but, the BS1 is very limited with it's coding... anyways, here's what I came up with and it works perfect.
By the way, this is what I wanted to achieve:
- Push button
- Activate stepper motor (in high torque mode) one revolution clockwise
- PAUSE a minute OR push button again
- Activate stepper motor (again, in high torque mode) one revolution counter-clockwise
- Return to beginning
Program:
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL StpsPerRev = 48 ' whole steps per rev
SYMBOL idx = B2 ' loop counter
SYMBOL phase = B3 ' new phase data
SYMBOL stpIdx = B4 ' step pointer
SYMBOL stpDelay = B5 ' delay for speed control
Full_Steps:
EEPROM 0, (%00110000, %01100000, %11000000, %10010000)
Setup:
DIRS = %11110000 ' make P1, P4-P7 outputs
stpDelay = 15 ' set step delay
Setup2:
PINS = %00000000
IF PIN1 = 1 THEN CCW
GOTO Setup2
CCW:
FOR idx = 1 TO StpsPerRev ' one revolution
GOSUB Step_Rev ' rotate counter-clockwise
NEXT
GOTO Setup3
Setup3:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup4
Setup4:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup5
Setup5:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup6
Setup6:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup7
Setup7:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup8
Setup8:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup9
Setup9:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup10
Setup10:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup11
Setup11:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup12
Setup12:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup13
Setup13:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup14
Setup14:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup15
Setup15:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup16
Setup16:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup17
Setup17:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup18
Setup18:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup19
Setup19:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup20
Setup20:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup21
Setup21:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO Setup22
Setup22:
IF PIN1 = 1 THEN CW
PAUSE 2500
GOTO CW
CW:
FOR idx = 1 TO StpsPerRev ' one revolution
GOSUB Step_Fwd ' rotate clockwise
NEXT
GOTO Setup2
END
Step_Fwd:
stpIdx = stpIdx + 1 // 4 ' point to next step
GOTO Do_Step
Step_Rev:
stpIdx = stpIdx + 3 // 4 ' point to previous step
GOTO Do_Step
Do_Step:
READ stpIdx, phase ' read new phase data
PINS = PINS & %00000000 | phase ' update stepper pins
PAUSE stpDelay ' pause between steps
RETURN
Post Edited (Mike_Developer) : 6/1/2008 7:55:37 PM GMT
I know you can run with single phases on at half torque (twice the battery life), but I haven't tried three phases on (0111, 1110, 1101, 1011) because it'll eat batteries and the motor will get hot.
What kind of motor is it?
Oh, and as long as it works, who cares what·the code·looks like. I put almost 15 years in at IBM. I'm no programmer by any stretch of the imagination (Remember my code?), but I've seen some real garbage that did what it was supposed to do.
CHEERS!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not a complete idiot! Some of my parts are missing.
just wondering
Amaral