Pop Machine problems

RickK

Member
Join Date
Mar 2007
Location
Iowa
Posts
3
Hi all,

Working on another project in class, a Pop Machine this time.

I currently have everything working, except for the change return.

Using the compare commands (GEQ, LEQ, EQU) to return the proper change. I'd like to know if there's away to make a loop in this subroutine. i.e. if the subtract command leaves an integer in the regsister, it will loop back up and subtract again until the register reads "0".

Thanks, I appriciate all the help I received on my last question.

Rickk
 
You **can** probably use a loop, but I'd venture a guess to say that that would be the worst possible approach, as in a real-world situation, you would be stuck in that loop for an awful lot of scans, which could time out the processor watchdog.

Since the logic should be evaluated every scan, as long as a 'Change_Due' flag is set, you should be evaluating your coin return logic. Also, you should probably have an overall timeout alarm to determine if it takes more than say 10 seconds to return all change.
 
Last edited:
For an application like this, it is unlikely that you need to loop back within the program. You can accomplish the same result by doing the calculation in successive scans.

Anyone who has ever programmed a loop knows how easy it is for the program execution to get stuck in one. This is just as true for a PLC executing ladder logic code as for a PC executing a Visual Basic or C application. Most PLCs have a built-in watchdog timer. If the program gets stuck in a loop for longer than the watchdog timer, the PLC shuts itself down and turns all of its outputs off. Because of this, it is generally better to avoid the use of loops when there are alternative methods of getting the job done.
 

Similar Topics

I Started a New Quarter at School last week and the First Project is to program a pop machine. The word for word description is as follows...
Replies
30
Views
15,345
Hello everyone, I need your help to guide me how to make this screen appear when the alarm is present, I have already configured its size and the...
Replies
5
Views
141
Hi to all, Does TIA portal support creating reusable pop-up display as FTV has it implemented? Something like on link below. Thanks in advance.
Replies
5
Views
531
I am running Logix Designer v32, and noticed if I type new instruction value(s) (XIC, XIO, MOV, etc etc) into a rung without any operands/tags...
Replies
4
Views
775
Hi Everyone, currently i'm developing a project using Cimplicity version 10. I'm facing an issue where every time i press the same button to open...
Replies
9
Views
832
Back
Top Bottom