Siemens LOGO! OBA7 Clock Variable Workaround Using VM Counters

David Krause12 min read
PLC HardwareSiemensTechnical Reference
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

Overview: The LOGO! OBA7 Clock Variable Limitation

The Siemens LOGO! OBA7 is positioned as a nano-PLC for OEM and small-machine control. Its real-time clock is fully functional for scheduled switching (astronomical timer, weekly timer, yearly timer), but unlike a S7-1200 or LOGO! 8.3, the OBA7 firmware does not expose the RTC hour, minute, or second as a numeric variable that can be read into a VW (Variable Word) and compared in a ladder diagram. Engineers who try to do something equivalent to VW1 := RTC_HOUR; will find the address list in LOGO! Soft Comfort V7 (LSC V7) does not contain an RTC tag. The complete function-block reference is documented in the LOGO! 8 System Manual on Siemens Industry Online Support.

This article documents the three field-proven workarounds for capturing and comparing time values inside a LOGO! OBA7 program:

  1. Data logging with the integrated SD-card slot or internal log buffer.
  2. A custom hour counter built from a one-second pulse generator plus up/down counters, stored in the 850-byte variable memory (VM).
  3. The built-in operating hour counter (OHC) block.
The VM area in the OBA7 generation is 850 bytes. This is the working RAM that survives a power cycle when the program is saved to the LOGO! base module. A battery card (LOGO! Battery Card 6ED1057-1BA00-0BA0) extends retention further.

Why Direct RTC Access Is Restricted in LOGO! OBA7

LOGO! is a logic module, not a soft-PLC. Its firmware only exposes the RTC indirectly through dedicated function blocks: weekly timer, yearly timer, astronomical clock, and stopwatch. The internal RTC registers are not mapped into the variable memory. When the LSC V7 program editor shows the address pool, only the following tag types are selectable:

  • Digital inputs I1...I24 (depending on base + expansion count)
  • Digital outputs Q1...Q20
  • Analog inputs AI1...AI8
  • Analog outputs AQ1...AQ2
  • Flag bytes M1...M64 (or higher in later firmware)
  • Variable memory VW0...VW849 (in 16-bit word increments)
  • Network inputs/outputs NI/NQ for LOGO! 8.1+

There is no VW_RTC_HOUR tag. The clock value is consumed only by the scheduling blocks. To compare the hour-of-day against a setpoint such as 17:30, you must either:

  • Configure a weekly timer set to 17:30 whose output bit drives a comparison branch, or
  • Reconstruct an hour counter yourself and load it into a VW.

This is why the search "LOGO! store current time in VW1" returns a question mark: the operation has to be synthesized, not read. The hardware overview and tag limits are summarized on the Siemens LOGO! product page.

LOGO! OBA7 System Architecture and VM Memory Layout

Resource OBA7 Specification Notes
Variable Memory (VM) 850 bytes Bytes VW0..VW849; user-defined bytes consume from low address up
Program Memory (Flash) 8,000 blocks typical Function-block count, not bytes
Remanence All VM bytes optional Set "Retentive = on" per byte in LSC V7
Scan cycle ~0.6 ms per 1k instructions Affects maximum counter pulse rate
RTC drift +/-2 s/day typical, +/-5 s/day max Without SNTP sync
SNTP sync Yes (LOGO! base with Ethernet) Polled hourly by default
SD card Up to 32 GB microSD, FAT32 Holds data log CSV files

For a counter-based workaround, only three VM words are needed: VW1 (hour count, 0..23), VW2 (comparison setpoint), and VW3 (minute count, 0..59). The rest of VM remains free for application I/O. Retentivity must be enabled for VW1 and VW3 if the OBA7 is expected to ride through short power dips and resume counting from the saved value.

A 16-bit word in LOGO! stores unsigned integers 0..65535. To wrap at 24 (hours) or 60 (minutes-of-hour), use the counter's reset input or include a comparator that triggers a self-reset.

Workaround A: Data Logging with Internal Memory and SD Card

The simplest path is to stop trying to compute the hour inside the program and instead let the firmware write a timestamped CSV. Configure a Data Log block in LSC V7:

  1. Open the LSC V7 project, drag the Data Log block onto the FBD sheet (Tools > Data Log Configuration).
  2. Select destination: Internal memory (one file, last ~16,000 records) or SD card (continuous, one file per power cycle).
  3. Set the sampling trigger: cyclic (1 s, 1 min, 1 h) or event-driven on a flag edge.
  4. Choose columns: time stamp (firmware-injected), your process value (e.g., kWh register), optional state word.
  5. Save the project and transfer to the OBA7.

The CSV on the SD card looks like this:

Timestamp, kWh_total, load_state
2024-03-12 14:23:01, 12455, 1
2024-03-12 14:24:01, 12458, 1
2024-03-12 14:25:01, 12461, 1

This is the recommended approach for electrical-consumption logging. You get the hour and minute "for free" because the firmware writes them, and the values can be pulled into a PC for graphing, peak detection, and time-of-use tariff analysis.

Destination Records retained Readout Survives power cycle?
Internal memory ~16,000 LSC V7 > Tools > Data Log Viewer Yes, ring-buffered
SD card Card capacity Card remove → PC Yes, new file per cycle
If the OBA7 is in RUN when the SD card is removed, logging pauses and the buffered records flush when the card is re-inserted. Do not hot-unplug while the green RD/WR LED is lit.

Workaround B: Building a Synchronous Hour Counter in VM

If the application needs the hour value inside the LOGO! program - for example to switch loads on/off, to compute time-of-day tariffs, or to write to a display - the recommended approach is to build a counter chain that mirrors the RTC behavior closely enough for control purposes. Three blocks are required:

  1. A pulse generator set to 1 s on / 0 s off (or use the on/off delay of a flag).
  2. A up/down counter preset to 60, counting each pulse, with its output wired to a counter-reset pulse generator for the next stage.
  3. A second counter preset to 24, incrementing on each minute rollover.

The hours counter's current value is then available as its CV (current value) output, which can be routed into a VM word by adding an Analog Multiplexer or, more simply, by using the counter's CV display that the HMI/LOGO! TD reads directly.

Pulse Generation

Use a Pulse Generator (clock generator) block with T = 1 s, duty 50%, output wired to the count input of a Up/Down Counter preset to 60. The counter output is the minute pulse (one high-going edge per minute).

Counting Chain

1 Hz pulse -> [Counter C_min] preset 60, CV -> VW3
                |
                +-- on Q (CV=60) pulse 1 cycle, then reset C_min to 0
                    |
                    v
                    [Counter C_hour] preset 24, CV -> VW1
                |
                +-- on Q (CV=24) pulse 1 cycle, then reset C_hour to 0

The reset of each counter is self-triggered by its own Q output through a one-cycle delay (or by routing Q through an OR with the count enable so that the next clock edge rolls the value from preset back to 0).

Synchronizing to the Real RTC

The chain above will drift relative to wall-clock time because the LOGO! oscillator is not temperature-compensated and the cycle time is added to the 1 s period. To align, two options exist:

  • SNTP sync (Ethernet base): enable SNTP client, set poll interval to 1 h. On each poll the firmware nudges the counter by adjusting the next 1 s pulse. This is not a direct injection into your counter; you still need a manual calibration block.
  • Calendar tick from a weekly timer: configure a one-minute-once weekly timer on every day, connect its output to reset C_min and increment C_hour. This gives you minute resolution matched to the firmware clock.
If the OBA7 loses power, the custom counter resets to 0 unless VW1 and VW3 are flagged retentive in LSC V7. Even with retention, the value will be off by however many minutes/hours the controller was de-energized. Plan a manual reset on a known time-of-day event (e.g., a weekly timer firing at 00:00:01 Sunday) to snap C_hour back to 0 once per week.

Ladder Logic Implementation - Counter Chain Design

The FBD implementation in LSC V7 is straightforward. The equivalent ladder representation, useful for engineers familiar with RSLogix, is shown below. The four rungs map directly to LOGO! function blocks.

Pulse 1 Hz (BL_1s) C_min (preset 60) CV -> VW3 (0..59) C_hour (preset 24) CV -> VW1 (0..23) Comparison branch (rung 3) IF VW1 >= VW2 THEN Q1 = 1 (load enable during target hours) IF VW1 < VW2 THEN Q1 = 0 (load shed outside target hours) VW2 = setpoint loaded from LOGO! TD or HMI as unsigned 16-bit word Rung 4: Weekly timer Sun 00:00:01 --> reset C_hour := 0, C_min := 0

The "Analog Threshold Trigger" or "Analog Comparator" block in LSC V7 can be used to do the comparison directly, with VW1 on input AX and VW2 on input AY, output Q1 switching on the configured relation (>, <, =, <>).

Using the Built-in Operating Hour Counter

LOGO! OBA7 includes an Operating Hour Counter block (in the Special Functions library). It counts the cumulative hours that its trigger input has been high and exposes the elapsed time as a 16-bit value. This is not the time-of-day, but it is the right answer if your goal is to log the duration of a specific event (e.g., compressor run-time per shift).

Parameter Range Default
Preset (threshold) 0..65535 h 0
Time base Hours (fixed) Hours
Retentive Yes/No Yes
Output Q bit when CV >= preset --

For a factory-load-scheduling application the OHC is rarely the right block; it measures duration, not clock time. Use it in combination with a daily-reset flag if you need shift counters.

Power-Cycle and Synchronization Considerations

The OBA7 RTC is maintained by a super-capacitor for several days and indefinitely if the optional battery card is fitted. After a power cycle:

  • The firmware RTC continues at the correct wall-clock time (the super-cap or battery holds it).
  • The custom counter chain in VM restarts at 0 unless its VM bytes are configured as retentive. Even with retention, the count is offset by the down time.
  • The data log file on the SD card is closed and a new one is opened, named with the new power-on timestamp.

For a tight sync between the firmware RTC and your VM counters, schedule a "snap" event once per day. In LSC V7:

  1. Insert a Weekly Timer block.
  2. Configure it for Every day, 00:00:00 to 00:00:01.
  3. Wire its Q output to a Set/Reset block that forces VW1 := 0 and VW3 := 0.

The chain then resets to midnight once per day and counts up from there. Worst-case drift between two snap events is bounded by the LOGO! oscillator accuracy, typically a few seconds per day.

If the OBA7 is in STOP/STOPPED mode, the cycle pulse stops, but the firmware RTC keeps running. Re-insert RUN and the chain resumes from its last VM value, not from wall-clock time. Always perform a system restart by going STOP → RUN only when the timer is intentionally being zeroed.

Verification and Commissioning

To prove the chain is working, run through this checklist on the bench or on-site before integrating with the load:

  1. Set the LOGO! internal clock to 23:59:55 via LOGO! menu or LSC V7 online > Set Clock.
  2. Force the controller into RUN.
  3. Open LOGO! TD or the on-board display and observe VW3 (minutes). It should increment by 1 every 60 s and roll over at 60.
  4. Observe VW1 (hours). It should increment by 1 each time VW3 rolls over, and roll over at 24.
  5. Set VW2 to a value between 1 and 23 and verify Q1 (or your chosen output) goes high when VW1 >= VW2.
  6. Trigger a power cycle for at least 5 s and verify the retentive VM bytes retain their values; non-retentive bytes reset to 0.
  7. Verify the daily-snap weekly timer fires by changing the LOGO! clock to 23:59:55 on day 2 and confirming VW1 returns to 0 at the configured snap moment.

For a data-log-only application, verification is simply opening the SD card CSV and confirming timestamps match the LOGO! on-board clock. Drift test: read the timestamp at start of shift, read again after 24 h, subtract. With SNTP, drift should be < 1 s; without, expect +/-2 to +/-5 s/day.

When to Migrate Beyond LOGO! OBA7

The OBA7 is a competent micro-controller, but for applications that need direct RTC register access, structured text programming, or a global namespace of time tags, a step up is justified:

Requirement LOGO! OBA7 capability Alternative
Read RTC hour as integer Indirect (counter chain) S7-1200 with RD_SYS_T / WR_SYS_T in SCL
Time-of-use tariff scheduling Limited (weekly timers) LOGO! 8.3+ with structured text or S7-1200
Sub-second time stamping of events Not possible (scan-time bound) ET200S with IM151 and S7-1500
Event log with millisecond resolution SD card CSV, 1 s resolution S7-1500 with syslog or OPC UA

For an electrical-consumption manager on a factory floor, the LOGO! OBA7 + data log combination is genuinely sufficient, and a migration is only justified if the application needs real-time tariff switching at sub-hour resolution or billing-grade audit logs. Power-supply sizing for the OBA7 itself: 12/24 V DC at 1.5 W typical, 3.0 W max with full expansion rack, so the controller does not need a separate UPS if the SD-card log is the audit trail.

FAQ

Can I read the LOGO! OBA7 real-time clock hour directly into VW1?

No. The OBA7 firmware does not expose the RTC as a numeric tag. You must either build a counter chain in VM (workaround B in this article) or use the firmware-injected time stamp from the data log block.

What is the size of the variable memory in LOGO! OBA7?

850 bytes (VW0..VW849), each byte optionally retentive. Three words (VW1, VW2, VW3) are sufficient for a full hour/minute counter chain, leaving 847 bytes for the application.

How do I keep the VM hour counter synchronized with the wall clock after a power cycle?

Set VW1 and VW3 as retentive and schedule a weekly timer for 00:00:00 to 00:00:01 that resets both counters. The firmware RTC keeps wall-clock time across power cycles via the super-capacitor or optional battery card.

Is the data log CSV timestamp accurate to the second?

Yes, but only if the LOGO! internal clock is set correctly. The CSV is generated by the firmware; if the clock drifts (typical +/-2 s/day without SNTP), the drift shows in the timestamps. Enable SNTP on an Ethernet-equipped base module to keep drift under 1 s.

Can the built-in Operating Hour Counter replace my custom hour counter?

Only if you need cumulative run-time of an input. The OHC measures elapsed hours of a high signal, not time-of-day. For time-of-day scheduling, use a counter chain or weekly timers.

Back to blog