1. Overview: Replacing End Switches with Time-Based Logic
End-of-travel detection on a moving belt normally uses mechanical limit switches or proximity sensors wired in series with the motor contactor coil. When a customer explicitly forbids any new sensor on the machine, the PLC must emulate the two end-of-travel contacts using only time. This article describes how to program a Siemens LOGO! 8 (0BA8) logic module to act as a virtual top-of-travel and bottom-of-travel limit switch using an Up/Down counter with retentive memory. The technique is designed for the common case of asymmetric travel — 25 seconds up, 16.5 seconds down — caused by gravity loading on a lifting belt.
The program uses three LOGO! function blocks: a self-running asynchronous pulse generator (B008) to clock the counter, the Up/Down counter (B011) with retentivity enabled, and a threshold trigger (B013) to derive the second virtual limit from the same count value. The output bits of those blocks are wired in series with the contactor coils exactly as if they were real limit switch contacts.
2. Prerequisites
- LOGO! 8 base module with at least 8 digital inputs / 4 relay outputs. Examples: 6ED1052-1MD08-0BA2 (24 V, with display) or 6ED1052-1CC08-0BA2 (24 V, no display). Refer to the Siemens LOGO! product page for the full 0BA8 catalog.
- LOGO! Soft Comfort V8.3 or later installed on Windows 10/11.
- A micro-SD card (max 32 GB, FAT32) for program transfer and backup.
- A 3-position selector switch (UP / OFF / DOWN) wired to two LOGO! digital inputs, e.g. I1 = UP, I2 = DOWN.
- One thermal overload relay on the motor contactor for hard-wired safety stop, independent of the LOGO!.
- Access to the Siemens Industry Online Support portal for the latest LOGO! 8 system manual.
3. Modelling the Asymmetric Belt Travel
The belt travel time differs because of the load:
| Direction | Travel time | Mechanical reason |
|---|---|---|
| Up (load raised) | 25.0 s | Motor lifts against gravity plus payload |
| Down (load lowered) | 16.5 s | Gravity assists; motor mostly brakes |
The first step is to convert each travel time into a counter threshold. With the LOGO! counter time base set to 0.1 s (i.e. 10 ticks per second), the thresholds are simple integers:
- Top-of-travel threshold = 250 (25.0 s × 10 ticks/s)
- Bottom-of-travel threshold = 0 (the counter simply clears at the bottom)
The 0.1 s base fits comfortably inside the 8-bit counter range (0 to 255) and gives ±50 ms of timing accuracy, which is well below the normal motor braking distance.
4. LOGO! Memory and Retentivity
LOGO! distinguishes between volatile and retentive (remanent) data. By default the value of every counter, timer, and flag resets to 0 when the module powers down. To make the virtual limit switch survive a power loss — and remember the belt's net position — retentivity must be enabled for the Up/Down counter block.
Procedure in LOGO! Soft Comfort:
- Double-click the Up/Down counter block (B011) on the FBD sheet.
- In the Block Properties dialog tick the Remanence check box.
- Set the Remanent range = 1 (the count value will be retained).
- Click OK and download the program to the LOGO!.
Retention time depends on the power backup option. With no battery the internal supercapacitor holds retentive values for typically 3 days. With the optional battery module fitted (6ED1052-2MD08-0BA2) the retention time exceeds 20 days. See the LOGO! 8 system manual, section "Retentive memory", for the exact figures applicable to your firmware build.
5. Timer and Counter Blocks Available in LOGO!
| Block # | Function | Used in this design for |
|---|---|---|
| B001 | On-delay timer (TON) | Alternative approach (two-timer) |
| B002 | Off-delay timer (TOF) | Coast-down delay after stop |
| B003 | On/off-delay timer | Pre-trigger warn signal |
| B004 | Retentive on-delay timer | Total run-hour accumulation |
| B008 | Asynchronous pulse generator | 10 Hz clock source for the counter |
| B011 | Up/Down counter with threshold | Net belt position register |
| B013 | Threshold trigger | Derive BOTTOM_LIMIT from counter = 0 |
| B014 | RS flip-flop | Latch UP / DOWN commands |
The Up/Down counter B011 is the heart of the design. Its key parameters for this application:
| Parameter | Setting | Meaning |
|---|---|---|
| On threshold | 250 (× 0.1 s) | Output Q becomes 1 when count ≥ 250 |
| Off threshold | 0 | Output Q returns to 0 when count ≤ 0 |
| Time base | 0.1 s | Each pulse on Cnt = 0.1 s of run time |
| Dir input | UP_LATCH (active low) | 0 = count up, 1 = count down |
| Reset input R | Manual reset pushbutton I3 | Forces count = 0 (e.g. for commissioning) |
6. Solution A — Two-Timer Approach (Quick but Limited)
The simplest way to give the customer "timers as limit switches" is to allocate one on-delay timer to each direction:
- B001a: TON, T = 25 s, triggered by UP_LATCH. Output drives TOP_LIMIT.
- B001b: TON, T = 16.5 s, triggered by DOWN_LATCH. Output drives BOTTOM_LIMIT.
This approach works the very first time the belt travels. It fails as soon as the operator reverses mid-travel, because both timers reset when the command latch drops and the belt position is forgotten. It also cannot survive a power loss.
For these reasons the two-timer approach is acceptable only on machines that always run a complete cycle without reversal. Most lifting belts do not, so the recommended design is Solution B.
7. Solution B — Up/Down Counter with Retentive Memory
The Up/Down counter (B011) integrates net belt travel time. Every 0.1 s of motion in the UP direction adds 1 to the count; every 0.1 s of motion in the DOWN direction subtracts 1. The count value therefore represents the belt's net position from the bottom, regardless of how many reversals happened in between.
Two virtual limit switch outputs are derived from the single count:
- TOP_LIMIT = B011 output Q, asserted when count ≥ 250
- BOTTOM_LIMIT = B013 output, asserted when count ≤ 0
The two virtual bits feed the contactor interlock logic exactly like mechanical limit switch contacts.
8. FBD Implementation
Build the program in LOGO! Soft Comfort as five functional islands.
8.1 Direction latching island
Two RS flip-flops (B014) latch UP and DOWN with hardware-style mutual interlocking. UP and DOWN can never both be active simultaneously.
I1 I2
| |
[B014 RS] [B014 RS]
S = I1 S = I2
R = TOP_LIMIT R = BOTTOM_LIMIT
Q = UP_LATCH Q = DOWN_LATCH
MUX (B019): output = UP_LATCH if NOT(DOWN_LATCH)
else DOWN_LATCH
8.2 Pulse generator island
The asynchronous pulse generator (B008) produces a symmetric 10 Hz square wave. TH = TL = 0.1 s. Output M1 is the clock for the counter's Cnt input.
8.3 Counter island
Inputs of B011:
- Cnt = M1 (the 10 Hz clock)
- Dir = NOT(UP_LATCH), i.e. 0 while moving up, 1 while moving down
- R = I3 (manual reset pushbutton, normally open)
Parameters: On = 250, Off = 0, time base = 0.1 s, remanence enabled, retentive range = 1.
8.4 Threshold trigger island
B013 with On = 0 and Off = 1. Output BOTTOM_LIMIT = 1 whenever the counter is at or below zero.
8.5 Contactor interlock island
UP_CONTACTOR = UP_LATCH AND NOT(TOP_LIMIT) AND NOT(BOTTOM_LIMIT)
DOWN_CONTACTOR = DOWN_LATCH AND NOT(BOTTOM_LIMIT) AND NOT(TOP_LIMIT)
Each AND gate mirrors a real contactor holding circuit with two normally-closed limit switches in series. The belt cannot drive past either virtual limit.
9. Ladder Equivalent
The same logic can be written in LAD if the LOGO! is programmed in ladder view:
Rung 1: | I1 UP_LATCH |
|--| |--+----(S)-----( )---|
| | |
| TOP_LIMIT |
|--|/|--+ |
Rung 2: | I2 DOWN_LATCH |
|--| |--+----(S)-----( )---|
| | |
| BOTTOM_LIMIT |
|--|/|--+ |
Rung 3: | UP_LATCH TOP_LIMIT Q1 (UP contactor)|
|---( )--------|/|-------( )-------------|
Rung 4: | DOWN_LATCH BOTTOM_LIMIT Q2 (DOWN)|
|---( )--------|/|------------( )----|
10. State Machine Visualization
The complete application reduces to a four-state machine:
Each transition fires on a single Boolean condition. The state machine guarantees that the belt can never be commanded UP while it is at the top, or DOWN while it is at the bottom.
11. Wiring Diagram
Note: the E-Stop, overload relay, and any existing mechanical limit switches remain in series with the contactor coil, completely outside the LOGO!. The LOGO! only replaces the customer-requested timer-based top/bottom limit.
12. Edge Cases and Safety Considerations
12.1 Mid-travel power loss
If mains power is lost while the belt is moving, the counter stops at its current value. Because it is retentive, motion resumes from the same value after power returns. The direction latch is deliberately volatile, so a power loss always leaves the machine in STOPPED state — no surprise re-start.
12.2 Belt stalled by overload
If the belt stalls because the overload trips, the counter continues to count even though the belt is not moving. To detect this, wire the overload contact to a digital input and use a second B013 threshold trigger with On = 50 to suppress the count (or latch an alarm) when the motor is not actually turning.
12.3 Drift over many cycles
Each cycle accumulates up to 0.5 pulse of drift if the stop is initiated on the very first pulse that crosses the threshold. With a 0.1 s time base this is ±50 ms, equivalent to ±25 mm at 0.5 m/s belt speed. Tighter accuracy requires a shorter time base at the cost of counter range.
12.4 Count underflow
If the operator holds DOWN_LATCH while count = 0, the counter clamps at 0 and does not wrap negative. The B013 output stays at 1, so the DOWN contactor is held off — exactly the desired behaviour.
12.5 Direction signal inversion
If you accidentally wire the raw I1 (UP) instead of the latched UP_LATCH into the Dir input, the counter will pause on every release of the pushbutton. Always derive Dir from the latch, never from the raw input.
13. Verification and Commissioning
-
Offline simulation: in LOGO! Soft Comfort press
F5. Drag I1 high and verify the counter increments at 10 Hz. Confirm Q1 (UP contactor) drops exactly when the count reaches 250. - Online monitor: connect the PC via Ethernet, switch to Online → Online monitor. Confirm real-time values match simulation.
- Direction toggle test: command UP for 10 s, then DOWN for 5 s. The counter should settle at 50 (half-way between 0 and 250). If it does not, the Dir input polarity is inverted.
- Retentivity test: drive the belt mid-travel, power the LOGO! off for 60 s, restore power. The counter must resume at the same value; if it resets, check the Remanence flag.
- Stop-position accuracy: mark the belt with a felt-tip pen and run 20 cycles. Stop position should be reproducible within ±5 mm at the take-up pulley.
- Asymmetry verification: time the actual upward and downward motions with a stopwatch. Upward should be 25.0 s ± 0.5 s, downward 16.5 s ± 0.5 s. Adjust the threshold values if the measured times drift.
- Loss-of-power test: with the belt mid-travel, pull the disconnect. After 60 s restore power and verify the belt does NOT start moving on its own.
14. Troubleshooting Matrix
| Symptom | Likely root cause | Corrective action |
|---|---|---|
| Belt drives past the virtual top | Counter threshold set to seconds instead of 0.1 s ticks | Re-enter threshold as 250 (for 25 s × 10) |
| Belt stops short of the top | Pulse generator time base mis-set | Verify B008 TH = TL = 0.1 s |
| Belt restarts after power loss | Direction latch marked retentive | Clear Remanence on B014 blocks |
| Counter resets on every power cycle | Remanence not enabled on B011 | Tick Remanence, set range = 1 |
| Count drifts negative | DOWN_LATCH held while count = 0 | Confirm B013 Off threshold = 1 prevents further decrement |
| Both contactors energize together | Missing UP/DOWN interlock | Add NOT(DOWN_LATCH) on UP rung and vice versa |
| Timer counts while motor is off | Clock wired to B011 Cnt input directly | AND the clock with motor contactor aux contact |
15. Alternatives Worth Presenting to the Customer
Time-based limits are inherently the least accurate solution. If at all possible, even a single inductive proximity sensor at one end of the belt, combined with a mechanical cam, will outperform timers by orders of magnitude in repeatability. An incremental encoder on the drive shaft feeding the LOGO!'s high-speed counter (I3/I4 on a 0BA8) gives absolute position without drift.
For background on timer/counter design in embedded systems, the Digi-Key article "Using Timers and Counters to Create Efficient MCU-based Designs" is a useful reference on edge-triggered counting, prescalers, and overflow handling — concepts that translate directly to the LOGO! Up/Down counter.
If the customer truly insists on time-based limits, document the limitations clearly in the operating manual and tag the cabinet with a warning label such as:
"Virtual limit switches — accuracy ± 1 s. Do not approach the belt during operation. Mechanical E-Stop must remain active."
16. Frequently Asked Questions
Can a single LOGO! timer replace both up and down limits?
No. A standard on-delay timer (B001) is direction-blind and would need extra logic to decide whether to count 25 s or 16.5 s. The Up/Down counter (B011) with retentivity is the simplest single block that handles asymmetric travel in one register.
Does the counter retain its value across a power loss?
Yes, provided the Remanence box is checked in the block properties and the LOGO! has either a battery installed or a fully charged internal supercapacitor. Retention is typically 3 days without battery and 20+ days with the optional battery module.
What time base should I pick?
Use 0.1 s for travel times of 5–25 s — the 8-bit counter then covers 0–25.5 s, which matches typical belt travel. Use 1 s for travel times above 30 s, and 10 ms only for sub-second movements such as pneumatic indexing.
Why not just use two separate on-delay timers?
Two on-delay timers work for a simple start-stop but cannot remember the belt's net position across an UP-then-DOWN sequence. The retentive Up/Down counter acts as a true integrating position register and recovers the correct virtual limit even after multiple reversals and a power cycle.
How accurate is the stop position?
With a 0.1 s time base the stop can drift up to 100 ms of belt travel. On a 0.5 m/s belt this is ±50 mm. Tighter accuracy requires a shorter time base (at the cost of counter range) or a real sensor such as an encoder or proximity switch.