Having a problem with Timers

actuallylike

Member
Join Date
Nov 2010
Location
Dublin
Posts
2
Hi all,
new here and have a problem I hope you can help me with, searched your archive and couldn't find anything similar. I'm writing a PLC program using rslogix 5k for university and have hit a wall and honestly don't know where to turn.

Basically, I'm trying to make a simulation of a tank filling up with liquid from another tank. Sorted that pretty easily in the Structured Text but our lecturer insists that the simulation looks real as in the tanks have to empty and fill in real time where I had it so they just instantly changed. I'm assuming the answer is in timers or counters which I've tended to avoid cause can't really get my head round them at the moment.

I'm sure there's a relatively simple answer but our lecturer is a joke, never giving us worked examples to practice with and whenever you ask a question you just get a "well, what do you think" response so I'm pretty much in the dark here. Combed the manuals but can't get an answer so I'd really appreciate it if any of you could help out.

Thanks.
 
A timer is actually pretty simple. The TON starts timing (in milliseconds) when the preceding logic goes true, until it hits its preset value, then turns on its .DN bit.

The TON timer unconditionally resets itself if the preceding rung logic goes false.

You also have access to the preset value (.PRE), and the current accumulated value (.ACC).

To simulate filling a tank in one minute, create a timer, set the preset to 60,000 (60 seconds), and enable it.

For simplicity sake (or, some may say, to complicate things) I would generally normalize the value so I don't have to change my HMI's and such if I change preset values. You can normalize to a span of 0 to 100% by creating additional tags, both reals and some simple math:

DIV MyTimer.ACC MyTimer.PRE MyREALTimerRatio (this gives 0 to 1)
MUL MyREALTimerRatio 100.0 MyRealTimerPercent (Normalize to 0 to 100%).
 
The only way to get close to 'real time' is to know the volume of the tanks and the rates of filling and emptying. It also helps if the tanks are cylindrical, without rounded tops or bottoms, so that there is to a linear filling/emptying rate.

Depending on the values it might take much more than a class time to fill or empty. If you are allowed you may choose a non-boring time to fill and empty. It would be more creative if the two were different.

Then you use animation of your display/simulation to show the level.

If filling then the current level equals full level times max fill time divided by current fill time (be careful of a 'divide by zero at the start).

While emptying (assuming from full) the current level equals full level times max empty time divided by (max empty time - current empty time) (be careful of a 'divide by zero' at the end).
 
A timer is actually pretty simple. The TON starts timing (in milliseconds) when the preceding logic goes true, until it hits its preset value, then turns on its .DN bit.

The TON timer unconditionally resets itself if the preceding rung logic goes false.

You also have access to the preset value (.PRE), and the current accumulated value (.ACC).

To simulate filling a tank in one minute, create a timer, set the preset to 60,000 (60 seconds), and enable it.

For simplicity sake (or, some may say, to complicate things) I would generally normalize the value so I don't have to change my HMI's and such if I change preset values. You can normalize to a span of 0 to 100% by creating additional tags, both reals and some simple math:

DIV MyTimer.ACC MyTimer.PRE MyREALTimerRatio (this gives 0 to 1)
MUL MyREALTimerRatio 100.0 MyRealTimerPercent (Normalize to 0 to 100%).
Cheers for your advice, starting to come to grips with now. Class on in an hour so can fiddle about with it then, I'm sure it'll come together today.
The only way to get close to 'real time' is to know the volume of the tanks and the rates of filling and emptying. It also helps if the tanks are cylindrical, without rounded tops or bottoms, so that there is to a linear filling/emptying rate.

Depending on the values it might take much more than a class time to fill or empty. If you are allowed you may choose a non-boring time to fill and empty. It would be more creative if the two were different.

Then you use animation of your display/simulation to show the level.

If filling then the current level equals full level times max fill time divided by current fill time (be careful of a 'divide by zero at the start).

While emptying (assuming from full) the current level equals full level times max empty time divided by (max empty time - current empty time) (be careful of a 'divide by zero' at the end).
The problem regarding times to fill are immaterial, she just wants us to simulate 'movement' so it looks like their changing. Thanks for your advice though, should get a decent attempt at it now.
 

Similar Topics

:banghead: Hello there Any can help me please, I'm using wincc SP3 2008.. The problem is when I use the scada with the animation gif file to run...
Replies
0
Views
1,186
So much thanks for your reply.... I have rearranged the RS232 pins as 2-3, 3-2, 5-5 and then I configured driver as RS232 DF1 with 19.2K baudrate...
Replies
0
Views
4,221
please help me about my plc problem. a have a "Stetter" batching plant "CP 30" with S7 plc.. when i switched on the supply the PLC's all lights...
Replies
2
Views
2,503
Hi all! I'm having a problem with a new PLC5/80C freezing or hanging. We use ControlNet to interface with our DCS via KFC modules. We have 4...
Replies
4
Views
4,266
I copied a panel in factory talk HMI for an identical system. The label names are still the same as the original panel but I am trying to change...
Replies
1
Views
126
Back
Top Bottom