Implementing Daily and Monthly Energy Totalizers with APL TimeTrig in PCS 7

Implementing Daily and Monthly Energy Totalizers with APL TimeTrig in PCS 7

Implementing automated daily, monthly, and shift energy consumption calculations in SIMATIC PCS 7 V8.1 using the Advanced Process Library (APL) is achieved by combining the totalizer block TotalL (FB1906) with the scheduling trigger block TimeTrig (FB1845) and memory sample blocks (ShMemory). Rather than constructing complex custom clock logic with comparators, TimeTrig natively generates precise calendar pulses at specified hours (e.g., 00:00 or 08:00) and days of the month. Connecting this trigger to sample-and-hold storage blocks freezes the completed period's consumption (Yesterday / Last Month) while simultaneously resetting the active TotalL accumulator via RstLi to begin the current cycle.

Table of Contents

Architecture of Periodic Energy Accounting in PCS 7

Industrial energy management systems require continuous accounting of utility consumption partitioned into standardized operational intervals: Today's Consumption, Yesterday's Consumption, Current Month, and Last Month.

Engineers implementing this in SIMATIC PCS 7 frequently attempt to write custom S7-SCL or CFC logic using date/time extraction functions (SFC1 READ_CLK), equality comparators, and manual resets. While functional, custom clock routines often fail during leap years, daylight saving time adjustments, or CPU clock synchronizations.

The SIMATIC PCS 7 Advanced Process Library provides a standardized, robust framework utilizing the TimeTrig (FB1845) block paired with TotalL (FB1906) and sample memory storage blocks.

Role and Configuration of the APL TimeTrig Block

The TimeTrig block generates boolean trigger pulses based on the controller's real-time clock according to pre-configured scheduling rules:

TimeTrig Operating ModeParameter ConfigurationTrigger Timing / BehaviorFunctional ApplicationDaily TriggerDayMode = 1, Hour = 0, Minute = 0Fires single pulse every day at 00:00:00Freezes Daily Total; resets Today's TotalShift TriggerMultiple instances or hourly moduloFires pulses at shift boundaries (08:00, 16:00, 00:00)Shift consumption handover reportsMonthly TriggerMonthMode = 1, Day = 1, Hour = 0Fires single pulse on the 1st day of each monthFreezes Monthly Total; resets Month TotalWeekly TriggerWeekMode = 1, WeekDay = 1 (Sunday)Fires single pulse on designated day of weekWeekly electrical utility accounting

TimeTrig automatically compensates for varying month lengths (28, 29, 30, 31 days) and evaluates leap years accurately from the CPU system calendar, eliminating clock rollover edge cases.

Integrating TotalL and Sample-and-Hold Memory Logic

To implement a complete Today / Yesterday and Current Month / Last Month energy structure in CFC:

  1. Active Integration via TotalL:
    - Place TotalL in cyclic interrupt OB35 (100 ms).
    - Configure Mode = 1 (Feature.bit6 = 1, Continuous Integrator).
    - Set integration reference time TI = 3600.0 s (assuming power in kW to yield kWh).
    - Interconnect instantaneous power (PAC3200.ActPwr) to TotalL.In.
    - Output TotalL.Out.Value continuously represents Today's Consumption (kWh).
  2. Yesterday Storage via Sample-and-Hold:
    - Insert an analog sample memory block (ShMemory / SampleHold).
    - Connect TotalL.Out to the input of ShMemory.
    - Connect the daily trigger pulse output from TimeTrig.Out to the store command of ShMemory.
    - The stored output represents Yesterday's Total (kWh).
  3. Resetting Active Accumulator:
    - Route TimeTrig.Out through a single-cycle delay or direct rising-edge connection to TotalL.RstLi.
    - At exactly 00:00:00, ShMemory captures the cumulative value, and TotalL resets to 0.0 to begin the new day.
  4. Replicate for Monthly Accounting: Replicate the identical architecture in a companion chart using a monthly TimeTrig instance to manage Current Month and Last Month totals.

WinCC Report Designer and Daily Energy Logging

To export daily energy records automatically into executive reports:
1. In WinCC Explorer, open Report Designer -> Layouts.
2. Create a daily energy production report layout (e.g., Daily_Energy_Report.rpl).
3. Insert dynamic I/O fields linked to the archived tags representing Yesterday's Energy and Last Month's Energy.
4. In WinCC Print Jobs, configure the report to trigger automatically when TimeTrig.Out transitions to 1, outputting a signed PDF to a network archive share.

Verification

To verify energy totalizer and trigger operation:
1. In CFC, open the chart containing TimeTrig online in test mode.
2. Parameterize TimeTrig to fire 2 minutes in the future; monitor the pulse output Out.
3. Confirm that upon reaching the trigger minute, TimeTrig.Out asserts for exactly one execution cycle.
4. Verify that ShMemory accurately latches the totalizer value and that TotalL.Out.Value resets to zero.
5. In WinCC Runtime, open the energy dashboard; confirm that Today and Yesterday fields display distinct, non-zero values.

Limitations and Operational Precautions

Ensure the execution sequence in CFC is ordered correctly: the sample-and-hold block (ShMemory) must execute before the totalizer reset logic (TotalL.RstLi) within the same OB execution slice. If the totalizer is reset first, ShMemory will latch zero instead of the completed daily total. Always verify block execution order in the CFC Runtime Editor (Edit -> Run Sequence).

Engineer FAQ

Can TimeTrig handle daylight saving time transitions without duplicate triggers?

Yes, provided the S7 CPU system clock is synchronized to UTC or standard time via SICLOCK/NTP with proper timezone offsets configured in Hardware Configuration.

What happens if the PLC loses power across midnight?

If the CPU is powered off during the midnight transition, the pulse from TimeTrig will not execute. To handle power interruptions across day boundaries, incorporate timestamp comparison logic or utilize WinCC Tag Logging compression.

Does TotalL maintain its cumulative value during CPU warm restart?

Yes. When parameterized with Feature.bit0 = 1 (Set startup characteristics), TotalL retains its accumulated value in retentive memory across CPU restarts.

Technical References

Related Articles

Related Tags

  • TimeTrig
  • TotalL
  • Energy Accounting
  • APL Blocks
  • Periodic Reporting
6 respuestas