Small Machine Automation
RGR_Engineer
Posts: 18
Ok, this is a huge project and there is a lot of code, so I hope there is a way someone will be able to help me. I wrote this as several smaller codes for each individual function (each worked correctly) then assembled it. My program is attached.
Here is what I'm doing:
I am building a machine that will dispense 2 capsule halves, fill them, snap them shut, then repeat the process until the number of balls (that were input at the beginning) have been completed. Each subroutine (dispensing, filling, and snapping) is triggered by a magnet fixed to the drive belt when it passes various reed switches I am testing that everything triggers correctly using a board with 16 inputs and 8 outputs. Everything triggers correctly, however I have come across a glitch that I can't seem to find a reason for. When I press the Start button and enter the number of balls that should created the program will cycle once through the "elseif (triggers = %00000000) then" section of the main routine, then skips to the Finish Subroutine (instead of going back to main) where "state = mlim" and it displays "Male Reset". Then instead of moving on to "state = flim" or repeating "state = mlim" it goes back to the beginning of Finish and loops forever. This only happens when the start button is pressed or when the "one ball" button is pressed and the first reed switch is not triggered right away. If the reed switch is triggered in a timely manner, the program runs smoothly without any glitches.
I figured out exactly what the code was doing by entering Debug statements and various points in the program. I've gone through the code several times and cannot figure out what is wrong. The only way I can see this happening is if "Ball = BallDone", but I can't find anything in the code that would make that true without running the program until the ball counter gets up to the input value of BallDone.
Does anyone have any ideas? I could really use some help. If there is any other information I need to provide, I will be happy to.
Thanks,
Tara
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
Post Edited (RGR_Engineer) : 12/22/2009 12:27:09 AM GMT
Here is what I'm doing:
I am building a machine that will dispense 2 capsule halves, fill them, snap them shut, then repeat the process until the number of balls (that were input at the beginning) have been completed. Each subroutine (dispensing, filling, and snapping) is triggered by a magnet fixed to the drive belt when it passes various reed switches I am testing that everything triggers correctly using a board with 16 inputs and 8 outputs. Everything triggers correctly, however I have come across a glitch that I can't seem to find a reason for. When I press the Start button and enter the number of balls that should created the program will cycle once through the "elseif (triggers = %00000000) then" section of the main routine, then skips to the Finish Subroutine (instead of going back to main) where "state = mlim" and it displays "Male Reset". Then instead of moving on to "state = flim" or repeating "state = mlim" it goes back to the beginning of Finish and loops forever. This only happens when the start button is pressed or when the "one ball" button is pressed and the first reed switch is not triggered right away. If the reed switch is triggered in a timely manner, the program runs smoothly without any glitches.
I figured out exactly what the code was doing by entering Debug statements and various points in the program. I've gone through the code several times and cannot figure out what is wrong. The only way I can see this happening is if "Ball = BallDone", but I can't find anything in the code that would make that true without running the program until the ball counter gets up to the input value of BallDone.
Does anyone have any ideas? I could really use some help. If there is any other information I need to provide, I will be happy to.
Thanks,
Tara
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
Post Edited (RGR_Engineer) : 12/22/2009 12:27:09 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
I would start a DEBUG for Ball and BallDone to track its value.
Large codes can take a while to DEBUG!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
Nicely done program, by the way. I haven't had a chance to study it in detail, but a couple of things come to mind.
Do the Start button and reed/buttons get read with the '165 chip? There may be an issue at start up where some of the chip states are not defined or are random. During initialization you can run through a cycle to make sure everything is in the expected states. Maybe use Debug during initialization to see what's there.
The other thing that catches me from time to time is not getting out of loops and subroutines properly. Usually happens by GOTOing instead of using EXIT or RETURN. If you have such a situation, you might have a variable in an unexpected state.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
ELSEIF (Triggers = %00000000) THEN····
Since this is where its failing add some DEBUG into the flow
Thanks again!
-Tara
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
Post Edited (RGR_Engineer) : 12/22/2009 4:15:33 PM GMT
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
-Tara
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
Glad to here the good news. I'd like to see the finished project when You complete it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA