Schneider PLC Counter+Timer

Thread Starter

JPalas83

Joined Jul 8, 2021
3
New on this forum so, Hi there

So I've been trying to complete a program to a Schneider PLC in Ladder but having some doubts.
I'm trying to add a timer, this needs to add a block of time every time a contact is cloded (coin validator). Tried so use a counter and a pulse timer, but doens't add time to it.
Could someone give me any idea?
Using a Schneider Modicom M221 24 I/O and Ecostruture Machine Expert Basic

Thank you so much

Mod edit: Moved here and added PLC type to title. JohnInTX
 
Last edited by a moderator:

mcardoso

Joined May 19, 2020
198
Hi JP,

I am a PLC programmer professionally, but I don't have experience specifically with Schneider. I mostly work with Allen-Bradley, but maybe I can be of some help.

What is the exact nature of the timer you want? Should it always be running? Does it only run after a coin is detected? If so, when does the timer expire (what is the preset?). What should happen when the timer expires? Does the rising or falling edge of the coin detection trigger the timer?

Are you trying to time how long the coin spent in the detector? If so, see the example below.

Assuming the above statement is what you are going for, some pseudo code might look like this

Coin Detected Timer Preset = 10,000ms
|--------| |------------------------------------------------[Timer ON]----------------|

Coin Detected Copy Timer Current Value to Tag: CoinTime
|--------| / |----------[One Shot]-----------------------------[Copy]-----------------|

10<=CoinTime<=20 CoinReal
|-----------[Limit]---------------------------------------------( )---------------------|

20<CoinTime<10 CoinFake
|-----------[Limit]---------------------------------------------( )---------------------|

Timer Done CoinJam
|-----------| |-------------------------------------------------( )---------------------|


Here the timer counts up, increasing the timer value (accumulator) as long as the coin is in the sensor. When the coin leaves the sensor, we take the value of the timer and move it into a holding tag "CoinTime". We then compare that time to a limiting range of times for it to be a real coin. If it falls between those times say 10ms - 20ms in our example, then the coin is real. If it is outside that range the coin is fake.

The timer is set to expire after 10 seconds. If the Timer expires (goes DONE) then we illuminate CoinJam since we assume no coin can stay in the sensor that long.

CoinReal and CoinFake hold their state until the next coin exits the sensor.

There are some optimizations that can be done here (like not computing the limit twice) but usually it pays off to write ladder code in the most readable way possible, even when that is less efficient.

This was an example based on my best guess of your question. If you can clarify further then we can help more.

EDIT: The forum didn't render well, here is an image of how it should look.

1626206685006.png
 

Thread Starter

JPalas83

Joined Jul 8, 2021
3
Hello

The application is a self service car wash. I have found a way to add time to the Present Value but it does not do it while the timer is running, which is what i need.
So What I'm trying to accomplish, a coin detector receives a costumer coin and closes a contact witch starts a timer that gives X seg. When the costumer enters a 2º coin it should give addicional X seg.
Y+(X-Z)
X -Time given by the first coin
Y - Time given by the second Coin
Z - Whatever time as elapsed between 1º and 2º coin

It's a simple problem that I was hoping to have a simple solution, but it has been a struggle.

Thank you
 

mcardoso

Joined May 19, 2020
198
hmmmm, If you can't change the timer preset while it is running (I'd expect you could), then you might need to restart the timer with a preset equal to the current Preset - current Accumulator + New coin time value.

As long as your code sequences on the Timer Done status then starting the timer over with a new time shouldn't affect the operation of the machine.
 

Thread Starter

JPalas83

Joined Jul 8, 2021
3
So I found this solution, which can add time to a retentive TOF timer by reseting it, timer stops at the reset however, and then restarts where it left of. This shouldn't happen but I believe in the pratical operation it will be nothing more than milseg, and that's not serious.
I can't seem to find, however, a solution to reset the timer to it's original present value. Whenever the system restarts it will start at the Present value added in the last usage.
Any ideas?
Thank you
 

Attachments

Top