Configure S7-1200 Modbus RTU Master for Altivar ATV12 via CM1241

David Krause18 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

Overview

Pairing a SIMATIC S7-1200 CPU with a Schneider Electric Altivar ATV12 variable frequency drive over Modbus RTU is a common low-cost motion package: a CPU 1212C, 1214C, or 1215C acts as the Modbus master, an RS-485 CM1241 or CB1241 acts as the physical port, and three ATV12 drives hang off the bus as slaves. Despite the simplicity of the topology, the integration trips on a handful of repeatable failures: the wrong communication module is installed (the CM1243 is not a Modbus RTU module), the S7-1200 Modbus blocks are addressed using the application layer convention 4xxxx instead of the data link layer convention expected by MB_MASTER, and the port is used before MB_COMM_LOAD initializes it, which surfaces as status word 16#8180. This reference walks through the wiring, TIA Portal configuration, block parameters, addressing rules, and the field-proven fixes for the most common error codes.

Scope. Modbus RTU master, single-master multi-drop RS-485, S7-1200 CPU 1212C/1214C/1215C/1217C, CM1241 (6ES7241-1CH30-0XB0), CB1241 (6ES7241-1CH30-1XB0), MB_COMM_LOAD, MB_MASTER, and the ATV12 Modbus register map. This document does not cover Modbus TCP (use the CP module and open user communication), PROFIBUS-DP to ATV12 (use the VW3A3607 communication card), or ATV12 analog/IO control.

Prerequisites

Item Specification Notes
CPU S7-1212C, S7-1214C, S7-1215C, S7-1217C DC/DC/DC variants recommended for clean field-side power
Firmware V4.0 or higher V4.2+ recommended for stable multi-master bus behavior
Modbus module CM1241 RS485 (6ES7241-1CH30-0XB0) or CB1241 RS485 (6ES7241-1CH30-1XB0) CM1241 has 9-pin SUB-D; CB1241 has screw terminals
Drive Schneider Altivar ATV12 with Modbus RTU Standard ATV12 ships with Modbus RTU on the RJ45 port
Software TIA Portal V13 SP1 or higher (V15/V16/V17/V18 recommended) Older portals lack MB_COMM_LOAD V2.x enhancements
Cable Shielded twisted pair, 120 Ω characteristic impedance (e.g. Belden 3106A) Max 1000 m bus length at 19.2 kbps; 120 Ω terminator at each end

Verify the ATV12 firmware supports Modbus RTU slave mode. From the drive keypad navigate to CONF > FULL > COMM > MODBUS, confirm Modbus is enabled, and assign a unique address (1 to 247) to each drive on the bus; addresses 1, 2, and 3 are typical for a three-drive cluster.

Communication Board Selection: CM1241 vs CB1241 vs CM1243

The single most common initial question on this integration is which communication module to install. The correct answer is either CM1241 or CB1241. The CM1243 family is not the right module for Modbus RTU and will not run MB_MASTER.

Module Order Number Function Use with ATV12?
CM1241 RS485 6ES7241-1CH30-0XB0 RS-485 Modbus RTU master/slave, 9-pin SUB-D Yes
CB1241 RS485 6ES7241-1CH30-1XB0 RS-485 Modbus RTU master/slave, screw terminals Yes
CM1241 RS232 6ES7241-1AH30-0XB0 RS-232 point-to-point No (ATV12 is RS-485)
CM1243-1 6GK7243-1BX30-0XE0 AS-Interface master No
CM1243-2 6GK7243-2AX30-0XE0 SINAUT SMS / telecontrol No
CM1243-5 6GK7243-5DX30-0XE0 PROFIBUS DP master/slave No (use ATV12 PROFIBUS card)
CM1243-7 6GK7243-7KX30-0XE0 Security / firewall No
CM1243 is not a Modbus RTU module. The CM1243 family is designed for AS-i, SINAUT, PROFIBUS, and security/firewall roles. For Modbus RTU over RS-485 you must use a CM1241 or CB1241. Confirm the printed part number on the side of the module before commissioning; a mismatched module is the most common root cause of error 16#8180. Refer to the S7-1200 CM/CB 1241 module manual for the catalog numbers and firmware compatibility.

CB1241 is the more compact choice: a communication board that mounts to the left side of the CPU with screw terminals for D+, D-, and GND, ideal for small panels. CM1241 is a communication module that mounts to the left of the CPU or CB1241, uses a 9-pin SUB-D connector, and is the right choice when a Profibus-style connector with integrated 120 Ω termination is required. Both modules support Modbus RTU master and slave at 1.2 to 115.2 kbps.

Hardware Wiring and Bus Topology

The ATV12 RJ45 Modbus port follows the Modbus standard pinout: pin 5 is D1 (B+), pin 4 is D0 (A-), pin 8 is common (0V/GND), and pin 7 is the 120 Ω termination jumper on the drive PCB. For multi-drop, daisy-chain D+, D-, and GND between drives, then place a 120 Ω resistor between D+ and D- at the two physical ends of the bus. If the CM1241 is one physical end, enable its internal termination via the slide switch or by inserting a jumper between pins 7 and 8 of the SUB-D connector per the CM1241 manual.

CM1241 9-pin SUB-D Signal ATV12 RJ45 pin
3 (D+ / B) Data + 5 (D1)
8 (D- / A) Data - 4 (D0)
5 (GND) Common 8 (0V)
Housing Shield 1 (Shield, 360° bond)
S7-1200 + CM1241 Modbus RTU Master 120 Ω D+ / B D- / A ATV12 #1 Address 1 Slave ATV12 #2 Address 2 Slave ATV12 #3 Address 3 Slave 120 Ω RS-485 bus: D+, D-, GND; 120 Ω at each physical end

Bond the shield at one end only to avoid ground loops. If the panel has high VFD switching noise, place a small RC snubber (e.g. 100 Ω + 100 nF) across the bus at each drive terminal; the ATV12 manual documents this as a software setting under CONF > COMM > MODBUS > TER.

Port Configuration in TIA Portal

  1. Open the device configuration of the S7-1200 CPU in TIA Portal.
  2. Drag the CM1241 or CB1241 from the hardware catalog (under Communication modules > CM/CB) onto a free slot to the left of the CPU.
  3. Open the module properties and set the port to RS-485 half-duplex, not RS-422. The ATV12 is a two-wire RS-485 device.
  4. Select 9.6 kbps (or 19.2 kbps for faster polling), 8 data bits, even parity, 1 stop bit, and flow control: none. These must match the ATV12 exactly or frames will be silently dropped.
  5. Confirm the diagnostic address. TIA assigns 271 to the CM by default; do not change this unless you also pass the new ID to MB_COMM_LOAD as the PORT input.

The hardware configuration is the input contract for MB_COMM_LOAD. If the slot is empty in the device view, MB_MASTER calls will return 16#8180 because there is no valid port to write to. For the broader Modbus RTU integration checklist, refer to the Siemens FAQ on S7 Modbus RTU components.

Initializing the Modbus Port: MB_COMM_LOAD

MB_COMM_LOAD is a one-shot block that runs in OB100 (startup) or OB1 on the first scan to push the port parameters into the CM/CB. Without it, every MB_MASTER call returns 16#8180 ("Invalid value for the port ID").

MB_COMM_LOAD input parameters

Input Data type Value Description
REQ Bool TRUE (first scan) Edge-triggered; pulse on first cycle only
PORT Uint 271 (default CM1241) Diagnostic address from device configuration
BAUD Uint 9600 / 19200 / 38400 Must match ATV12
PARITY Uint 0=none, 1=odd, 2=even ATV12 default is even (2)
FLOW_CTRL Uint 0=none, 1=XON/XOFF Use 0; the ATV12 has no RTS
RTS_ON_DLY Uint 0 No RTS on RS-485
RTS_OFF_DLY Uint 0 No RTS on RS-485
RESP_TO Uint 1000 Response timeout in ms

Sample call in OB100:

// OB100 - Startup
MB_COMM_LOAD_DB.MB_COMM_LOAD(
    REQ        := TRUE,        // execute on first scan only
    PORT       := 271,         // CM1241 default diagnostic address
    BAUD       := 9600,
    PARITY     := 2,           // 2 = even parity
    FLOW_CTRL  := 0,
    RTS_ON_DLY := 0,
    RTS_OFF_DLY:= 0,
    RESP_TO    := 1000,
    DONE       => FirstInitOK,
    ERROR      => FirstInitErr,
    STATUS     => FirstInitStatus);

If the block returns ERROR = TRUE on first execution, capture STATUS. A common value is 16#80B0 plus the slot number; this means "module does not exist or wrong ID". Verify the slot is populated in the device configuration and that PORT matches the diagnostic address.

Polling Three Slaves with MB_MASTER

With one CM1241 handling three ATV12 drives, MB_MASTER is called in a round-robin pattern. Use a cyclic OB (OB1) and a state machine that cycles through slave IDs 1, 2, and 3, requesting one or two registers per cycle. Calling MB_MASTER more than once per port at the same time will corrupt the frame; gate the call with a single instance DB per channel.

MB_MASTER input parameters

Input Data type Value Description
REQ Bool Edge from sequencer Rising edge triggers one transaction
MB_ADDR Uint 1..247 Modbus slave address; ATV12 set by drive keypad
MODE USInt 0..7 Function code selector
DATA_ADDR Uint 0..65535 0-based data link layer address
DATA_LEN Uint 1..125 Number of registers/coils
DATA_PTR Variant Pointer to DB Source/destination buffer; WORD-aligned for registers
DONE Bool Output TRUE for one cycle on success
ERROR Bool Output TRUE for one cycle on failure
STATUS Word Output Error code; see table below

Mode values (S7-1200 Modbus block V2.x)

MODE Function code Operation
0 01 Read Coils
1 02 Read Discrete Inputs
2 03 Read Holding Registers
3 04 Read Input Registers
4 05 Write Single Coil
5 06 Write Single Holding Register
6 15 Write Multiple Coils
7 16 Write Multiple Holding Registers

To read the output frequency of an ATV12, use MODE 2 (read holding registers, FC 03) and point DATA_ADDR to the data link address of the ETA/frequency register. To set the speed reference, use MODE 5 or MODE 7 with a target value, e.g. 1500 for 50.0 Hz on a 50 Hz drive (the Schneider Altivar scaling is 0..1500 for 0..50.0 Hz on most parameters; check the specific register in the ATV12 manual for the correct scaling).

Modbus Addressing: Data Link Layer vs Application Layer

This is the most common source of confusion. The S7-1200 Modbus blocks (MB_MASTER, MB_SLAVE) accept the 0-based data link layer address, not the application layer 4xxxx convention. The ATV12 manual, on the other hand, lists its registers in the 4xxxx format. Convert by subtracting 40001.

Application layer (ATV12 doc) Data link layer (MB_MASTER input) Decimal
40001 0 0
40002 1 1
42001 2000 2000
4xxxx xxxx - 1 xxxx - 1
Address space limit. The S7-1200 Modbus blocks support up to 65535 (0xFFFF) in the data link layer. The ATV12 holding register space is 40001..40999 by default, but several control and status registers live at higher 40xxx addresses, including the user-reserved 16#FD00 range used for advanced parameter access. The S7-1200 block can address these as long as the integer fits in 16 bits and the slave supports function codes 03/06/16.

For hex-formatted addresses such as 16#FD00 (64768 decimal), MB_MASTER accepts the integer directly. Some Schneider manuals present the address in a 6-digit form (e.g. 416FD00). Whether the value to enter is the application address or the data link address depends on the manual; the simplest field test is to use a free Modbus master tool on a PC (e.g. Modscan32) against the same drive, request the documented register, and observe the raw address it sends. See the S7-1200 Modbus RTU master programming manual for the full block description.

ATV12 Holding Register Map (Working Subset)

The ATV12 exposes a virtual control word, status word, frequency setpoint, and output frequency through Modbus. The field report cited 16#FD00 (64768 decimal) as the address for output frequency and 42001 as another working read address. Treat these as example values and verify against the official ATV12 Modbus communication manual (Schneider document NVE21777 or the current equivalent) before deployment.

Logical name Application addr (4xxxx) Data link (MB_MASTER) Read/Write Notes
ETA (status word) 43201 (typical) 3200 (typical) R Drive status, bit-encoded
CMD (control word) 43251 (typical) 3250 (typical) W Bit 0 = run, bit 1 = direction, etc.
Speed setpoint 43253 (typical) 3252 (typical) W 0..1500 = 0..50.0 Hz on 50 Hz drive
Output frequency 43273 (typical) 3272 (typical) R 0..1500 = 0..50.0 Hz
Parameter access block 40FD00..40FD09 16#FCFF..16#FD08 R/W User-reserved parameter access range
Example from source 42001 2000 R Confirmed working in field report
Example from source 16#FD00 (64768) 64768 (if data link) R Used in source as output frequency; verify with Modscan32

To read a holding register into S7-1200 data block "ATV12_FB" at offset byte 0 (Word 0):

// OB1 - Cyclic, one transaction per cycle
IF (State = 0) THEN
    // Read status from slave 1
    MB_Master_DB.MB_Master(
        REQ       := TRUE,
        MB_ADDR   := 1,
        MODE      := 2,            // 03 = read holding registers
        DATA_ADDR := 3200,         // ETA (verify against ATV12 manual)
        DATA_LEN  := 1,
        DATA_PTR  := P#DB10.DBX0.0 WORD 1,
        DONE      => DoneFlag,
        ERROR     => ErrFlag,
        STATUS    => StatusWord);
    State := 1;
END_IF;

For the 16#FD00 parameter access range, confirm whether the ATV12 manual lists the address as the application layer value (in which case use DATA_ADDR = 64767) or as the data link value (in which case use DATA_ADDR = 64768). The Modscan32 utility on a PC is the fastest way to confirm; it can scan the entire 0..65535 data link space and show which addresses return a non-exception response.

Error Code Diagnosis: 16#8180 and Other Status Words

Status word 16#8180 from MB_MASTER or MB_SLAVE means the PORT input does not match any Modbus-enabled communication module in the device configuration. This is by far the most common fault when bringing up an S7-1200/ATV12 link.

Likely cause Diagnostic Fix
No CM1241/CB1241 in the device configuration Open device view; is the module visible to the left of the CPU? Drag CM1241 from the catalog to a free slot; download hardware config
PORT input does not match diagnostic address Cross-check the diagnostic address in module properties; default 271 Update MB_COMM_LOAD/MB_MASTER PORT to the same number
CM1243 installed by mistake Order number on side of module is 6GK7243-x Replace with CM1241 RS485 (6ES7241-1CH30-0XB0)
MB_COMM_LOAD never executed Monitor REQ edge and DONE/ERROR/STATUS of MB_COMM_LOAD Call MB_COMM_LOAD in OB100 with REQ := TRUE on first scan only
Hardware configuration not downloaded Online > Accessible devices: is the module visible? Compile and download the device configuration
Loose module LEDs on CM1241 are dark Power down, reseat the module, check connector pins

Other common status words

STATUS Meaning Corrective action
16#8180 Invalid port ID See table above
16#8181 Port ID is for non-Modbus module Verify the slot has CM/CB 1241 with Modbus RTU role
16#8182 Port is in use by another block Only one MB_MASTER/MB_SLAVE per port
16#8183 MB_COMM_LOAD not yet executed Call MB_COMM_LOAD first, monitor DONE
16#8184 Port disabled by system Check CPU run/stop, firmware
16#80C8 Data address out of range Verify DATA_ADDR fits the slave's map
16#80D1 Response timeout Increase RESP_TO; check bus wiring and ATV12 address
16#80D2 CRC error Check baud, parity, termination; add 120 Ω at each end
16#80D4 Modbus exception from slave Examine high byte: 01=illegal fn, 02=illegal addr, 03=illegal value, 04=slave failure
Modbus exception 02 (illegal data address) is the slave telling you the requested register is not implemented. If the ATV12 is set to CONF > COMM > MODBUS and the address still returns 02, double-check the manual: the register may be in a 40xxx bank that requires a separate access procedure (function code 16 with sub-addressing) or the value may be in the read-only input-register range, not the holding-register range.

Verification, Commissioning, and Pitfalls

Commissioning sequence

  1. Confirm the MB_COMM_LOAD DONE = TRUE on the first OB100 cycle and DONE never appears again (the block fires only on edge).
  2. Trigger one MB_MASTER read with MB_ADDR = 1, MODE = 2, DATA_ADDR = 3272 (output frequency, typical), DATA_LEN = 1.
  3. Watch the CM1241 Send/Receive LEDs. A healthy transaction shows alternating flashes on each direction; the receive LED should blink on every successful response.
  4. Use a Modbus diagnostic tool on the bus (Modscan32 on a laptop with a USB-RS485 adapter) to confirm the slave is responding to the same address. If the drive is silent, isolate it from the bus to rule out a stuck partner.
  5. Read back the output frequency in a watch table. The value should track the local HMI/keypad setpoint within one cycle.
  6. Add a write test: send MODE = 5, MB_ADDR = 1, DATA_ADDR = 3252 (speed setpoint, typical), DATA_LEN = 1, data = 1000 (33.3 Hz on a 50 Hz drive). The drive should ramp and the output frequency should climb to 33.3 Hz.
  7. Once one drive is healthy, extend the polling sequencer to slave IDs 2 and 3 and add fault handling per the STATUS codes above.

Polling state machine sketch

// OB1 - Polling sequencer
CASE PollState OF
    0: // Read ETA from slave 1
       MB_Master_DB.REQ := TRUE;
       MB_Master_DB.MB_ADDR := 1;
       MB_Master_DB.MODE := 2;
       MB_Master_DB.DATA_ADDR := 3200;
       MB_Master_DB.DATA_LEN := 1;
       MB_Master_DB.DATA_PTR := P#DB10.DBX0.0 WORD 1;
       PollState := 10;
    10: // Wait for done/error
       IF MB_Master_DB.DONE THEN PollState := 1; END_IF;
       IF MB_Master_DB.ERROR THEN LogFault(1, MB_Master_DB.STATUS); PollState := 1; END_IF;
    1: // Read ETA from slave 2
       MB_Master_DB.MB_ADDR := 2;
       MB_Master_DB.DATA_PTR := P#DB10.DBX2.0 WORD 1;
       PollState := 11;
    11: IF MB_Master_DB.DONE THEN PollState := 2; END_IF;
        IF MB_Master_DB.ERROR THEN LogFault(2, MB_Master_DB.STATUS); PollState := 2; END_IF;
    2: // Read ETA from slave 3
       MB_Master_DB.MB_ADDR := 3;
       MB_Master_DB.DATA_PTR := P#DB10.DBX4.0 WORD 1;
       PollState := 12;
    12: IF MB_Master_DB.DONE THEN PollState := 3; END_IF;
        IF MB_Master_DB.ERROR THEN LogFault(3, MB_Master_DB.STATUS); PollState := 3; END_IF;
    3: // Read output frequency from slave 1
       MB_Master_DB.MB_ADDR := 1;
       MB_Master_DB.DATA_ADDR := 3272;
       MB_Master_DB.DATA_PTR := P#DB10.DBX6.0 WORD 1;
       PollState := 13;
    13: IF MB_Master_DB.DONE THEN PollState := 4; END_IF;
        IF MB_Master_DB.ERROR THEN LogFault(1, MB_Master_DB.STATUS); PollState := 4; END_IF;
    4: // Send speed setpoint to slave 1
       MB_Master_DB.MODE := 5;
       MB_Master_DB.MB_ADDR := 1;
       MB_Master_DB.DATA_ADDR := 3252;
       MB_Master_DB.DATA_LEN := 1;
       MB_Master_DB.DATA_PTR := P#DB10.DBX20.0 WORD 1;
       PollState := 14;
    14: IF MB_Master_DB.DONE THEN PollState := 0; END_IF;
        IF MB_Master_DB.ERROR THEN LogFault(1, MB_Master_DB.STATUS); PollState := 0; END_IF;
ELSE
    PollState := 0;
END_CASE;

Field debugging checklist

  • Measure A-B on the bus with an oscilloscope; signal should swing at least 1.5 V differential, with the bus biased by 650 Ω pull-up to +5 V and 650 Ω pull-down to GND at one master.
  • Confirm 120 Ω at each physical end; the ATV12 RJ45 has a 120 Ω resistor that can be enabled with a jumper on the drive PCB (refer to ATV12 installation manual).
  • Verify drive Modbus address in CONF > COMM > MODBUS > ADDR. Default is 1; ensure each drive on the bus has a unique value.
  • Watch for silent slaves after a hot restart of the CPU. Some ATV12 firmware versions drop the Modbus connection if the drive sees a long inter-character gap; reduce inter-frame delay or use a 100 ms post-response recovery if needed.
  • Use a watch table to confirm MB_MASTER STATUS = 0 (DONE) on success and capture the first non-zero value for the diagnostics table above.

Pitfall matrix

Pitfall Symptom Fix
CM1243 used instead of CM1241 Status 16#8180 forever Replace module with CM1241 RS485 (6ES7241-1CH30-0XB0) or CB1241
Application layer 4xxxx used directly Slave returns exception 02 Subtract 40001 from the address
MB_COMM_LOAD never called 16#8180 on first MB_MASTER call Call in OB100 with REQ := TRUE
Baud or parity mismatch Status 16#80D2 (CRC) or no response Match ATV12 default (9600,8,E,1)
Missing 120 Ω termination Intermittent errors at long bus length Add 120 Ω at both physical ends
Two MB_MASTER blocks on same port Status 16#8182 Use a single sequencer with one MB_MASTER instance
Pointer mismatch (BYTE vs WORD) DONE = TRUE but data is shifted by 1 byte Use WORD-aligned pointer for registers; BYTE-aligned for coils
DATA_PTR not Variant-compatible Block rejects call Use P#DBx.DBBy.0 WORD n in SCL; in LAD use the "?" pin dropdown to pick a DB

Frequently Asked Questions

Which Siemens module do I need: CM1241 or CM1243?

For Modbus RTU to an ATV12, use the CM1241 RS485 (6ES7241-1CH30-0XB0) or the CB1241 RS485 (6ES7241-1CH30-1XB0). The CM1243 family is for AS-Interface, SINAUT, PROFIBUS, and security modules and will not run MB_COMM_LOAD/MB_MASTER. Verify the printed part number on the side of the module before commissioning; a mismatched module is the most common cause of status 16#8180.

MB_MASTER returns status 16#8180. What is wrong?

16#8180 means "Invalid value for the port ID" and is returned when MB_COMM_LOAD has not been called, the CM/CB is not in the device configuration, or the PORT input does not match the diagnostic address of the module. Place MB_COMM_LOAD in OB100 with REQ := TRUE on the first scan, confirm the module is in the device view, and pass the same PORT value (default 271) to both blocks. If the slot is empty in the device configuration, MB_MASTER will report 16#8180 even with the correct PORT value.

How do I read the output frequency of an ATV12 at Modbus address 16#FD00?

First confirm whether the manual uses application layer (4xxxx) or data link layer (0-based) addressing. The S7-1200 MB_MASTER block uses 0-based data link layer addresses. If the manual states 16#FD00 is the application address, use DATA_ADDR = 64767 (0xFCFF); if 16#FD00 is the data link address, use DATA_ADDR = 64768 (0xFD00) directly. Use MODE = 2 (function code 03, read holding registers) and DATA_LEN = 1. Verify the data with a free Modbus master tool on a PC before relying on the S7-1200.

Why are the CM1241 Send/Receive LEDs flashing but the data is wrong?

Traffic is happening but the byte order or register map is mismatched. Three common causes: (1) the address offset is off by one because the application layer was used directly, (2) the byte pointer in DATA_PTR is BYTE-aligned instead of WORD-aligned, which shifts every subsequent register by 8 bits, and (3) the drive is interpreting a 1500-decimal value as 150.0 Hz when the scaling is 0..1500 for 0..50.0 Hz (the human-readable Hz value is the register value divided by 10 on most ATV12 parameters). Validate the buffer with a watch table and a Modbus diagnostic tool side by side.

Can I poll three ATV12 drives from one CM1241?

Yes. Use a single MB_MASTER instance in a sequencer that cycles through MB_ADDR 1, 2, and 3, requesting one or two registers per cycle. Do not instantiate MB_MASTER once per slave; only one MB_MASTER can be active per port at a time. Keep RESP_TO between 500 and 1000 ms per drive, and budget at least 30 to 50 ms of post-response recovery time before the next request to allow the ATV12 to release the bus.

Back to blog