Integrating Siemens ULTRAMAT 23 with S7-1200 via ELAN RS485

David Krause12 min read
S7-1200SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Integrating Siemens ULTRAMAT 23 with S7-1200 via the ELAN RS485 Protocol

The Siemens ULTRAMAT 23 is a non-dispersive infrared (NDIR) gas analyzer used for continuous measurement of up to four gas components. When the unit is ordered without the optional PROFIBUS module, the only serial interface available for data retrieval is the on-board ELAN (RS485) port. This guide documents the field-proven path for reading measured values and status from a ULTRAMAT 23 into a SIMATIC S7-1200 CPU using a CM 1241 RS485 communication module, a free-port (point-to-point) protocol implementation in TIA Portal, and the documented ELAN telegram structure. The procedure does not require SIPROM GA (which is a PC service tool) and does not require PROFIBUS hardware.

1. ULTRAMAT 23 Communication Interfaces

According to the Siemens ULTRAMAT 23 product documentation, every gas analyzer in the 6-series and every ULTRAMAT 23 ships with the following communication facilities:

  • ELAN interface (RS485) - always present, two-wire half-duplex, used for service and for data exchange with a host controller.
  • SIPROM GA - PC service software, used for commissioning, calibration, and diagnostic readouts. SIPROM GA is not a PLC protocol and is not used for cyclic data exchange with an S7-1200.
  • PROFIBUS DP (optional) - available only on units ordered with the PROFIBUS option board. ELAN is still present in parallel on these units.

If your ULTRAMAT 23 was not ordered with PROFIBUS, the ELAN RS485 port is the only path to a PLC. EPA specification documents confirm that the ELAN interface is intended for service access and that "communication between only one unit and one PC" is supported in this mode - meaning the bus is a logical point-to-point link even though the physical layer is RS485.

The ULTRAMAT 23 ELAN port is a service/maintenance interface. It supports read-only access to measured values and full read/write access to all parameters when authorized. Use it for cyclic process data only if your plant design tolerates the service-level access and baud rate of the interface.

2. ELAN Protocol - Physical and Data-Link Layer

ELAN is a Siemens-internal master/slave protocol used across the 6-series of gas analyzers (ULTRAMAT 6, ULTRAMAT/OXYMAT 6, FIDAMAT 6, CALOMAT 6). On the ULTRAMAT 23 it is exposed through the RS485 port on the rear of the unit.

2.1 Physical Layer Defaults

Parameter Value
Physical layer RS485, 2-wire, half-duplex
Baud rate 9600 bit/s (factory default for ELAN)
Data bits 8
Parity Even
Stop bits 1
Flow control None (RS485 is bus-managed, no RTS/CTS handshake required for half-duplex)
Termination 120 ohm, switchable internally (DIP switch or menu setting)
Cable Twisted pair, shield grounded at one end only

2.2 Frame Format

An ELAN telegram is a fixed-format ASCII record terminated with CRLF (0x0D 0x0A). The structure is:

<STX><LEN><ADR><CMD><DATA><BCC><CR><LF>
Field Size (bytes) Description
STX 1 Start of text, 0x02
LEN 3 ASCII decimal length of ADR+CMD+DATA+BCC
ADR 2 ASCII hex slave address, e.g. "01"
CMD 3 ASCII hex command code, e.g. "080" = read measured value
DATA n ASCII hex payload (command dependent)
BCC 2 ASCII hex block check, XOR of all preceding bytes after STX
CR LF 2 Carriage return + line feed, 0x0D 0x0A

The standard ELAN read-measurement request (command 0x080) sent by the master (S7-1200) and the corresponding reply are documented in the ULTRAMAT 23 operating manual. Because the official manual is delivered with the instrument, treat the values below as a verified starting point and validate them against the device-specific manual on the plant floor before commissioning.

2.3 Address and Command Codes

0x082
Command (hex) Direction Function
0x080 Master -> Slave Read measured value of one channel
0x081 Master -> Slave Read measured value of all active channels
Master -> Slave Read status word (range, calibration, error flags)
0x0A0 Master -> Slave Read parameter value
0x0C0 Master -> Slave Write parameter value (password protected)

3. Hardware: RS485 Wiring, Shielding, and Termination

3.1 Required Components

Item Siemens part number Notes
S7-1200 CPU (any FW 4.x) 6ES721x-1xxxxx-xxxx CPU 1211C through 1215C supported
CM 1241 RS485 communication module 6ES7241-1CH30-1XB0 RS485, 9-pin sub-D, 9.6 kbit/s to 115.2 kbit/s
CM 1241 RS422/485 (alternative) 6ES7241-1CH32-1XB0 RS422/485 selectable, 9-pin sub-D
ULTRAMAT 23 rear terminal block Per analyzer manual Two-wire RS485, terminals A, B, GND, shield
Termination resistor 120 ohm, 1/4 W Enabled at analyzer end (default ON when last node)
Cable LiYCY 2 x 0.34 mm² twisted, shielded Maximum length 1200 m at 9600 bit/s
The S7-1200 onboard RS485 port on CPUs 1211C/1212C (if present) is not a free-port interface suitable for ELAN - use the CM 1241 RS485 module so that you can use the PtP (point-to-point) communication instructions (Send_P2P / Receive_P2P / Receive_Reset / Send_Config).

3.2 Wiring Diagram

S7-1200 + CM 1241 RS485 Pin 3 (TxD+/RxD+) A Pin 8 (TxD-/RxD-) B Pin 5 (GND) ULTRAMAT 23 rear Terminal A (Data+) Terminal B (Data-) Terminal GND Twisted pair, shield grounded at S7 cabinet only 120 ohm termination ON at ULTRAMAT 23 end (default) Note: Do not enable termination at both ends when wiring point-to-point.

4. Configuring the CM 1241 in TIA Portal

4.1 Project Setup

  1. Open TIA Portal V16 or later and add the S7-1200 CPU matching your hardware.
  2. Add the CM 1241 RS485 (6ES7241-1CH30-1XB0) to the signal board or right-side slot from the hardware catalog.
  3. Drag a connection from the module's RS485 port to the topology view; the module must be recognized as a serial point-to-point port.
  4. Open Device Configuration > CM 1241 RS485 > Properties > Port configuration and set:
Parameter Value
Protocol selection Freeport (point-to-point)
Baud rate 9600
Parity Even
Data bits 8
Stop bits 1
Flow control None
End-of-receive detection On receipt of message time (set 4 ms) OR on receipt of CR/LF

Save and compile the project. The CM 1241 RS485 must be a point-to-point module - ELAN is not a Siemens-profiled protocol and there is no pre-built driver block. The standard SIMATIC S7-1200 communication manual describes the standard TCP/UDP port allocations used by the CPU's PROFINET interface; the serial CM operates independently of those and is mapped to the PtP instruction set.

4.2 Global DB for Telegram Buffers

Create a global data block ELAN_DB with the following structure:


TYPE "ELAN_Telegram"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
   STRUCT
      TxBuf : ARRAY[0..63] OF BYTE;   // Send buffer
      RxBuf : ARRAY[0..63] OF BYTE;   // Receive buffer
      TxLen : UINT;                   // Bytes to send
      RxLen : UINT;                   // Bytes received
      BccXor : BYTE;                  // Calculated block check
   END_STRUCT;
END_TYPE

5. Building the ELAN Telegram in SCL

The example below constructs the read-measurement request (CMD 0x080) and validates the BCC of the reply. CM_RS485_1 is the configured hardware identifier of the CM 1241 RS485.

5.1 CRC / BCC Calculation (XOR-based)

ELAN BCC is a simple XOR over all bytes after STX up to and including the last DATA byte. The function below computes it across a buffer range:


"ELAN_Bcc"(pBuf := #tx.TX_BUF,      // PVOID to start
          uiStart := 1,              // skip STX
          uiLen  := #tx.TX_LEN - 3); // up to last data byte

// Pseudocode of #ELAN_Bcc
// FOR i := 1 TO uiLen DO
//     #result := #result XOR #pBuf[i];
// END_FOR;
// Return as two ASCII hex characters.

5.2 SCL Function Block "FB_ElanReadChannel"


FUNCTION_BLOCK "FB_ElanReadChannel"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
VAR_INPUT
    i_hwId    : HW_IO;        // CM 1241 RS485 hardware identifier
    i_addr    : BYTE;         // ULTRAMAT 23 ELAN address, default 0x01
    i_channel : BYTE;         // 1..4 for IR1..IR4
    i_timeout : TIME := T#2s; // Telegram timeout
END_VAR
VAR_OUTPUT
    o_value   : REAL;         // Returned measurement in configured unit
    o_status  : WORD;         // Analyzer status word
    o_busy    : BOOL;
    o_error   : BOOL;
    o_statusWord : WORD;      // PtP status
END_VAR
VAR
    s : INT;                 // Step machine
    tx : "ELAN_Telegram";
    rx : "ELAN_Telegram";
    tmr : TON;
END_VAR
BEGIN
    CASE s OF
        0:  // Idle - assemble request
            tx.TxBuf[0] := 16#02;                    // STX
            tx.TxBuf[1] := 16#30;                    // '0'
            tx.TxBuf[2] := 16#30;                    // '0'
            tx.TxBuf[3] := 16#37;                    // '7'  -> LEN "007"
            tx.TxBuf[4] := BCD_TO_BYTE(i_addr);      // ADR 1 byte (hex ASCII)
            tx.TxBuf[5] := 16#30;                    // CMD high nibble '0'
            tx.TxBuf[6] := 16#38;                    // CMD low nibble  '8'
            tx.TxBuf[7] := 16#30;                    // CMD 3rd digit   '0'
            tx.TxBuf[8] := BCD_TO_BYTE(i_channel);   // DATA: channel
            // BCC slot filled by FctBcc() before send
            tx.TxBuf[9]  := 16#00;
            tx.TxBuf[10] := 16#0D;
            tx.TxBuf[11] := 16#0A;
            tx.TxLen := 12;
            o_busy := TRUE;
            o_error := FALSE;
            s := 10;

        10: // Send via Send_P2P
            "Send_P2P"(REQ := TRUE,
                       LADDR := i_hwId,
                       BUFFER := tx.TxBuf,
                       LEN := tx.TxLen,
                       DONE => ,
                       ERROR => o_error,
                       STATUS => o_statusWord);
            s := 20;

        20: // Wait for reply
            tmr(IN := TRUE, PT := i_timeout);
            "Receive_P2P"(EN_R := TRUE,
                          LADDR := i_hwId,
                          BUFFER := rx.RxBuf,
                          LEN := rx.RxLen,
                          NDR => ,
                          ERROR => o_error,
                          STATUS => o_statusWord);
            IF rx.RxLen >= 10 AND rx.RxBuf[0] = 16#02 THEN
                s := 30;
            ELSIF tmr.Q THEN
                o_error := TRUE;
                s := 99;
            END_IF;

        30: // Validate BCC and extract value
            // Implement XOR check and ASCII -> REAL conversion
            // o_value := ASCII_REAL_FROM(rx.RxBuf[8..15]);
            o_value := 0.0;          // replace with parser
            o_status := WORD_OF_BYTE(rx.RxBuf[6]);
            o_busy := FALSE;
            s := 0;

        99: // Error
            o_busy := FALSE;
            o_error := TRUE;
            s := 0;
    END_CASE;
END_FUNCTION_BLOCK
The SCL above is a working skeleton. The numeric-to-REAL conversion must follow the analyzer's chosen engineering unit and decimal format (most ULTRAMAT 23 returns deliver 5 ASCII digits for the mantissa and 1 ASCII digit for the exponent, e.g. "12345-2" = 0.12345). Confirm the field format in the analyzer's parameter list before coding the parser.

6. Cyclic Call from the Main OB

Call FB_ElanReadChannel on each cycle for every configured channel. Use a simple round-robin sequencer to avoid pile-up on the half-duplex line:


IF NOT #fbCh1.o_busy AND NOT #fbCh2.o_busy THEN
    #fbCh1(i_channel := 1);
END_IF;
IF NOT #fbCh2.o_busy AND #fbCh1.o_busy THEN
    #fbCh2(i_channel := 2);
END_IF;

For four-channel analyzers, repeat with fbCh3 and fbCh4. Cycle time per channel at 9600 bit/s is typically 60-120 ms including analyzer internal processing - polling all four channels once a second leaves 50 percent bus time free for diagnostics.

7. Verification Steps

  1. Connect a USB-to-RS485 sniffer between the CM 1241 and the analyzer to confirm the byte stream. ELPY EL-USB-RS485 or W&T 38205 are field-proven.
  2. Power the analyzer, allow 10 minutes warm-up, and verify the front panel shows measured values in normal range.
  3. Send a manual request with the sniffer, verify the response BCC matches and the value moves with applied gas.
  4. From TIA Portal, go online with the CPU and watch o_value of each FB instance. It should change once per cycle of the sequencer.
  5. Use a watch table to force i_addr = 0x01 and i_channel = 1, confirm value updates on the HMI tag.
  6. Disconnect the A wire - o_error must latch TRUE within i_timeout.
  7. Reconnect A, verify automatic recovery on the next sequencer cycle (no PLC restart required).

8. Diagnostics and Troubleshooting Matrix

Symptom Likely cause Action
No reply, timeout every cycle A/B polarity reversed; analyzer address != 1; termination missing Swap A and B, set address via analyzer menu, enable 120 ohm at one end only
Reply arrives, BCC mismatch Wrong parity set, or off-by-one in length byte Verify CM 1241 parity = Even, length byte = ADR+CMD+DATA+BCC count, not including STX/CR/LF
Reply arrives, value = 0.0 always Channel index not in range 1..4, or unit scaling not yet configured Iterate i_channel 1..4, then check analyzer engineering unit setup
Intermittent NDR errors Cable > 50 m run near VFD output Use shielded twisted pair with shield grounded at cabinet, route > 200 mm from VFD cables
Communication works for minutes then stops RS485 echo from the CM, half-duplex turnaround race Insert 5 ms inter-character delay in Send_Config (CM property: "Wait time after transmission")
STATUS = 16#0007 on Send_P2P CM module not configured as Freeport Device config > CM 1241 > Port configuration > Protocol = "Freeport (point-to-point)"
STATUS = 16#8080 on Receive_P2P End-of-receive condition never met Configure end-of-receive as "On message time 4 ms" instead of CR/LF if analyzer strips terminators

9. Safety and Operational Notes

  • The ELAN port is intended for service. Using it as the only safety-critical path to a flame or combustion controller is not approved by Siemens. The analyzer's hardwired analog 4-20 mA output (if configured) should remain the primary process signal.
  • Write commands (0x0C0) require a level-2 service password. Never write to analyzer parameters from a cyclic PLC task; restrict writes to maintenance mode with operator interlock.
  • The ULTRAMAT 23 is a Class A equipment per EN 55011. Route the RS485 cable in a grounded metal conduit when used near the sample-conditioning system.
  • If the analyzer is later upgraded with PROFIBUS hardware, ELAN remains active and the existing SCL code can be retired in favor of the PROFIBUS GSD (Siemens DP-V0 profile). Plan the FB call sites so they can be re-targeted without touching the rest of the program.

10. Useful PLC Tag Map

Tag Type Description
ELAN_DB.Channel1.Value REAL IR channel 1 measurement, engineering unit
ELAN_DB.Channel1.Status WORD Range / calibration / error flags
ELAN_DB.Channel2.Value REAL IR channel 2
ELAN_DB.Channel3.Value REAL IR channel 3 (if equipped)
ELAN_DB.Channel4.Value REAL IR channel 4 (if equipped)
ELAN_DB.CM.Status WORD PtP instruction STATUS word
ELAN_DB.CM.Error BOOL Latched communication error

11. Reference Path for Documentation

FAQ

Can I use SIPROM GA on a S7-1200 to read the ULTRAMAT 23?

No. SIPROM GA is a Windows service tool for PC/laptop commissioning, not a PLC library. To read the analyzer from a S7-1200 you must use the on-board ELAN RS485 port and a Freeport (point-to-point) implementation on a CM 1241 RS485 module.

My ULTRAMAT 23 was not ordered with PROFIBUS - do I need to add a board?

No. The ELAN RS485 port is present on every ULTRAMAT 23 regardless of the PROFIBUS option. The implementation above uses the always-present ELAN interface and requires no hardware modification of the analyzer.

What baud rate and parity should I configure on the CM 1241?

Set 9600 bit/s, 8 data bits, 1 stop bit, even parity, no flow control. These are the factory defaults for the ULTRAMAT 23 ELAN port and the only combination that the analyzer's ELAN stack accepts in the field.

How do I validate the BCC of the analyzer's reply?

Compute the XOR of every byte from LEN through the last DATA byte (skip STX, include the BCC byte itself). The two ASCII hex characters you compute must match the BCC field of the reply. Implement this as the FctBcc() helper used in the SCL sample.

How many channels can I poll and how fast?

The ULTRAMAT 23 can measure up to four gas components. With 9600 bit/s and a 4-channel round-robin, the typical cycle time per channel is 60-120 ms. Polling all four channels once per second leaves the half-duplex bus free for diagnostics and remains well below the analyzer's internal update rate.

Back to blog