Modbus RTU Slave Not Working on RS485 (X20CP0484)

I created a Modbus RTU Slave program on B&R X20CP0484 using Automation Studio 6.5. I am sharing screenshots 1 to 5 showing my code and configuration, but communication is not working. Can anyone help me identify what is wrong?

Hello and welcome to the Community!

Can you please share additional information about what “not working” means? For example:

  • Are you getting errors on any of the function blocks in your program?
  • Are there errors on the other communication device?
  • Are there any communication related messages in the Logger?

The more information you can provide, the easier it will be for someone to help you :slight_smile:

Hello, thank you for the response!

Here are the details:

  1. Function Block status errors:

    • MBMOpen.status = 20241 (before changing baud rate)
    • MBMaster.status = 20210
    • MBMCmd.status = 20210
    • MBMOpen.ident = 0 (connection never establishes)
  2. Hardware setup:

    • CPU: X20CP0484
    • RS485 module: X20CS1030 at slot ST2, connected via X2X (IF6)
    • Module path confirmed via SDM (System Diagnostics Manager): IF6.ST2.IF1
  3. My current code:
    MBMOpen_xx.pDevice:=ADR(‘IF6.ST2.IF1’);
    MBMOpen_xx.pMode:=ADR(‘/PHY=RS485 /PA=E /DB=8 /SB=1 /BD=9600’);
    MBMOpen_xx.pConfig:=ADR(‘datamod’);
    MBMOpen_xx.timeout:=2000;
    MBMOpen_xx.ascii:=0;

  4. Logger: I have not yet checked the Logger for communication-related
    messages — will check and report back.

  5. Slave device: I am testing with a Modbus Slave simulator software
    (PC based), configured at 9600 baud, 8 data bits, 1 stop bit, even parity,
    Slave ID = 1.

Could you confirm if the pDevice path format “IF6.ST2.IF1” is correct
for a module connected via X2X bus.
Thank you for your help!

Hi,

i am a little bit confused.

in you first post we see you 've implemented a Modbus Slave (MBSopen ()).

In your current post you provide status information about a Modbus Master(MBMopen) an mention a PC Modbus Slave.

In general: if your initial function block (MBSopen(), MBMopen() ) fails with a status <> 0 AS online help provides an error number you can refer to: Error Numbers

Subsequent function blocks which uses an ‘ident’ output will then fail, too …

Hello, thank you for the responses so far!
Here are my full details:

  1. Function Block status errors:

MBSOpen_xx.status = 8258
MBSOpen_xx.ident = 0 (connection never establishes)
MBSlave_xx.status = 20210 (depends on ident from MBSOpen)

  1. Hardware setup:

CPU: X20CP0484
RS485 module: X20CS1030 at slot ST2, connected via X2X (IF6)
Module path confirmed via SDM (System Diagnostics Manager): IF6.ST2.IF1
Hardware interface settings: RS485, 9600 baud, Even parity, 8 data bits, 1 stop bit — all confirmed matching in Physical View
ModbusRTU parameters (hardware-level, for ACOPOS) set to “off” since this is not an ACOPOS application

  1. My current code:
    pascalMBSOpen_xx.enable := 1;
    MBSOpen_xx.pDevice := ADR(‘IF6.ST2.IF1’);
    MBSOpen_xx.pMode := ADR(‘/PHY=RS485 /PA=E /DB=8 /SB=1 /BD=9600’);
    MBSOpen_xx.own_ID := 1;
    MBSOpen_xx.timeout := 2000;
    MBSOpen_xx.pCoilStat := 0; (* uses global MB0 )
    MBSOpen_xx.pInputStat := 0; (
    uses global MB1 )
    MBSOpen_xx.pInputReg := 0; (
    uses global MB3 )
    MBSOpen_xx.pHoldingReg := 0; (
    uses global MB4 *)
    MBSOpen_xx();

  2. What I’ve already tried:

Confirmed pDevice path against SDM hardware tree (exact match: IF6.ST2.IF1)
Verified MB0/MB1/MB3/MB4 variable types match library requirements (USINT for MB0/MB1, INT for MB3/MB4)
Rebuilt the project (Clean + Rebuild All)
Power-cycled the PLC fully
Added a startup delay before calling MBSOpen() in case of X2X bus initialization timing
Confirmed DRV_mbus and dvframe libraries are present in the SW tree
Status remains 8258 in every attempt

  1. Testing setup:

Testing as Modbus RTU Slave (station ID = 1)
PC side using ModPoll, configured at 9600 baud, 8 data bits, 1 stop bit, even parity
ModPoll shows “Read error: Break condition” on every poll, consistent with the PLC-side port never opening

My question: Is there a known conflict between the X20CS1030 hardware-level interface configuration and the MBSOpen() function block claiming the same port? Could the “Module supervised” or “Extended error status information” settings under the X20CS1030 module configuration affect this? Any guidance on what status 8258 specifically indicates for FRM_xopen in this context would be greatly appreciated.
Thank you for your help!

Hello,

you must set the mode of the X20CS1030 to “stream” or “cyclic stream”.

It’s Already “stream” mode.

can you try to set to defaults, please ?

Since you set the serial parameters by function block it should not be necessary to change anything here.

BTW : you can see the correct device path by activating column ‘PLC Address’ in hardware tree:

What do the LEDs on the X20CS1030 indicate?
Is the X20CS1030 plugged into an X20BM11?

Path is Correct

I will set default just change to modbus485, but Same error, check to Screenshot

.

What do the LEDs on the X20CS1030 indicate?
=> its error Red led blink and Rx led.
Is the X20CS1030 plugged into an X20BM11?
= yes.

but now MBSOpen_xx.status is 20215

This is my code Please check and i will share screenshot for setting and variable list.

i will try many time mod poll but I have not receive and data, how to solve it Please Guide me.

PROGRAM _INIT
S1 := 0;
InitDone := 0;
StartupDelay := 0;

MB0[0] := 0;  MB0[1] := 1;  MB0[2] := 1;  MB0[3] := 0;  MB0[4] := 1;
MB1[0] := 0;  MB1[1] := 1;  MB1[2] := 0;
MB4[0] := 10; MB4[1] := 30; MB4[2] := 50; MB4[3] := 60; MB4[4] := 70;
MB3[0] := 80; MB3[1] := 90; MB3[2] := 100;

END_PROGRAM

PROGRAM _CYCLIC
(* Wait 2 seconds (200 cycles @ 10ms) before opening port *)
IF StartupDelay < 200 THEN
StartupDelay := StartupDelay + 1;
ELSIF InitDone = 0 THEN
MBSOpen_xx.enable := 1;
MBSOpen_xx.pDevice := ADR(‘IF6.ST2.IF1’);
MBSOpen_xx.pMode := ADR(‘/PHY=RS485 /PA=E /DB=8 /SB=1 /BD=57600’);
MBSOpen_xx.own_ID := 1;
MBSOpen_xx.timeout := 2000;
MBSOpen_xx.pCoilStat := 0;
MBSOpen_xx.pInputStat := 0;
MBSOpen_xx.pInputReg := 0;
MBSOpen_xx.pHoldingReg := 0;
MBSOpen_xx();

	IF MBSOpen_xx.status <> 65535 THEN  (* FBK execution complete *)
		InitDone := 1;
	END_IF
ELSE
	MBSlave_xx.enable := 1;
	MBSlave_xx.ident  := MBSOpen_xx.ident;
	MBSlave_xx();
END_IF

IF(S1=1)THEN
	MBSClose_xx.enable := 1;
	MBSClose_xx.ident  := MBSOpen_xx.ident;
	MBSClose_xx();
END_IF

END_PROGRAM

As I see it, your Modbus variables are local. However, they must be declared global.

MBSOpen()

online help to MBSopen() says MB0, MB1, MB3 and MB4 have to be GLOBAL

or use the pCoilStat, pInputStat, pInputReg, pHoldingReg with own variables.

Please check the attached image

. I moved my local variables to global variables, saved the project, rebuilt it, and transferred the code to the PLC. After the transfer, I tried to read the data using ModPoll, but no data is being received. I am unable to find the mistake. Could you please help me identify the problem?

Do you have a serial sniffer to analyze raw data?

Ciao
Valerio

Sir Check my Last share Information, and Solve My Issue.