The document describes the process of reading out the Unique Identifier (UID) from a SIMATIC RF1070R reader via serial CMs, specifically using a SIMATIC S7-1200 PLC and a CM1241 RS232 communication module. This setup is designed for RFID-based identification card systems, enabling access control or machine operation based on employee identification cards or user-specific instructions stored on the cards.
Function Description
The core function of this application example is to read the UID from an RFID card using a SIMATIC RF1070R reader and transmit it to a SIMATIC S7-1200 PLC via a CM1241 RS232 communication module. The UID can then be used within the S7 program for various purposes, such as access authorization or sharing information on a machine.
The system comprises an automation system (SIMATIC PLC with a communication interface) and an RFID system (SIMATIC RF1070R reader and an RFID card with UID). The RF1070R reader communicates with the S7-1200 CPU via the CM1241 RS232 communication module using a Freeport protocol. This protocol allows for direct communication without complex telegram structures.
The application example provides a "ReadUID" function block (FB) for the SIMATIC S7-1200 CPU, which handles the entire communication process. This FB is a custom development that simplifies the integration of the RF1070R reader into STEP 7 projects. It is cyclically called in OB1 and automatically manages the point-to-point instructions "Port_Config", "Send_P2P", and "Receive_P2P".
The "ReadUID" function block performs the following actions:
- Configuration of the CM1241 RS232 communication module: Sets up the serial interface parameters.
- Initialization of the RF1070R reader: Prepares the reader for operation.
- Monitoring of the RF1070R reader's antenna field: Detects the presence of an RFID card.
- Selection of the card located in the antenna field: Identifies a specific card for reading.
- Receipt and analysis of the UID: Reads the UID from the selected card.
- Output of status and error messages from the block: Provides feedback on the operation.
The "ReadUID" FB operates through a state machine, progressing through states like "NO_PROCESSING", "PORT_CONFIG", "RESET_READER", "SET_LED", "SELECT_CARD", and "READ_UID". Each state involves specific point-to-point instructions to the reader and waits for a response telegram. For instance, in the "FB_STATE_READ_UID" state, the system requests the serial number (UID) of the card in the reader's antenna field using the "vhl_get_snr" command.
The UID read from the card is stored in a global data block (DB) named "RFData", which contains the "typeRFData" PLC data type. This data type includes fields for the UID (an array of 20 bytes), card type, and various status and diagnostic information from the reader and communication module.
Important Technical Specifications
The system components used in this application example include:
- Power supply: PM1207 (6EP1332-1SH71), providing 24 Volt for S7-1200.
- CPU: CPU 1214C DC/DC/DC (6ES7214-1AG40-0XB0). Other SIMATIC product range CPUs can also be used.
- Communication module: CM1241 RS232 (6ES7241-1AH32-0XB0), version 2.1 onward.
- RFID reader: SIMATIC RF1070R reader (6GT2831-6BA50). Alternatively, a SIMATIC RF1040R reader (6GT2831-6CA50) can also be used.
- RF1000 connection cable: (6GT2891-2UH30) for connecting the reader to the RS232 port.
- Power supply for reader: LOGO!POWER/1AC/DC5V/3A (6EP3310-6SB00-0AY0), providing 5 Volt for RF1070R.
- Engineering software: STEP 7 V16 Professional (6ES7822-1AA06-0YA5).
Communication parameters for the RS232 interface of the SIMATIC RF1070R reader (and CM1241 RS232):
- Transmission speed: 115.2 kbps
- Parity: None
- Data bits: 8
- Stop bits: 1
- Flow control: None
The RF1040R/RF1070R reader has two interfaces: USB and RS232 serial interface. This application example specifically uses the RS232 serial interface.
The "RFData" global data block includes the following structure:
rfData (type typeRFData):
port (Uint): Specifies the communication module used.
cardType (Byte): Type of card in the antenna field.
uid (Array[0..20] of Byte): Serial number of the card in the antenna field.
interface (Struct):
reset (Bool)
enable (Bool)
ndr (Bool)
valid (Bool)
busy (Bool)
error (Bool)
status (Word): Status of the instruction.
diagnostics (type typeDiagnostics):
status (Word): Last status code of the interface parameter "status" of the FB.
subfunctionStatus (Word): Status or returned value from internal instructions or FBs where an error occurred.
stateNumber (DInt): State of the FB's state machine in which the error occurred.
The application uses specific IP addresses for the CPU (192.168.0.1) and the engineering station (192.168.0.10) with a subnet mask of 255.255.255.0.
Usage Features
The application example provides a straightforward method for integrating RFID reading capabilities into an S7-1200 PLC system.
- Simplified programming: The "ReadUID" function block encapsulates the complex communication logic, allowing users to easily implement RFID reading without deep knowledge of the Freeport protocol.
- Flexible configuration: The communication parameters for the CM1241 RS232 can be dynamically parameterized via the user program using the "Port_Config" instruction, overriding hardware configuration settings.
- Clear status and error handling: The "ReadUID" FB provides detailed status and diagnostic information, including error codes for various scenarios (e.g., reader error, port configuration error, send/receive P2P errors, no job processing active, new UID read, card not selected). This facilitates troubleshooting and monitoring of the RFID system.
- Modular design: The use of a function block promotes modularity, making it easier to reuse the RFID reading functionality in different projects.
- Support for various RFID cards: The system is designed to read UIDs from RFID cards, enabling diverse applications such as access control, material tracking, or tool identification.
- Online support: Siemens Industry Online Support provides additional resources, including FAQs, application examples, and product information, to assist users.
Operation sequence:
- Open the OB1 in the STEP 7 project.
- Activate the "enable" input of the "ReadUID" FB.
- The system performs the parameterization of the CM1241 RS232 communication module and resets the RF1070R reader.
- Once the reader is ready, the "enable" input can be set to TRUE.
- The system monitors the antenna field. When a card is detected and selected, its UID is read and stored in the "RFData" data block.
- The "ndr" (new data ready) and "valid" outputs of the "ReadUID" FB indicate when a new UID has been successfully read and is available.
Maintenance Features
- Diagnostic information: The "diagnostics" output of the "ReadUID" FB provides detailed error messages and status codes, which are crucial for identifying and resolving issues. This includes the last status code, subfunction status (indicating where an error occurred within the FB), and the state number of the FB's state machine.
- Online Help: For detailed information on error messages and instructions, users can refer to the Online Help within the STEP 7 software.
- Firmware updates: Regular updates for SIMATIC products are available to address security vulnerabilities and improve functionality. Users are strongly recommended to apply these updates.
- Security recommendations: Siemens provides recommendations for industrial security, including measures to protect plants, systems, machines, and networks against cyber threats. This involves implementing a holistic, state-of-the-art industrial security concept, ensuring secure access to components, and regularly checking for and applying security updates.
- Service and support: Siemens offers various support services, including:
- Industry Online Support: For general questions, FAQs, and product information.
- Technical Support: For specific technical queries and tailored offers.
- SITRAIN – Training for Industry: Global training courses for industry with practical experience.
- Service offer: Includes plant data services, spare parts services, repair services, on-site and maintenance services, retrofitting and modernization services, and service programs and contracts.
- Industry Online Support app: A mobile application for Android and iOS devices to access support information.
The document emphasizes the importance of secure operation and provides links to Siemens resources for industrial security and product updates. It also includes a change documentation section, noting the first edition of the document in 09/2020.