On every other scan. In this case the address for ’first scan’ in a PLC-5 is ’S2:1/14’. With the logic in the example the first scan will seal on ’light’, until ’clear’ is turned on. So the light will turn on after the PLC has been turned on, but it will turn off and stay off after ’clear’ is turned on.
I am working with PLCs trying to design a water tank. On one section of the design I am asked to create a clock pulse generator. I am currently trying to do this using ladder diagrams.
I believe I have the logic correct just cant seem to put it together. I want a counter to count the clock pulses that I generate, then I store these pulese in a data memory to ensure the count is retained if the system is switched off and on.
question is how do I design this clock pulse generator.
Kind regards
FrankWhiteFrankWhite
3 Answers
There are a few different ways to create a pulse generator (or commonly known in the plc world as a BLINK timer). As a matter of fact many plc programming softwares have this function block built in to their function block libraries. But if they don't or you just want to make your own you can do something like this
If you would like to count the number of pulses and store this value to a variable you can use a simple CTU (counter up) block available in all plc languages.
Review of functionality
- The
StartPulse
variable can be anything you want that will start the counter. In my case I just used an internalbool
variable that I turned on. If you want this timer to start automatically when the plc starts then just initialize this variable totrue
. BecauseStartPulse
only works on the rising edge of the signal theLatchPulseInitial
coil will only ever be set once. - When the
LatchPulseInitial
variable goes true this will startton1
aTimer On Delay (TON)
function block. This will delay the output of the block from turning on for the time ofPT
(in my case I have 500ms). - After 500ms has expired the
ton1
outputs will turn on. this will turn on theTimer1Done
variable and turn off theTimer2Done
andLatchPulseInitial
. Now thatLatchPulseInitial
has been turned off it will never interfere with the program again since it can only be turned on by the rising edge ofStartPulse
. Note: once the block has reachedPT
the outputs will stay on until the input to the block is removed.
- Since
Timer1Done
is now onton2
will start counting untilPT
is reached. OncePT
is reached the outputs for that block will turn on. This will resetTimer1Done
and setTimer2Done
This will startton1
again and thus starting the whole process over. - For the
PulseOutput
, which is the actual pulse output you are looking for, I have this being set to true whenTimer2Done
is true. This is because when this variable istrue
it is the high state of the pulse generator. WhenTimer1Done
is true it is the low state of the pulse generator. - When the
PulseOutput
goestrue
it will trigger the input on theCTU
which will increment the count of the variable inCV (current value)
by 1.
If you are going to be using this logic in numerous places in your program or you plan on reusing it in the future I would make this into its own function block so you won't have to repeat this logic everytime you want to make this type of timer.
mrsargentmrsargent
Once I had to create a BLINK FB. It is written in Structured Text. But it is suitable to use in a ladder logic program and IN/OUT Variables are named like TON style. The Blink starts with Q = TRUE. If you want to start with FALSE just invert Q and switch the Times!
Felix KeilFelix Keil
In my opinion, this is the most straightforward way to do it, using 1 timer, up counter and modulo operator:
Also note, if your PLC doesnt have modulo, then multiply by -1 each time.
alekskaleksk
Not the answer you're looking for? Browse other questions tagged clockplc or ask your own question.
A TON plc based timer for javascript.
The TON (On-Delay Timer) type of timer is used to control on-delay actions. When the Timer start, it wait a preset period of time to turn on is output.
Installation
Basic Usage
TON constructor([preset [, retentive [, callback [, ...args]]]])
- preset {number | string}
- retentive {boolean}
- callback {function}
- args
preset Defines the preset value for the timer in ms. Default is 1000 (1s).
retentive Set true or false the retentive behavior. When the retentive is false (default), the property Ton.V is reset when Ton.Stop is called. Counting restarts from 0.When the retentive is true, the timer retains its value when Ton.Stop is called before the Preset value is reached. Counting restarts from this value.
callback Function to call when the preset value is reached.
args arguments to pass to a callback function.
Timer Atributes
isRetentive
Type: {boolean}
Indicate the retentive behavior of the timer. See retentive description on constructor secction.
isRunning
Type: {boolean}
Indicate the running status of the timer.
P
Type: {number}
Indicate the preset value of the timer.
Q
Type: {boolean}
Timer output. Indicate the preset value was reached.
tick
Type: {Wiring.Signal}
A signal that is emited by timer when the preset value was reached.See wiring.io for mor details about signal and slots.
![Turn Of Ton Plc Turn Of Ton Plc](/uploads/1/2/5/8/125805072/400815269.png)
V
Type: {number}
Value that increments from 0 to the preset value timer.P when the timer is running. The value can be read and tested, but not written to
Timer Methods
Start()
Start the timer. Similar to put in true the in input of a plc's ton timer. Returns a
Boolean
indicating whether or not the timer was started.![Plc ton block Plc ton block](/uploads/1/2/5/8/125805072/999115936.png)
Stop()
Stop or pause (depents of retentive behavior) a timer. Similar to the
start()
method, Stop()
returns a Boolean
indicating whether or not the timer wasstopped.SetAction(callback [, ...args])
Set a callback function to call when the preset value is reached. The callback function will be called whit the aruments passed to SetAcction.
Development
Pull requests are welcome.
Get the code
Install the dependencies
Run the tests
Contributing
If you have a suggestion or found a issue, let us known and create an issue
License
This project is licensed under the MIT License - see the LICENSE.md file for details