Troubleshooting
PLC hopper filling sequence with first-in first-out demand queue
Short answer
Run four hopper gates from a FIFO demand queue and a proof-gated motion sequence: convey only while the selected gate proves open and the other three prove closed, drop conveying on demand clear, and release the gate coil only after the conveyor stops. Set each gate travel timer to valve travel time plus a measured allowance and fault if proof is late.

On this page
- How do I sequence four hoppers so feeding runs first come, first served?
- Why does a demand light not decide which hopper fills next?
- What goes into the FIFO queue and when do entries move?
- Which conditions must be true before conveying turns on?
- When does conveying drop and the gate coil release?
- How long should the gate travel timer run before a fault?
- What do the two proximity sensors prove and what do they not prove?
- How do I test the sequence before material runs?
- Questions asked
Four spring-return gate valves, one conveyor, and a first-come, first-served rule call for two separate PLC functions: a first-in, first-out demand queue that remembers arrival order, and a proof-gated motion sequence that conveys only while the selected gate proves fully open and the other three prove fully closed, each endpoint watched by its own two proximity sensors. When a demand clears, drop the conveying command first and release the gate coil only after the conveyor has stopped, so the spring closes the gate under a dead material line. The sections below follow the sequence in the order you commission it: queue mechanics with arithmetic, the conveying permissive, the shutdown order, the travel timer, the proof inputs, and the test list.
How do I sequence four hoppers so feeding runs first come, first served? #
Split the job into two functions that share no logic: a first-in, first-out queue that remembers the order demands arrived in, and a proof-gated motion sequence that lets only the queued hopper's gate travel and permits conveying only after every position proof agrees.
The queue answers who feeds next; the state machine answers what that hopper may do. Only one gate may own the system at a time, the same one-at-a-time rule the motor interlock logic for three one-at-a-time motors page applies to motors, and the queue head is the only input through which ownership reaches the state machine.
The motion side lives in six states:
- Idle: conveying off, every coil off, the head selected only after all four gates prove closed.
- Opening: the selected coil energized, conveying blocked while that gate travels.
- Filling: conveying permitted only while the demand stays present and every proof input agrees.
- Stopping: the conveying command removed, the coil still held while the conveyor stops.
- Closing: the coil released, the spring drives the gate closed, conveying blocked until closed proof returns.
- Fault: conveying off, the fault latched until the proofs agree again.
You can hold the same six states in a table instead of rungs; a table-driven PLC valve sequencer keeps each transition in one data row, which makes the order easy to audit.
Decision: one queue decides ownership, one state machine decides motion, and neither reads the other's bits except at the handoff.
Why does a demand light not decide which hopper fills next? #
A demand input only raises a request; the queue decides ownership, so four start rungs scanned in a fixed order hand the system to the first rung every scan and hold Hopper 1 forever even when Hopper 3 asked first.
Capture the rising edge of each demand so an input held ON for a hundred scans cannot refill the queue, and append the hopper number only when that hopper is neither active nor already waiting. Four seal-in bits feeding a priority selector remember requests but destroy arrival order, and the classic symptom is two waiting hoppers feeding in the wrong sequence. If a waiting demand clears while its entry waits, delete the stale entry and inspect the next one; a request that vanished while its command survived is the same failure mode as a stuck HMI valve command after a lost release.
Decision: edge-capture each demand, deduplicate, and write the tie-break order into the program comments; whatever the scan picks is not a queue.
What goes into the FIFO queue and when do entries move? #
The queue stores one hopper number per new demand in arrival order, sized to four positions for four hoppers, one active entry plus three waiting, appending at the tail on a demand rising edge and releasing the head only after that hopper proves closed.
IEC 61131-3 gives ladder the edge-detect and move instructions this queue needs, and most platforms add a ready-made queue or shift instruction on top; the four-place size is not arbitrary, because it is one active entry plus one position per waiting hopper.
Worked example, with illustrative values: Hopper 1 raises demand at t = 0 s, Hopper 2 at t = 40 s, Hopper 3 at t = 95 s. The three rising edges append 1, then 2, then 3, so the register reads head 1, 2, 3 with one position still free. Hopper 1 finishes and its gate proves closed at t = 160 s; its entry leaves at the head, the others shift forward, and the queue reads head 2, 3. Hopper 3 waited 160 - 95 = 65 s yet still feeds after Hopper 2, which is the arrival-order guarantee the queue exists to make.
After a power cycle every coil is off and the springs should have closed every gate. Accept queue entries only after all four gates prove closed with open proof OFF; any gate showing open ON or both inputs ON at power-up goes straight to Fault and waits for an operator acknowledgment. Do not restore a retained queue until those proofs are clean.
Decision: append on the rising edge, release the head only on closed proof, and treat power-up as Idle until four closed proofs agree.
Which conditions must be true before conveying turns on? #
Conveying switches on only when one rung sees every permissive at once: the queue head's demand still active, the selected gate's open sensor ON, that gate's closed sensor OFF, and all three other gates each showing closed ON with open OFF.
Keep that permissive in one rung so a later edit cannot quietly bypass a position check, and decode the queue head so exactly one gate coil output can energize; add a mutual-exclusion rung that faults the instant two gate commands are ON together.
|--[ STATE_FILLING ]--[ HEAD_DEMAND ]--[ SEL_OPEN_PV ]
--[/ SEL_CLOSED_PV ]--[ GT_A_CLOSED_PV ]--[ GT_B_CLOSED_PV ]
--[ GT_C_CLOSED_PV ]--------------------( CONVEYOR_RUN )--|
The tag names are illustrative; map them to your project convention. The rung must drop if the demand clears, the state leaves Filling, either selected-gate input changes state, or any nonselected gate loses its closed proof, the same closed-proof discipline applied in closed-limit feedback for two dock doors.
Decision: conveying is the AND of every proof, and there is no second conveying output anywhere else in the program.
When does conveying drop and the gate coil release? #
Conveying drops the instant the demand clears, the state leaves Filling, or any proof input disagrees; the selected gate coil releases only after the conveyor has actually stopped, so the spring closes the gate under a dead material line.
The Stopping state holds the coil while the conveyor spins down: on a drive-fed conveyor use the drive's stopped signal or its documented coast interval, not a guessed number of seconds. Closing starts only after that, the coil drops, and the spring does the closing; Closing is complete when the closed sensor is ON and the open sensor is OFF, and only then does the head entry leave the queue for the next demand.
These rungs are a process interlock against jammed material; personnel protection such as guards and emergency stop is specified by the machine risk assessment. IEC 60204-1's fail-safe principle shapes the design the same way: the safe state is reached by de-energizing, which is exactly what releasing the coil does on a spring-return valve.
Decision: conveyor stops first, coil releases second, closed proof third; that order is not adjustable.
How long should the gate travel timer run before a fault? #
Set each gate timer from that valve's documented full-travel time plus a measured commissioning allowance and fault when it expires without proof; a gate documented at 5 s travel with a 2 s allowance gets a 7 s preset.
Read the travel time from the actuator documentation, then earn the allowance in commissioning: time several unobstructed full travels with the conveyor isolated, take the worst cycle, and round the margin up to a whole second. A slower gate presets proportionally higher, its own travel time plus the same allowance. Common library valve-interlock blocks carry an open and closed echo delay in seconds that you set per valve, because two valves on one machine rarely travel alike.
Worked example, with illustrative values: a gate documented at 5 s full travel measures a 4.6 s worst case in commissioning, so the margin rounds up to 2 s and the preset is 5 s + 2 s = 7 s. Proof arriving at 6.8 s passes; proof at 7.2 s never arrives, because the fault tripped at 7 s.
On expiry, drop the conveying command, latch a gate-travel fault, and release the coil so the spring takes the gate to the contained position. The queue keeps its remaining entries; when the faulted gate finally proves closed with open proof OFF, an operator acknowledgment returns the sequence to Idle and the head is read again.
Decision: no proof inside the timer means mechanical trouble or a dead sensor, so stop material, latch the fault, and let the spring close the gate.
What do the two proximity sensors prove and what do they not prove? #
Each input proves an endpoint only while it is ON: open proof means open ON with closed OFF, and a de-energized coil proves nothing, because a blocked spring-return valve can sit partly open with both sensors dark.
Valve position sensing exists to verify, in real time, that the valve reached its commanded open or closed state, which is why these proof inputs and not the coil command gate the conveyor. Classify the impossible combinations deliberately: if the valve documentation declares a valid overlap band near an endpoint, fix that band from the documentation and commissioning and accept inputs inside it; otherwise open ON with closed ON is a position fault, and neither input ON past the travel timer is the second fault case.
A coil-off indication is never closed proof; the Closing state and the power-up check therefore insist on live closed proof, not on the memory of a released coil.
Decision: the two inputs must agree with the commanded state; both ON, neither ON, or proof late are faults, not waits.
How do I test the sequence before material runs? #
Test every transition with the conveyor isolated and the sensors operated by hand or by the actuator alone, watching one state bit at a time; a sequence that only passes with forced outputs has never been tested.
- No demands: every coil OFF, conveyor OFF, and all four gates report closed ON with open OFF.
- One demand: exactly that coil energizes, and conveying stays OFF through the entire travel.
- Operate the selected open sensor by hand: conveying starts only when selected open is ON, selected closed is OFF, and the other three closed proofs are ON.
- With hopper 1 filling, raise hopper 2, then hopper 3: neither waiting gate moves, and the queue holds 1, then 2, then 3.
- Clear hopper 1's demand: the conveying command drops first, the coil releases only after the stopped condition, and hopper 2 leaves the queue only after hopper 1 proves closed.
- Inject each fault case, open proof missing, closed proof missing, both ON, and neither ON past the timer, and confirm conveying drops and the fault latches on every one.
Run the list before material flows and after every edit to the queue or the permissive rung. The design reduces to one chain, and every link is testable from the panel: the queue head owns the system, proof inputs own the motion, the stopped conveyor owns the gate release, and any disagreement anywhere stops material before it can jam.
Questions asked
What happens when two hoppers demand in the same PLC scan?
Inputs that rise inside one scan have no real chronology, so the program has to impose one. Resolve same-scan demands in a documented order, for example a fixed input order from Hopper 1 through Hopper 4, and record that order in the program comments. The tie-break is arbitrary; leaving it to scan luck is not, because a later code edit can reverse it silently and change which hopper feeds first.
What happens if a fifth hopper demands while three are already waiting?
A four-position register holds one active entry plus three waiting entries, so a fourth waiting request has nowhere to go. Reject the fifth demand with an operator annunciation rather than overwrite an entry, or enlarge the queue register and retest the shift logic before the change reaches the machine. The right size is the hopper count plus any units you plan to add later.
Do the gate interlocks need safety-rated I/O?
The open, closed, and conveying rungs here are process interlocks that protect material flow, not personnel. Whether guards, emergency stops, or the gate itself need safety-rated hardware comes from the machine risk assessment. If that assessment calls for a rated function, ISO 13849-1 grades it as a Performance Level and IEC 62061 as a Safety Integrity Level; the two ratings are separate and are not interchangeable.
What does the queue do when a gate faults mid-fill?
Drop the conveying command at once, release the gate coil so the spring drives the gate closed, and latch the fault until that gate proves closed with its open proof OFF. Later queue entries stay in place and wait. Resume only after an operator acknowledges the fault, and only if the head entry's demand is still active; if the demand cleared during the fault, remove that entry and read the next one.


