Siemens LOGO! 8: Measuring Time Between Digital Input Pulses

David Krause12 min read
HMI ProgrammingSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Problem Overview

A 24 V photoelectric sensor sends a short pulse each time its light beam is broken. The application is not interested in the pulse width; it must capture the interval between pulses and write each interval as one row in a CSV file on the Siemens LOGO! 8 (6ED1052 series) controller. A naive on-delay timer would only measure the time the input is active, which is what a 24 VDC PNP sensor shows when the beam is made. The fix is an off-delay timer held reset while the input is active, with a positive-edge trigger feeding the Data Log function block.

This reference covers the entire path from hardware selection through CSV export and field troubleshooting. It assumes the application is non-SIL, run at 24 VDC, and that intervals are between 1 ms and several hours.

Terminology: "Inter-pulse interval" = the period during which the digital input is low, measured from one rising edge of the input to the next rising edge. With a PNP dark-on sensor, a broken beam corresponds to a low output, so the low interval is exactly what the off-delay measures.

Prerequisites and Hardware Reference

Confirm the following before wiring:

  • LOGO! 8 base module with display, firmware FS:04 or later (FS:06 acceptable, adds 32-bit timestamps). Earlier releases lack the Data Log function block.
  • LOGO! Soft Comfort V8.3 or later for offline programming. The free tool is downloadable from Siemens support entry 109766026.
  • MicroSDHC card 2–32 GB formatted FAT32 (SanDisk Industrial or Kingston Industrial recommended).
  • 3-wire PNP photoelectric sensor capable of switching 24 V DC.
  • 24 V regulated power supply sized for the LOGO! plus the sensor plus all loads.
  • PC running Windows 10 or 11 plus either a USB A-B cable or an Ethernet patch lead.
LOGO! part number Order code Digital inputs Outputs Best fit
LOGO! 12/24 RCE 6ED1052-1MD08-0BA1 8 (4 high-speed) 4 relay 10 A Default pick — relay outputs, 24 V DC
LOGO! 24 RCE 6ED1052-1CC08-0BA1 8 4 solid-state 0.3 A Need fast solid-state outputs
LOGO! 230 RCE 6ED1052-1FB08-0BA1 8 AC 4 relay Use only with AC sensors
LOGO! DM8 12/24 6ED1052-2MD08-0BA1 4 4 relay I/O expansion (not required for base project)

Verify firmware revision on the LOGO! display: ESC → Diagnostics → Module Information. The FS:xx string is shown on the screen. If FS < 04, the Data Log block is unavailable; upgrade the firmware first. The official upgrade procedure for the LOGO! 8 family is documented in entry 109751400, the LOGO! 8 system manual.

Sensor Wiring and Power Budget

PNP sensor wire LOGO! 12/24 RCE terminal Function
Brown / +24 V "24 V" on power input block Sensor supply
Blue / 0 V "M" terminal Common ground
Black / output I1 Digital input (high when beam made)

The input filter default of 1.5 ms is fine for normal photoelectric sensors. Raise it (Tools → Options → Filter) only when long cable runs are picking up radiated noise. The digital input signal response time of any industrial controller, including the LOGO! 8 and also documented by NI as "the total time it takes to charge or discharge line load capacitance, propagate the signal to the user counter", is dominated by the firmware scan cycle rather than by hardware, so for inter-pulse measurement in the seconds range the difference between a standard and a high-speed input does not matter.

Component Current at 24 V
LOGO! 12/24 RCE base module 40 mA typ / 200 mA peak
LOGO! display 25 mA
Each PNP sensor 15 mA typ
Energised relay coil up to 70 mA each

A Siemens SITOP 6EP1332-1LB10 (24 V / 5 A) gives comfortable headroom and can be specified on the system cabinet BOM.

Logic Design and Time Base

Block diagram

I1 NOT Off-delay To AM1 AM1 (seconds) Edge ↑ Data Log PULSE.CSV microSD

FBD program in LOGO! Soft Comfort

  1. Drop I1 from the toolbar onto the diagram.
  2. Insert an Inverter block (B01). Drive its input from I1.
  3. Insert an Off-delay (TOF) timer (B02) and set Ta = 24:00:00.000 so it never times out on its own. The B01 output feeds the Enable input of B02.
  4. Insert an Analog Memory Marker AM1 and wire the running output of B02 into AM1. AM1 will be the "low time" measurement.
  5. From I1 again, drive the Enable input of a Positive-Edge block (B03). Set Ta = 0.05 s for software debounce.
  6. Insert a Data Log block (B04). Wire the B03 output into its Enable input.
  7. Wire the B03 output also back to the Reset input of B02 through a second inverter. That clears AM1 right after every log write so the next value reflects only the next interval.

Time base selection

The Off-delay block accepts a time parameter with a configurable base unit. For interval logging in seconds, set the project time base to seconds (Tools → Options → Time Base = Second). The AM1 value is then in seconds already.

Time base AM1 unit Recommended when
Second seconds Intervals ≥ 1 s
Millisecond milliseconds Intervals in the 10–100 ms range
1/100 s centiseconds European convention

Data Log Block Configuration

The Data Log function block (BF) was added in firmware FS:04. It writes one comma-separated row per trigger event into a CSV file under SD:\log\.

Parameter Setting Purpose
Buffer Count 16 Records kept in RAM between flushes
Force Flush ON One write per record
Time Stamp RTC timestamp Adds a leading column with absolute date-time
Logged Variable 1 AM1 The interval value
File Name PULSE.CSV Stored at SD:\log\PULSE.CSV
Rows per File 4096 Rotates to PULSE_1.CSV
Cyclic Mode OFF Event-driven only
  1. Right-click the Data Log block → Block Properties.
  2. Buffer Count = 16, Force Flush = ON.
  3. Tick Use time of day.
  4. Click Select Variables, pick AM1, confirm.
  5. File name = PULSE.CSV, Rows per File = 4096.
  6. OK. Wire the Enable input from the B03 Positive-Edge output.
Why Buffer Count = 16? Each buffered record survives a transient card disconnection of up to 16 events without loss. Force Flush ON minimises the window of buffered data at the cost of slightly higher wear on the SD card. Industrial-grade SD cards tolerate at least 10× the LOGO! write workload; consumer cards may fail earlier. Set up an annual card-replacement in the maintenance plan.

Program Download and CSV Export

USB download

  1. Connect USB cable between PC and the LOGO! front USB port.
  2. In LOGO! Soft Comfort, click PC → LOGO!.
  3. Choose USB in the connection dialog.
  4. Select Download Program (Stop CPU); the LOGO! halts briefly and re-enters RUN.
  5. Confirm Yes when prompted to upload the project file to the microSD.

Ethernet download

  1. Set a fixed IP via the LOGO! menu: ESC → Settings → Network.
  2. Connect an Ethernet patch cable from PC to LOGO!.
  3. In Soft Comfort, choose Ethernet and enter the LOGO!'s IP.
  4. Same download dialog as USB above.

The download procedure for the LOGO! 8 family including the supported IP ranges is documented in the FS:04 release manual entry on Siemens Industry Online Support.

Reading the CSV file

Option A — remove the microSD card. Power the LOGO! down (or briefly Stop CPU), eject the card, insert into a PC card reader, and open PULSE.CSV from the log folder. A typical layout looks like:

"Time";"Pulse (s)"
"06/12/2024 09:14:31";"30"
"06/12/2024 09:15:13";"42"
"06/12/2024 09:16:12";"59"

Option B — LOGO! Web Server. Enable the Web Server (Access Protection → Web Server = On), browse to http://<LOGO_ip>, default password LOGO, click the Data Log tab, choose the file, and click Download. No card removal required.

Option C — LOGO! Access Tool. Install the free LOGO! Access Tool. Connect to the LOGO! via Ethernet, open the Data Log tab, right-click on the file, choose Export to CSV. Destination is Documents\LOGO!\AccessTool.

Neither the Web Server nor the Access Tool requires removing the card. Always export remotely first, only fall back to card removal if the live channel is unavailable. Ejecting under power is the leading cause of corrupt CSV files on LOGO! 8.

Diagnostic Display and Verification

For local commissioning, configure the LOGO! display so AM1 is visible without traversing the menu:

  1. From the LOGO! front panel: ESC → Display → AM.
  2. Pick AM1; toggle to Show.
  3. Back out; the home screen reads AM1 in seconds and updates once per scan.

Optional diagnostic extension — flag M01 "Logging active":

  1. Insert an OR block driven by the Write Done output of B04 (the Data Log block).
  2. Wire OR output into a Status Marker; show on the home screen as an indicator.

Acceptance checklist

  • I1 status LED on the LOGO! toggles within 50 ms of the beam breaking.
  • AM1 increments on the display while the beam is broken, freezes when the beam is made again.
  • One line is appended to PULSE.CSV for every cycle.
  • CSV intervals match a stopwatch within ±5 ms (millisecond base) or ±0.5 s (second base).
  • Web Server Data Log viewer is reachable from a LAN PC.
  • Card may be removed and reinserted without losing the project or pulse series.
  • After 4096 rows, file rotation to PULSE_1.CSV occurs without operator action.

Troubleshooting Matrix

Symptom Likely cause Corrective action
AM1 stays at zero Inverter wired backwards Verify inverter input = I1, output to TOF Enable
AM1 counts continuously Self-reset path broken Re-wire B02 output back into its Reset
Every entry logs twice Both edges trigger Data Log Use Positive-Edge block, not raw I1
CSV file empty Data Log not enabled or card missing Check Diagnostics → SD Card; reseat card
Value off by 1000 Time-base mismatch Set Tools → Options → Time Base = Second
"Parameter write failed" on download Firmware below FS:04 Update firmware
Web Server shows no Data Log files Web Server disabled Enable Web Server in Access Protection
Card "locked" message Mechanical SD lock engaged Slide the lock switch up
CSV header row missing on second file Force Flush ON every event Header is first row after each boot, not per file
Intervals missing after reboot Buffer not flushed before power-off Force Flush ON; consider external UPS
Values > 65535 lose precision Signed 16-bit integer overflow Switch to Float; or reduce time base
Sensor LED lit but no LOGO! input Mis-wired sensor (PNP vs NPN) Verify brown = 24 V, blue = M, black = I1

Comparative Methods and Migration

Approach Block count CSV output Sub-10 ms Best for
Off-delay + Data Log (this article) 4–6 Yes Marginal Default for sensors logging in seconds
On-delay measures high time only 1 Optional Good Pulse width, NOT interval
Shift Register + Display 3 No Good Rolling average shown on LOGO! display
Pulse Generator averaged over cycle 2 No No Quick approximation, no DB
S7-1200 High-Speed Counter 5 Yes Yes Higher-end controllers, scan time < 1 ms

Migration to LOGO! 8.4 (FS:06)

LOGO! Soft Comfort V8.4 added Double Word unsigned / signed 32-bit logging with Unix-time millisecond timestamps. The CSV gains a leading column that simplifies cross-day analysis. The block-diagram logic above is fully portable, only the Data Log configuration dialog needs to be reconstructed in the new tool version.

Migration to S7-1200

If the application outgrows the LOGO! platform (more than 8 inputs, faster scan time, integration with plant historians), the equivalent S7-1200 logic uses:

  • %I0.0 wired to a High-Speed Counter (HSC) configured for period measurement.
  • HSC captured value on every rising edge written to a retentive tag.
  • HMI data log records the tag at 1 Hz, exporting CSV via WinCC Runtime.

Retention is automatic in S7-1200 (the tag stays alive through power-cycles), eliminating the SD-card dependency.

Operating Limits and Field Tips

Cycle-time bandwidth

The minimum reliably detectable interval is determined by the LOGO! scan time. With the program above, scan time on a 6ED1052-1MD08-0BA1 is 2–3 ms.

Event rate Scan load Reliability
1 pulse / 1 s < 10 % Excellent
1 pulse / 100 ms ~30 % Good with high-speed inputs
1 pulse / 10 ms ~95 % Marginal, expect dropped edges
1 pulse / 1 ms — Not feasible

Memory card choice

Card type Endurance Recommended
SanDisk Industrial 4 GB SDHC High Yes
Kingston Industrial 8 GB SDHC High Yes
Generic consumer microSD Lower Acceptable for low event rates
SDXC 64 GB+ Not supported in FS:04 No

Field-proven tips

  1. Mount the photoelectric sensor on a vibration-isolated bracket; contact bounce on a loose bracket is the most common cause of "extra" log rows.
  2. Use shielded 3-wire cable and ground the shield at the cabinet side only. Unshielded runs in long cable trays will produce false edges.
  3. Configure the LOGO! onboard time of day before enabling the Data Log; otherwise the first rows carry a 1970-01-01 timestamp because the RTC was never set.
  4. Periodically export the CSV via the Web Server rather than removing the SD card; "safe remove" is not part of the LOGO! firmware.
  5. Set up an annual card-replacement task in the maintenance plan. Industrial-grade SD cards typically last 3–5 years in continuous-write applications like this one.
  6. When commissioning, temporarily set Buffer Count = 8 so data flushes more frequently; this gives the engineer rapid visual confirmation that rows are landing as expected.
  7. For dual-channel logging (high time and low time), duplicate the block: one branch through the inverter (low), one without (high). Log both columns in the same Data Log row.
  8. Avoid SDXC > 32 GB; FS:04 cannot mount them and the controller logs an "SD card missing" diagnostic.

FAQ

Can the LOGO! 8 measure inter-pulse intervals down to a few milliseconds?

Yes, when the high-speed digital inputs (I3, I4, I5, I6) of the 12/24 RCE module are used and the project time base is set to milliseconds. The off-delay timer offers 1 ms resolution. The controller scan time is 2–3 ms with the program in this article, so the practical lower limit is around 5–10 ms before aliasing occurs.

Do I need a shift-register block in addition to the Data Log?

Not for this task. The Data Log block in firmware FS:04 stores one CSV row per trigger event automatically. A shift register is helpful only when the application needs the last N samples kept in volatile RAM (for instance, a moving average shown on the LOGO! display) and not in a file.

How do I export the CSV without removing the microSD card?

Enable the LOGO! Web Server in Access Protection → Web Server = On, assign a fixed IP, then point any browser at the LOGO! and use the Data Log viewer to download the current CSV. The LOGO! Access Tool does the same over Ethernet without disturbing the SD card.

What is the maximum number of pulse intervals I can log?

With Buffer Count = 16 and Force Flush = ON, the LOGO! writes one CSV line per pulse. The microSD is rotated into files named PULSE.CSV, PULSE_1.CSV, and so on at 4096 rows each. A 4 GB card holds well over a million intervals, subject to the FS:04 rotation limit.

Will this work on a LOGO! 6 or older?

No. The Data Log block exists only on LOGO! 8 (6ED1052 series) running firmware FS:04 or later. Older LOGO! generations (0BA5, 0BA6, 0BA7) lack both the function block and the FAT32 microSD slot that FS:04 expects. Upgrade the LOGO! base module first.

My CSV timestamps keep shifting; is that normal?

It is normal for the millisecond value to drift relative to wall-clock time because the LOGO! internal RTC is not crystal-compensated for the LOGO! 8 family. The drift is typically less than 5 ppm, which is well within the FS:04 specification. If a closer match is required, use the S7-1200 HSC approach instead.

Back to blog