Help with this project
imix500
Posts: 4
Hello all, I'm new to this forum and micro controllers but not electronics.
So I'm having trouble with the code for this project. It needs to spin a motor with a paddle wheel attached a certain number of times and then stop for a certain amount of time. The external components (motor ,paddle wheel switch) are working fine. Since the BS1 can't count, I'm using the FOR...NEXT instruction to set a number of loops for both paddle counting and interval timing. I am planning on using FOR...NEXT a large number of times for some of the intervals (~6 to 12 hours). Is there a better way in the BS1? Right now it seems like the BUTTON instruction is resetting the FOR...NEXT instruction for the motor control. Here's the program: Thanks!
SYMBOL btn = 0 ' FOR BUTTON
SYMBOL btnWrk = B4
SYMBOL reps = B2 ' FOR...NEXT loop counter
motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT
timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor
No_Press:
GOTO motor
So I'm having trouble with the code for this project. It needs to spin a motor with a paddle wheel attached a certain number of times and then stop for a certain amount of time. The external components (motor ,paddle wheel switch) are working fine. Since the BS1 can't count, I'm using the FOR...NEXT instruction to set a number of loops for both paddle counting and interval timing. I am planning on using FOR...NEXT a large number of times for some of the intervals (~6 to 12 hours). Is there a better way in the BS1? Right now it seems like the BUTTON instruction is resetting the FOR...NEXT instruction for the motor control. Here's the program: Thanks!
SYMBOL btn = 0 ' FOR BUTTON
SYMBOL btnWrk = B4
SYMBOL reps = B2 ' FOR...NEXT loop counter
motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT
timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor
No_Press:
GOTO motor
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
This is actually controlling the movement of parts into a machine.
I think I read the clue I previously missed. The BUTTON instruction cannot stop a loop, which is where my head was. So, any tips on how to have the stamp let a set number of paddles go by before stopping the motor and continuing on with the instructions?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
So, it seems to be working. Maybe not the most elegant of programming but it does seem to work -a starting point. The only change I made was where the No_Press condition branches to:
SYMBOL btn = 0 ' FOR BUTTON
SYMBOL btnWrk = B4
SYMBOL reps = B2 ' FOR...NEXT loop counter
motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
switch:
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT
timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor
No_Press:
GOTO switch