Developing Custom Module Drivers and Channel Drivers Using the PCS 7 Driver Generator

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

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:

  1. <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 input LADDR.

  2. <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.

  3. <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:

Macro ElementScope / PurposeReturned Data TypePractical Usage in Custom Driver Rule<AUTATTRVAL>Reads a single named hardware propertyString / Hex / IntegerFetching LADDR, DIAG_ADDR, slot number, or baud rate<AUTATTRARRAY>Loops through an array of sub-objectsObject collectionIterating over all active channels on a 16-channel digital card<AUTATTRSTRUCT>Queries nested hardware recordsStructured objectAccessing PROFINET submodule identification and port diagnostics<AUTCONNECT>Defines interconnection targetInterconnection linkBinds output DXCHG of MOD_ block to input DataXchg of channel block<AUTPARAM>Assigns static or calculated valueConstant / VariableSets parameter ACC_MODE or sample time on the diagnostic driver<AUTCONDITION>Evaluates logical prerequisitesBoolean (True/False)Verifies if module is parameterized for 4-20mA HART or raw analog

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:

  1. 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. Pcs7AnIn FB1869 or custom channel block CustomAnIn).
    - Ensure the block source headers contain the mandatory system attributes: S7_driver := 'true', S7_tasklist := 'OB100,OB82,OB86'.

  2. 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>

  3. 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\).

  4. 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).
    - Select Chart -> Compile -> Changes only with Generate module drivers enabled.
    - Confirm that the compiler automatically creates system chart @..., places MOD_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

  1. 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.
  2. 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.
  3. 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

Related Articles

Related Tags

  • Driver Generator
  • AUTATTRVAL
  • AUTATTRARRAY
  • Module Drivers
  • Basis Library
  • CFC Compilation
6 respuestas