Vending Machine based plc

Meemee

Member
Join Date
May 2020
Location
Curepipe
Posts
3
I got a problem concerning the change of coins from a vending machine plc based, i use the rs logic starter lite with Rs emulate 500 along with rslinx classic.
i am actually a beginning having problem to run the program. I made use of subroutine to subtract the input money from the price of the product.
Anybody can help?
 
I have called the subroutine but it's not working,The change is actually stored in the N7:15. And at the start of program when any coin 20 is added to the machine, the counter c5:4 adds up and therefore it need to count down when the change exceeds 20 and also need to subtract.

Thank you

SUBROUTINE CALL.PNG
 
I have called the subroutine but it's not working
First, a slight detour


From the statement quoted above, it is likely that you are somewhat inexperienced in programming. That is okay, that is not meant to insult embarrass you, everyone one here has been where you are and has done something similar; it's a club, and we are having jackets and hats made up;).


The ***MOST*** important thing for to understand from this reply is that this will be last time you use that statement ("it's not working") without appending a phrase: "it's not working how I want it to." Because I can assure you that the program is working; that is, it is doing exactly what you told it to do; however, I do understand and agree and sympathize that it is not doing what you want it to do.


The secret of successful programming is this: the ONLY thing that is important is what we tell the PLC to do; WHAT WE WANT IT TO DO IS IRRELEVANT!


Conjecture

We don't know what the main routine is doing, and you have still not told us what how the entire program is actually behaving and how this is different from what you want it to do.


But from the code you showed us (and similar code I have written in the past;)), and what you wrote in the last post, it appears that every time this routine is called with B3:7/15 = 0, the program should subtract 20 from N7:15, and when it makes that subtraction you expect it to also decrement Counter Control C5:4? Is that correct?

When the code subtracts 20 from N7:15, it puts the result in a different integer, N7:16; I assume there is someplace else in the main routine where N7:15 will have 20 subtracted from its value, probably triggered by the discrete output O:0/14 (RELAY TO OPENING COIN20). Is that correct?




So if N7:15 goes over 39, then two or more 20s need to be subtracted and the machine needs to release two or more 20 cent coins. And in that case I suspect the problem (with the current code) is that you only see one coin released. Is that correct?



Summary



So, if all my conjectures (assumptions) above are correct (and that is a big if), then the problem is when N7:15 goes over 39. In that case this routine only sets B3:7/15 to 1 only once, when N7:16 finally goes below 20, instead of setting B3:7/15 back to 1 on each 20 is subtracted. As a result the CTD instruction counts down only once, which sets C5:4/CD to 1 only once, which sets O:0:14 to 1 only once.


Details

See here: https://literature.rockwellautomati...documents/rm/1763-rm001_-en-p.pdf#G12.1048469



Summary: the CTD instruction counts up or down only on a rising edge (false-to-true transition) of its input rung. CTU keeps track of the rung state from the previous scan of its instruction in the Counter Control internally, specifically in the CD bit (C5:4/CD here).
So if a CTD instruction's input rung transitions to true, and remains true from scan to scan after that, a CTD will only decrement on that transition; it will not decrement on subsequent scans until it sees another false-to-true transition.



So if B3:7/15 is false, and remains false on subsequent calls to this subroutine, which appears to be that case when N7:15 starts at 40 or more, then the CTD will decrement C5:4.ACC the first time only that this routine is called.
 
Last edited:
Sorry for that:(
I cant upload the file due to file size so here is a link for the program

https://drive.google.com/file/d/1UuSXEYAV9_5aR6LOXjZJdm7aHxo1RlHJ/view?usp=sharing

The program actually have to select either 1 product from 4 products and can order up to 2 units.
Subroutines have been called for each product and price is calculated.

The coins are inputed then counted until led light flash when amount has reached or exceeded.

Subtraction is then done to give back change.
 
I'll take a look

You can put a .RSS file into a .zip and upload it here, but it might be easier to print a report as a PDF file and upload it here
 

Similar Topics

Hi, I have seen a few post with similar topics and I have tried contacting the authors however I have not had any luck so I am posting this new...
Replies
14
Views
1,012
Please assist, i don't know where to start. Vending machine for personal use only for a school project. I've attached a picture of what it...
Replies
4
Views
2,071
Hi, I'm pretty new to PLCs (about 2 weeks experience) and still learning all the commands but I had a problem and after spending a long time...
Replies
4
Views
3,961
I am working on a PLC simulation using I/O simulator and BCD counter i was basically i want a push button for 5,10,and 25 cent that would add them...
Replies
3
Views
221
i want t know the contril folw of a vending machine PLC bsed who can help me
Replies
1
Views
1,670
Back
Top Bottom