Tracking Motor Operating Hours with CountOh and Exporting Shift Reports to Excel in PCS 7
To track motor operating hours during an operating shift in SIMATIC PCS 7, use the Advanced Process Library (APL) block 'CountOh' (FB1864) interconnected to the motor run feedback signal ('FbkRunOut' of MotL). Shift resets are performed by pulsing the 'RstLi' or 'RstOp' inputs at shift changeover. Because the AS controller cannot generate native Excel files, automated shift reporting to Microsoft Excel or CSV is implemented at the OS layer using SIMATIC Information Server, WinCC DataMonitor, or scheduled WinCC VBScripts writing archived tag values to disk.
Table of Contents
- Executive Summary
- Architecture and Fundamental Mechanics
- Step-by-Step Implementation Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
Tracking motor operating runtime and switching cycles per shift is a standard requirement in continuous and batch process plants. In SIMATIC PCS 7 (V8.0 through V9.1), runtime tracking is handled in the automation controller via the APL function block CountOh (FB1864), which accumulates running hours and cycles with millisecond precision. However, automation controllers do not support native file system operations to write Excel (.xlsx) or CSV workbooks. This article provides the complete implementation architecture: parameterizing CountOh in CFC, executing automated shift resets, and configuring supervisory reporting options in WinCC, DataMonitor, and SIMATIC Information Server.
Architecture and Fundamental Mechanics
Runtime Counting and Supervisory Reporting Architecture:
- Controller Layer (
CountOh- FB1864 Mechanics): - The APL Operating Hours Counter block (
CountOh) is placed in a cyclic interrupt OB (e.g. OB35 / 100ms). - Input
Trackis connected directly to the motor run feedback (FbkRunOutofMotL,MotRevL, orMotSpdCL). WhenTrack = TRUE, internal timers accumulate run duration. - Outputs
Hours(REAL, hours) andCount(DINT, switching cycles) provide live values to the OS. -
Reset Mechanics: Two distinct reset mechanisms exist. Operators can reset counters from the OS faceplate (
RstOp = 1), or an automated PLC signal (such as a time-of-day trigger block or SFC pulse) can triggerRstLi = 1. An internal edge evaluator captures the pulse, stores final shift values, and resets the counters to zero. -
Architectural Boundary between AS and Reporting:
- S7-400 / CPU 410 controllers are deterministic real-time execution engines. They do not have file system drivers to create or manipulate Office files.
-
Shift data generated by
CountOhmust be logged to WinCC Tag Logging on the OS Server or Process Historian, where enterprise reporting engines process and format the data. -
Excel Reporting Technologies in PCS 7:
1. SIMATIC Information Server: Siemens' premier web-based reporting platform integrated with Process Historian. Generates scheduled automated shift reports in Excel or PDF format based on pre-configured templates.
2. WinCC DataMonitor: Web-based reporting package with an Excel Workbooks Add-In. Automatically queries WinCC runtime archives on a shift schedule and writes populated Excel spreadsheets to a network share.
3. WinCC Global Script (VBScript): A script running on the OS Server triggered by a shift-change binary tag. It queries the runtime tag, formats a timestamped line, and appends it to a.csvfile via WindowsScripting.FileSystemObject.
Step-by-Step Implementation Procedure
Step-by-Step Implementation Procedure for Motor Runtime Tracking and Reporting:
- Instantiate and Interconnect
CountOhin CFC:
- Open the CFC chart containing the motor block (e.g.MotL).
- InsertCountOh(FB1864) from the APL library into the chart.
- InterconnectMotL.FbkRunOuttoCountOh.Track.
- Interconnect a shift reset trigger bit (generated by a timer block such asTimeTrigor system clock logic) toCountOh.RstLi. - Configure Block Parameters:
- Set parameterFeature.Bit1if external reset requires pulse authorization.
- Parameterize high warning limits (HoursHiLim) if preventive maintenance alerting is desired. - Configure WinCC Tag Logging on the OS Server:
- Compile the OS from SIMATIC Manager to transferCountOhtechnological tags (Hours,Count,FbkRunOut).
- In WinCC Explorer, open Tag Logging.
- Create a Cyclic-Selective or Event-Triggered Archive for the motor runtime tag to record the value right before each shift reset. - Configure Shift Export in WinCC (VBScript Method for CSV/Excel):
- In WinCC Explorer, open Global Script -> VBS-Editor.
- Create a new project action triggered by the shift change binary tag:
vbscript Dim fso, file, logPath, motorHours, motorTag, dtNow logPath = 'D:\ShiftReports\MotorRuntime_' & Year(Now) & Month(Now) & Day(Now) & '.csv' motorHours = HMIRuntime.Tags('Mot101_CountOh/Hours.Value').Read Set fso = CreateObject('Scripting.FileSystemObject') If Not fso.FileExists(logPath) Then Set file = fso.CreateTextFile(logPath, True) file.WriteLine('Timestamp,MotorTag,ShiftRunningHours') Else Set file = fso.OpenTextFile(logPath, 8, True) End If file.WriteLine(Now & ',Mot101,' & motorHours) file.Close
- Save the action and activate Global Script Runtime in the OS Server startup list. - Configure Information Server / DataMonitor (Enterprise Method):
- If SIMATIC Information Server is installed, open the Web Management interface.
- Create an Excel Report Template bound to the motor runtime archive tag.
- Set up an automated schedule: trigger every 8 hours at shift change (e.g. 06:00, 14:00, 22:00) with automatic email or folder delivery.
Verification
Verification Procedure:
1. Controller Verification: In CFC Test Mode, simulate motor running (FbkRunOut = TRUE). Verify that CountOh.Hours increments steadily.
2. Shift Reset Verification: Pulse CountOh.RstLi. Confirm that CountOh.Hours resets to 0.0 while total lifetime hours (if mapped) remain intact.
3. File Export Verification: Trigger the shift event on the OS Server. Check the destination directory (e.g. D:\ShiftReports\). Open the generated .csv or .xlsx file and confirm the timestamp, tag name, and motor runtime are recorded accurately.
Limitations and Operational Precautions
Operational Precautions and System Boundaries:
- S7-300 / CPU 315 Incompatibility: The APL CountOh block relies on S7-400 system function blocks (SFBs) and is strictly unsupported on S7-300 / CPU 315 hardware. For S7-300 controllers, custom IEC timers or Standard Library blocks (TIMETICK) must be used.
- VBScript File Access Guardrails: In multi-user or redundant OS environments, file I/O scripts must include error handling (On Error Resume Next) to prevent script engine hangs if network drives or files are temporarily locked by another user.
- Process Object Licensing: CountOh is an APL block that consumes one AS Process Object (PO) when compiled into the OS.
Engineer FAQ
Which PCS 7 block counts motor operating hours?
The Advanced Process Library (APL) block CountOh (FB1864) counts operating hours and switching cycles.
Can the S7-400 PLC write directly to an Excel file on a network PC?
No. S7-400 and CPU 410 controllers do not possess file system drivers or network SMB client stacks to write .xlsx files. Reporting must be handled at the WinCC OS, DataMonitor, or Information Server layer.
Can I run CountOh on an S7-300 CPU 315 controller?
No. CountOh requires S7-400 system functions and is not executable on S7-300 CPUs. Standard STEP 7 timer logic must be used instead.
How do I reset CountOh hours at the end of a shift without losing total lifetime hours?
Use CountOh.RstLi to reset shift hours. Total lifetime hours can be tracked simultaneously by instantiating a second un-reset CountOh block or archiving the reset increments in WinCC.
What software is recommended for automated enterprise Excel reporting in PCS 7?
SIMATIC Information Server (integrated with Process Historian) or WinCC DataMonitor are Siemens' recommended enterprise reporting solutions.
Technical References
- SIMATIC Process Control System PCS 7 Advanced Process Library (APL) Manual
- WinCC DataMonitor System Manual
- SIMATIC Information Server System Manual
Related Articles
- Distinguishing SIMATIC PDM Licenses from Maintenance Station Engineering and Runtime Packages
- Managing S7-400 Local Data Stack Allocation and Resolving CFC Compilation Exhaustion
- Implementing Redundant Analog Input Channels with Pcs7AnIn in SIMATIC PCS 7 V9.0
Related Tags
- CountOh
- Operating Hours
- APL
- WinCC Reporting
- Information Server