Shop OBEX P1 Docs P2 Docs Learn Events
Small Machine Automation — Parallax Forums

Small Machine Automation

RGR_EngineerRGR_Engineer Posts: 18
edited 2009-12-22 23:44 in BASIC Stamp
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

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-21 23:34
    Tara I think Your problem may be contact bounce in the reed switches.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
  • RGR_EngineerRGR_Engineer Posts: 18
    edited 2009-12-22 00:23
    I'm not using the reed switches yet. I'm running it off of push buttons at the moment; for testing purposes. Sorry, I forgot to mention that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-22 01:38
    Push buttons bounce too. You could add some PAUSE times to help wait for the contact to open or close. As You mentioned "If the reed switch is triggered in a timely manner, the program runs smoothly without any glitches."


    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
  • stamptrolstamptrol Posts: 1,731
    edited 2009-12-22 01:43
    Tara,

    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
    ·
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-12-22 01:45
    Whai is the value of Triggers here? ( In Main[noparse]:)[/noparse]


    ELSEIF (Triggers = %00000000) THEN····

    Since this is where its failing add some DEBUG into the flow
  • RGR_EngineerRGR_Engineer Posts: 18
    edited 2009-12-22 16:08
    Thanks for trying to help, everyone. And thank you stamptrol for complimenting my program [noparse]:)[/noparse] I've been working on it for a couple months and I'm pretty new to programming still. I tried the debug statements and nothing seemed to make sense so I just rolled back the revision to 2 days ago (before this issue started) and then slowly added in each function that I had changed since then. It's working fine now. I never found the problem, but I probably had deleted a line that I thought was useless but wasn't.

    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
  • stamptrolstamptrol Posts: 1,731
    edited 2009-12-22 19:58
    Good to see progress. Don't forget to show us the finished machine!

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • RGR_EngineerRGR_Engineer Posts: 18
    edited 2009-12-22 22:24
    I will be sure to do post pictures and code when it is finished. But it will be quite awhile from now as I still need to fine tune the hardware.

    -Tara

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Either kill me or take me as I am because I'll be damned if I ever change" - Marquis de Sade
  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-22 23:44
    Tara

    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
Sign In or Register to comment.