Developing Custom Module Drivers and Channel Drivers Using the PCS 7 Driver Generator
Developing custom module drivers and channel drivers for new PROFINET IO or PROFIBUS DP devices in SIMATIC PCS 7—enabling the Driver Generator ('Generate module drivers' during CFC compile) to automatically instantiate diagnostic blocks and interconnect channel drivers—requires authoring structured XML rule files within the PCS 7 Driver Generator framework. These XML rules evaluate hardware definitions using macro tags such as <AUTATTRVAL> (reads scalar hardware attributes), <AUTATTRARRAY> (iterates over hardware arrays), and <AUTATTRSTRUCT> (queries structured module records). The official guidelines and attribute specifications are documented in the Siemens manual 'SIMATIC PCS 7 Basis Library - Driver Concept'.
Table of Contents
- PCS 7 Driver Generator Architecture and Automated Diagnostics
- XML Rule Structure and Macro Syntax (, )
- Comparison of Driver Generator Macros and Attribute Query Methods
- Step-by-Step Procedure to Integrate Custom Field Devices with Driver Generator
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
PCS 7 Driver Generator Architecture and Automated Diagnostics
A foundational strength of SIMATIC PCS 7 is its automated diagnostic concept governed by the Driver Generator Wizard (Generate module drivers during CFC compilation). In standard STEP 7 engineering, commissioning engineers must manually program Organization Blocks (OB82 diagnostic alarm, OB83 pull/plug, OB85 program error, OB86 rack failure) and manually interconnect hardware status words to technological blocks.
In PCS 7, the Driver Generator automatically parses the compiled HW Config database, instantiates necessary hardware diagnostic blocks (such as MOD_1, MOD_D8_PN, RACK, SUBNET, OB_BEGIN), places them into appropriate cyclic and interrupt runtime groups, and binds the logical address (LADDR) and diagnostic sub-slot parameters to channel blocks (Pcs7DiIn, Pcs7AnIn).
When third-party OEMs or sensor manufacturers develop proprietary PROFINET/PROFIBUS field devices that must integrate seamlessly into PCS 7, they must provide a custom Driver Library adhering to the official Siemens driver concept.
XML Rule Structure and Macro Syntax (, )
The Driver Generator uses an extensible rule engine driven by XML configuration files located within the project's driver rules repository. These rules tell the compiler how to identify the hardware (via GSD/GSDML Vendor ID and Device ID) and how to bind block parameters using dynamic macro attributes:
-
<AUTATTRVAL>(Attribute Value):
- Queries a single scalar hardware attribute from the compiled hardware database.
- Example:<AUTATTRVAL Object="Module" Name="LADDR"/>retrieves the logical base I/O address of the submodule and writes it directly to the block inputLADDR. -
<AUTATTRARRAY>(Attribute Array Iteration):
- Iterates through repeating elements, such as multiple submodules in a modular field device or multiple channel groups.
- Evaluates each channel's diagnostic status register dynamically across the card. -
<AUTATTRSTRUCT>(Attribute Structure Query):
- Traverses hierarchical hardware structures, querying properties across Rack -> Slot -> Subslot -> Channel.
- Example: Navigating from a PROFINET interface module down to a specific 4-channel analog input slice.
Comparison of Driver Generator Macros and Attribute Query Methods
The following table compares the macro tags utilized by the PCS 7 Driver Generator XML rule engine:
<AUTATTRVAL>LADDR, DIAG_ADDR, slot number, or baud rate<AUTATTRARRAY><AUTATTRSTRUCT><AUTCONNECT>DXCHG of MOD_ block to input DataXchg of channel block<AUTPARAM>ACC_MODE or sample time on the diagnostic driver<AUTCONDITION>Step-by-Step Procedure to Integrate Custom Field Devices with Driver Generator
Follow this procedure to develop and integrate custom driver rules into SIMATIC PCS 7:
-
Develop Custom Function Blocks in SCL:
- Create the hardware diagnostic block (e.g.MOD_CustomPN, FB1200) designed to handle OB82/OB86 interrupts.
- Create or assign the channel driver block (e.g.Pcs7AnInFB1869 or custom channel blockCustomAnIn).
- Ensure the block source headers contain the mandatory system attributes:S7_driver := 'true',S7_tasklist := 'OB100,OB82,OB86'. -
Author the XML Driver Rule File:
- Create an XML file named according to the device specification (e.g.CustomDevice_Rules.xml).
- Define the hardware match criteria matching your device GSDML:
xml <Device Type="PROFINET" VendorID="0x002A" DeviceID="0x0102"> <ModuleDriver Type="MOD_CustomPN"> <Parameter Name="LADDR" Value="<AUTATTRVAL Object='Module' Name='LADDR'/>"/> <Parameter Name="DADDR" Value="<AUTATTRVAL Object='Module' Name='DIAG_ADDR'/>"/> </ModuleDriver> </Device> -
Register Rule in PCS 7 Driver Repository:
- Place the compiled blocks into the project's Master Library.
- Copy the XML rules into the PCS 7 system driver folder (C:\Program Files (x86)\Siemens\Step7\S7CFG\DriverRules\). -
Compile and Test Driver Generation:
- In HW Config, insert the custom field device and configure I/O submodules.
- In CFC, place a channel block connected to the device's peripheral input address (PIW 512).
- SelectChart -> Compile -> Changes onlywith Generate module drivers enabled.
- Confirm that the compiler automatically creates system chart@..., placesMOD_CustomPN, and wires all diagnostic pins.
Verification
Verify automated driver generation in CFC:
1. Open the compiled chart folder in SIMATIC Manager. Confirm the presence of automatically generated system charts prefixed with @.
2. Open the system chart and locate the instantiated MOD_CustomPN block. Confirm that LADDR and DADDR match the hardware addresses assigned in HW Config.
3. Verify that the output DXCHG or diagnostic status word is interconnected with a green line to the channel driver block.
4. In the CFC compile log, confirm that 0 errors are reported and the device identification matches the XML rule specification.
Limitations and Operational Precautions
- Never Manually Alter
@System Charts: Modifying block placements or interconnections manually inside charts prefixed with@violates PCS 7 design rules. The next CFC compilation will overwrite manual changes. - Interrupt Organization Block Handling: Custom module drivers must correctly acknowledge hardware interrupts in OB82 and OB86. Failing to clear the interrupt register will cause the S7-400 CPU to crash into STOP mode upon fault detection.
- Version Migration Compatibility: Custom XML driver rules are tied to specific PCS 7 Basis Library versions. When upgrading from PCS 7 V8 to V9, custom driver rules must be re-validated against the updated compiler schema.
Engineer FAQ
Where is the official documentation for the PCS 7 Driver Generator?
The architecture and macro syntax are documented in the manual 'SIMATIC PCS 7 Basis Library - Driver Concept' and the 'PCS 7 Programming Guide - Creating Driver Blocks' available via Siemens Industry Online Support.
What does the S7_driver := 'true' attribute do in SCL?
The attribute S7_driver := 'true' informs the CFC compiler and Driver Wizard that the compiled Function Block is a hardware diagnostic driver, prompting the driver generator to evaluate it during the 'Generate module drivers' compilation phase.
Can I use standard Pcs7AnIn channel blocks with my custom module driver?
Yes, provided your custom module driver outputs the standard diagnostic status signals and quality codes expected by Pcs7AnIn (such as DataXchg, MODE, and channel fault bits).
Technical References
- SIMATIC Process Control System PCS 7 Basis Library (V9.0) Manual (A5E39222238-AA)
- SIMATIC PCS 7 Driver Generator Architecture and Programming Guide (Entry ID 24249116)
- SIMATIC S7-400 Automation System Module Data Manual (A5E00850741-08)
- Siemens Industry Online Support FAQ: Developing custom channel drivers in PCS 7 (Entry ID 109748892)
Related Articles
- Optimizing Module Driver Generation and Communication Job Limits in PCS 7 CFC
- Integrating Third-Party IO-Link Masters and Transmitters via PROFINET into SIMATIC PCS 7
- Behavior of QBAD and Diagnostic Alarms During Simulation on PCS 7 Channel Blocks (CH_AI and Pcs7AnIn)
- Troubleshooting Persistent Analog Input (AI) Channel Faults (QBAD / Bad Signal) in PCS 7
Related Tags
- Driver Generator
- AUTATTRVAL
- AUTATTRARRAY
- Module Drivers
- Basis Library
- CFC Compilation