Automation Builder uses the IEC 61131-3 timer and counter blocks. TON switches its output Q on after the input IN has been TRUE for the preset PT (for example T#3s); TOF keeps Q on for PT after IN goes FALSE; TP gives a fixed pulse. CTU counts rising edges on CU, sets Q when the count CV reaches PV and is cleared by RESET. Each block needs its own instance variable.
- Every timer and counter needs its own instance (T_Warn : TON;)
- Time presets use IEC literals: T#3s, T#500ms, T#1m30s
- CTU counts rising edges, so a sensor held on counts once
- Name instances after their job: T_Warn, T_RunOn, C_Parts
Real machines rarely just start and stop. They warn before moving, keep running to clear a part, and count what they produce. These three jobs cover TON, TOF and CTU, the blocks you will use most.
Step 1: Choose the Right Timer or Counter
| Block | Inputs → outputs | Behaviour | Conveyor use |
|---|---|---|---|
| TON on-delay | IN, PT → Q, ET | Q TRUE after IN has been TRUE for PT | 3 s warning horn before motor start |
| TOF off-delay | IN, PT → Q, ET | Q TRUE with IN, stays TRUE for PT after IN falls | Run 5 s after the exit sensor clears |
| TP pulse | IN, PT → Q, ET | Fixed-length pulse on rising IN | 1 s pulse to a reject flap |
| CTU up counter | CU, RESET, PV → Q, CV | CV +1 per rising edge; Q when CV ≥ PV | Batch of 5 parts |
| CTD down counter | CD, LOAD, PV → Q, CV | CV −1 per edge; Q when CV ≤ 0 | Parts remaining in an order |
| CTUD up/down | CU, CD, RESET, LOAD, PV | Both directions | Buffer conveyor fill level |
VAR
T_Warn : TON; (* pre-start warning *)
T_RunOn : TOF; (* run-on after exit *)
C_Parts : CTU; (* batch counter *)
Start_Req, Warn_Done, Batch_Done : BOOL;
END_VARStep 2: Pre-start Warning with TON
- Change the start rung so Start sets
Start_Req(seal-in) instead of the motor output. - Insert a TON block (instance
T_Warn), IN =Start_Req, PT =T#3s, Q → coilDO_Motor_Run. - Add a rung:
Start_ReqAND NOTT_Warn.Q→DO_Buzzer. - Stop resets
Start_Req, which resets the TON and stops the motor.
Timer and counter simulator
Press Start: the buzzer sounds for 3 s, then the motor runs. Pulse the exit sensor 5 times to finish the batch. Reset clears the counter.
Green contact = passing power. Orange moving wire = rung is true and the output is energised.
Step 3: Run-on with TOF and Batch Count with CTU
| Rung | Logic | Notes |
|---|---|---|
| Run-on | TOF T_RunOn: IN = DI_Exit_Sensor, PT = T#5s → keeps Cmd_RunOn TRUE | OR Cmd_RunOn into the motor command so the conveyor clears the part |
| Count | CTU C_Parts: CU = DI_Exit_Sensor, RESET = DI_Reset_PB, PV = 5 | Rising edge only: a part sitting on the sensor counts once |
| Batch done | C_Parts.Q → Batch_Done | Used as NC contact in the start rung |
| Display | C_Parts.CV → HMI | Show count on the CP604 in Lab 12 |
A normal CTU counts from 0 after a power cycle. If production counts must survive power off, declare the count in a RETAIN area and copy it, rather than relying on the block instance.
Step 4: Test on the Kit
| ID | Check | How to check | Pass criterion | Result |
|---|---|---|---|---|
| Timers and counters | ||||
| T-01 | Warning | Press Start | Buzzer 3 s, then motor; T_Warn.ET counts to 3 s | |
| T-02 | Stop during warning | Press Stop within 3 s | Buzzer stops, motor never starts | |
| T-03 | Count | Pass 5 parts past exit sensor | C_Parts.CV = 5, motor stops | |
| T-04 | Held sensor | Hold part on sensor | Counts once only | |
| T-05 | Reset | Press Reset | CV = 0, start possible again | |
Practice Exercise
Add a TP block that pulses DO_Reset_Lamp for 1 s each time a part is counted, and a second counter for total parts that is never reset by the batch reset.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Timer never finishes | IN not held TRUE (pulse instead of level) | Drive IN with a sealed bit like Start_Req |
| Two timers behave the same | Same instance used twice | Declare one instance per timer |
| Counter counts many times per part | Bouncing sensor or CU driven by a pulse train | Check sensor, add input filter |
| Count lost after power off | Non-retain variable | Store count in a RETAIN variable |
Frequently asked questions
How do I use a TON timer in ABB Automation Builder?
Declare an instance (T1 : TON;), insert the TON block in ladder, connect IN to the start condition, set PT such as T#3s and use Q where you need the delayed signal.
What is the difference between TON and TOF?
TON delays switching ON: Q comes on PT after IN. TOF delays switching OFF: Q goes off PT after IN falls.
How does a CTU counter work?
Each rising edge on CU adds 1 to CV. When CV reaches PV, Q becomes TRUE. RESET sets CV back to 0.
How do I write a time preset in Automation Builder?
Use IEC time literals: T#500ms, T#3s, T#2m, T#1h30m.