How-to
Build a siren pulse count sequence in S7-1200 ladder logic
Short answer
Use a positive-edge request to load a target of 3, 2, or 1 pulses, then run a four-state ladder sequence — idle, start, stop, count — that drives Q6.2 (START) and Q6.1 (STOP) from separate states so the two SIMOCODE Pro V commands never overlap. With a 2.0 s on-time and a 1.0 s gap, the three patterns finish in 11.0 s, 7.0 s, and 3.0 s.
On this page
- How do you turn three signals into counts of 3, 2, and 1?
- Why does the pattern restart every scan without an edge contact?
- How do you drive the SIMOCODE start and stop commands?
- What does the ladder sequence look like step by step?
- How long does each pattern take from first ring to idle?
- What happens if a signal arrives while the siren is already pulsing?
- How should the sequence behave after a power cycle or a trip?
- How do you test all three patterns before the siren is wired?
- Questions asked
Build the pattern as one four-state sequence — idle, start, stop, count — where an edge-detected request loads a target of 3, 2, or 1 pulses and the sequence issues exactly that many start/stop command cycles before returning to idle. The states themselves keep Q6.2 (START) and Q6.1 (STOP) mutually exclusive, because each state drives only one of them. With the example timing of a 2.0 s on-time and a 1.0 s gap, the three patterns complete in 11.0 s, 7.0 s, and 3.0 s. The sections below follow the order you will meet the problem: selecting the count, catching the scan-cycle trap, mapping the commands, building the sequence, setting the timing, and proving it in test.
How do you turn three signals into counts of 3, 2, and 1? #
Give each of the three signals its own positive-edge contact, run the three edges through priority-ordered selection, and move the winner's target — 3 for Signal 1, 2 for Signal 2, 1 for Signal 3 — into a target register that the sequence counts against. Program the selection as its own rung group, upstream of anything that touches the command outputs.
Declare the bookkeeping registers as plain integers with zero start values: SirenState (Int, 0), SirenTarget (Int, 0), SirenDone (Int, 0). These tag names are illustrative; Q6.2 and Q6.1 in the sections below are the project's addresses for START and STOP, exactly as the question states them.
Commit to a fixed priority for the scan where two edges land together: check Signal 1 first, then Signal 2, then Signal 3, first match wins. An unassigned tie is the one defect this pattern cannot tolerate, because an ambiguous target produces an ambiguous number of rings.
If your count never changes and you only need one fixed number of rings, the selection layer is unnecessary — that simpler case is siren ring count ladder logic with a timer and counter.
Why does the pattern restart every scan without an edge contact? #
A signal that stays true is true in every PLC scan, so plain contact logic would reload the target and restart the pattern continuously until the input drops; one positive-edge contact per signal makes each request exactly one scan wide. The edge contact passes its input for a single scan on the rising edge, and that is what converts a held pushbutton or a latched alarm bit into one accepted request.
Latch the acceptance, not the condition: idle stores the target and leaves idle, and from then on the raw input level means nothing to the sequence until the pattern finishes. This one-scan trigger discipline is the same one used when writing an S7-1200 heartbeat in ladder logic — there too the rung must fire on transitions rather than levels, or it retriggers every scan.
How do you drive the SIMOCODE start and stop commands? #
Drive Q6.2 (START) and Q6.1 (STOP) from separate states of the sequence and hold each only for its command pulse — 0.5 s in this example — so the two SIMOCODE Pro V commands are mutually exclusive by structure, not by interlock. The SIMOCODE pro system manual (edition 02/2023) shows start and stop switches wired directly to inputs on the basic unit: pushbutton operation. That is the behavior to assume — a short pulse on Q6.2 latches the starter, a short pulse on Q6.1 drops it. The 0.5 s value is an example, chosen as a clean command for a hardwired input; the configured interface sets the real requirement.
Verify two things before commissioning. First, confirm what Q6.2 and Q6.1 actually are in this project — physical outputs driving the unit's control inputs, or mapped bits of a network interface — because the state logic is identical either way but your fault-finding is not. Second, if run feedback is mapped back to the PLC, use it: a timer proves the command was issued, feedback proves the siren sounded.
The exclusivity rule itself is structural, the same discipline as configuring mutually exclusive outputs on any other platform: one state owns one output, and no second rung writes the same coil.
What does the ladder sequence look like step by step? #
Four states carry the whole pattern: idle accepts one request and loads the target, start pulses Q6.2 and runs the on-time, stop pulses Q6.1 and waits the off interval, and count either loops back to start or returns to idle. State encoding is your choice; the values below are illustrative. Use one on-delay timer per timed wait and reset each timer when its state is left.
| Tag | Type | Initial | Meaning |
|---|---|---|---|
SirenState |
Int | 0 | 0 idle, 1 start, 2 stop, 3 count |
SirenTarget |
Int | 0 | pulses requested this pattern |
SirenDone |
Int | 0 | pulses completed this pattern |
- Idle (
SirenState= 0): both commands false. On the highest-priority edge, move 3, 2, or 1 intoSirenTarget, zeroSirenDone, setSirenState:= 1. - Start (
SirenState= 1): set Q6.2 true for the 0.5 s command pulse, then false. The starter stays latched, so the siren sounds through the 2.0 s on-time; if run feedback is configured, require it within a timeout or abort to idle. - Stop (
SirenState= 2): set Q6.1 true for 0.5 s, then false. Keep both commands false through the 1.0 s gap. - Count (
SirenState= 3): add 1 toSirenDone. IfSirenDone<SirenTarget, return to state 1; otherwise clear the accepted request and return to idle.
That is the whole sequence: two mutually exclusive command states, two bookkeeping states, and no path that ever writes both outputs in the same scan.
How long does each pattern take from first ring to idle? #
With 0.5 s commands, a 2.0 s on-time and a 1.0 s gap between pulses, Signal 1 finishes in 11.0 s, Signal 2 in 7.0 s, and Signal 3 in 3.0 s, measured from the first start command to the return to idle. Each pulse costs the start command plus the on-time plus the stop command: 0.5 s + 2.0 s + 0.5 s = 3.0 s. The gap runs only between pulses, so an n-pulse pattern adds (n − 1) × 1.0 s. Total = 3.0 s × n + 1.0 s × (n − 1):
- Signal 1, n = 3: 3.0 × 3 + 1.0 × 2 = 9.0 + 2.0 = 11.0 s
- Signal 2, n = 2: 3.0 × 2 + 1.0 × 1 = 6.0 + 1.0 = 7.0 s
- Signal 3, n = 1: 3.0 × 1 + 1.0 × 0 = 3.0 + 0 = 3.0 s
The on-time dominates the total: stretch it from 2.0 s to 3.0 s and Signal 1 moves to (0.5 + 3.0 + 0.5) × 3 + 2.0 = 14.0 s, while the same 1.0 s added to the gap moves it only to 3.0 × 3 + 2.0 × 2 = 13.0 s. All four time values are examples chosen here for the arithmetic; your site's audible-code requirement sets the on-time and gap, and the device configuration sets the command pulse. When you change them, the formula is the check.
What happens if a signal arrives while the siren is already pulsing? #
Accept requests only in idle: a signal that rises while a pattern is running is ignored, and once the sequence returns to idle that same input needs a fresh rising edge before anything new starts. For an audible warning, ignore is the correct default of the three policies — a queued request replays a stale warning after conditions may have changed, and a replacing request truncates a pattern operators already started counting.
Program it simply: qualify the request-acceptance rung with the idle state, and let nothing else in the pattern read the raw input levels. A signal that rises mid-pattern then never reaches the target register, and the sequence keeps exactly four states instead of growing queue logic.
How should the sequence behave after a power cycle or a trip? #
Initialize to idle in the CPU's startup routine with both command outputs false and both counters cleared, so no pattern resumes on its own after a restart, and let any protective trip inhibit the start state until it is acknowledged. Two rules cover the ugly cases: after a restart, the startup routine sets SirenState := 0, SirenDone := 0, SirenTarget := 0 and writes false to both outputs, so a pattern that died mid-count stays dead until a new edge; after a trip, the sequence must never reissue Q6.2 just because SirenDone is short of SirenTarget.
Write the abort so it wins. If one rung resets SirenState while another still sets it from a condition that remains true, the reset silently loses — the mechanism behind why a bit reset never executes in S7 logic — so make the abort the only writer of the state or the last write in scan order.
How do you test all three patterns before the siren is wired? #
Trigger each signal once while watching the tags online and count the Q6.2/Q6.1 pulse pairs against the target: Signal 1 must yield exactly three, Signal 2 exactly two, Signal 3 exactly one, and a held input must not retrigger. One note belongs here: once the physical siren is connected, coordinate test ringing with operations, because at a running plant an audible pattern is indistinguishable from a real alarm to everyone in earshot.
| Trigger | Target loaded | Command pairs out | Back to idle |
|---|---|---|---|
| Signal 1, one edge | 3 | 3 | 11.0 s |
| Signal 2, one edge | 2 | 2 | 7.0 s |
| Signal 3, one edge | 1 | 1 | 3.0 s |
| Any signal held true | 3, 2 or 1 | as targeted | no retrigger without a new edge |
Two more cases close it out: raise two request edges in the same scan and confirm the priority target loads; raise a request mid-pattern and confirm nothing changes until the running pattern completes.
Questions asked
Can one timer and one counter do this instead of a state machine?
They can for a single fixed count, which is the ring-counter pattern, but three selectable targets need a target register and a comparison, and issuing the stop command between pulses needs a step or state bit to separate the phases. By the time you add those pieces you have built the state machine anyway, so write it as one from the start and keep every command in exactly one place.
Should the START and STOP commands stay energized, or is a pulse enough?
The SIMOCODE pro system manual wires its start and stop switches directly to inputs on the basic unit, which is pushbutton, momentary-style operation, so short command pulses are the expected stimulus. The 0.5 s pulse used here is an example; take the actual command time from your device configuration, and never leave STOP maintained unless that configuration explicitly calls for it.
How many I/O points does the sequence need?
Two outputs, Q6.2 for START and Q6.1 for STOP, plus one input per request signal, and one more input if run feedback is wired back. The state, target and completed-count registers are internal memory words, so the I/O count does not grow no matter how many pulse patterns you define.
What if Signal 1 and Signal 2 rise in the same scan?
The priority order already decides it: Signal 1 loads 3 and Signal 2's edge is consumed. Write the selection as priority-ordered checks so the second edge is never accepted in that scan, then test the tie deliberately by setting both request bits together online, because an untested tie is the most common defect in this pattern.
Why does the siren keep sounding after the last pulse?
Either the stop command pulse is shorter than the configured command time needs, or the sequence advanced past the stop state before its timer finished. Lengthen the stop pulse first, then confirm online that the count state returns to idle and clears Q6.1; if run feedback is wired, that feedback should be false before the sequence reports the pattern complete.