Port instantiation of serial interface WAGO 750-652 in WAGO PLC 881-652 using Modb_L05.lib in CoDeSys v2.3

Hi, Would really appreciate your insights in this issue I have.

I am currently using a WAGO 750-881 with multiple IO devices. For one of them I already occupied the MODBUS Master configuration tool so I cannot overwrite it for my other devices.

I have a total of two serial interfaces WAGO 750-652.

The first one is instantiated in COM2 and doesn’t need any protocol since the information comes in an specific formatting that need little code to differentiate between needed info. This one is working just fine.

The second one is where I have an issue. I have tried to instantiate the port using MODBUS library modb_L05.lib to properly receive the data from an ARDUINO and I am absolutely unable to open the port: Signal DEVICE2.fbModbus.MODBUS_EXT_MASTER.Interface.Com_Port_Ist_Offen is never TRUE, among with all other signals from that interface, while signal DEVICE1.COM2.Com_Port_Ist_Offen is TRUE, and the other signals also read as TRUE or FALSE.

I have tried instantiating the second one as the first one (exactly the same code but to COM3/4), changing COM3 to COM4, I’ve tried a lot of things but it wont ever open the channel. I don’t know if you have any recommendations for me.

For both physical modules, both witness LEDs A and E are on.

First one is instantiated like this:

PROGRAM DEVICE1
VAR
wBaudRate		: WORD := BAUD_9600;
bDataBits			: BYTE := 8;
bParity				: BYTE := 0;
bFlowControl 		: BYTE := 3;  		(RS422 FullDuplex with continous send)
i 					: INT;
COM2 				: SERIAL_INTERFACE;
xOpenPort2		: BOOL := TRUE;	 (* Flag to open the Port )
xInitPort2			: BOOL;			 ( Flag to initiallize the Port *)
ReceiveBuffer2	: typRing_Buffer;
END_VAR

COM2(	bCOM_PORT_NR 	:= 2,
cbBAUDRATE 			:= wBaudRate,
cbsBYTESIZE			:= bDataBits,
cpPARITY				:= bParity,
csSTOPBITS			:= STOPBITS_1,
cfFLOW_CONTROL	:= bFlowControl,
utRECEIVE_BUFFER := ReceiveBuffer2,
ptSEND_BUFFER		:= ADR(SendString2),
xINIT					:= xInitPort2,
xOPEN_COM_PORT	:= xOpenPort2,
iBYTES_TO_SEND	:= LEN(SendString2)+1,
xSTART_SEND		:= xSendActive2 );

Second one like this:

PROGRAM DEVICE2
VAR
COM4				: SERIAL_INTERFACE;
xInitPort4    		: BOOL := TRUE;
xOpenPort4    		: BOOL := TRUE;
ReceiveBuffer4	: typRing_Buffer;

    fbModbus : MODBUS_EXTENDED_MASTER_RTU;

	fbError : enumMB_ERROR;

	stQuery    : typModbusExtendedQuery;
	stResponse : typModbusResponse;

	au16Data 	: ARRAY[0..14] OF WORD;
    i 			: INT;
	tPoll : TON;

END_VAR

COM4
(bCOM_PORT_NR       := 4,
cbBAUDRATE         	:= BAUD_9600,
cbsBYTESIZE        	:= 8,
cpPARITY           	:= 0,
csSTOPBITS         	:= STOPBITS_1,
cfFLOW_CONTROL  	:= 2,           (* RS-485 half-duplex )
utRECEIVE_BUFFER := ReceiveBuffer4,
xINIT              			:= xInitPort4,
xOPEN_COM_PORT  	:= xOpenPort4,
xSTART_SEND		:= xSendActive4,);
stQuery.SlaveAddress     		:= 1;      	
stQuery.FunctionCode     		:= 3;      	
stQuery.Read_StartAddress	:= 0;      	
stQuery.Read_Quantity    		:= 15;     	
(*Poll code*)
fbModbus(
ENABLE              		:= TRUE,
bCOM_PORT           	:= 4,           ( *COM4=> 750-652 port *)
cbCOM_BAUDRATE  	:= BAUD_9600,
cpCOM_PARITY        	:= 0,
csCOM_STOPBITS 	:= 1,
cbsCOM_BYTESIZE 	:= 8,
cfCOM_FLOW_CONTROL  := 2,
TimeOut             		:= T#500ms,
StartFunction       	:= xStart,
ExtQuery            	:= stQuery,
Response            	:= stResponse,
MB_Error            	=> fbError);
FOR i := 0 TO 14 DO au16Data[i] := stResponse.Data[i]; END_FOR;

So you have 2 x 750-652?
The COM port should be name after 750-652 in the hardware declaration.
Could you show us your K-bus declaration ?

I think my version of codesys does not allow to set or check COM declaration. Its v2.3.

my only available options are checking the elements and assigning addresses to the specific IO lines.

Ok, I thought you were using CODESYS 3.5. I didn’t see the reference to Modb_l05.

You should use COM 2 for the first interface and COM 3 for the second one.

Could you check the wiring first ?
The most common setting is RS-485 half-duplex.
In Half-duplex it should be wired this way :

Check also you communication settings : FlowControl, Parity, Baudrate, Stopbit, Databits.
If it doesn’t match to the slave it won’t work.

Hi,

you do not need a separate SERIAL_INTERFACE instance for COM4, it is already internally included in MODBUS_EXTENDED_MASTER_RTU

Hi quenorha,

I have checked the cables and seem to be correct, and I have deleted the extra instantiation of COM3, and now it seems I am opening the port COM3 correctly (Receiving TRUE in DEVICE2.fbModbus.MODBUS_EXT_MASTER.Interface.Com_Port_Ist_Offen) but communication is still not happening. For this case what I need to fix is my Arduino communication protocol I think.

I am open to knowledge in RS-485 half-duplex. Because I understand for the parameter flow control 3 is full/duplex, but for half duplex I dont know what I should go with. I tried with 2 and 4, but either make the operating mode to default to RS-232 as per WAGO I/O CHECK 3 .

Thank you for your kind guidance!

Hi Thruster,

Thank you se much! I can see now the channel opening (DEVICE2.fbModbus.MODBUS_EXT_MASTER.Interface.Com_Port_Ist_Offen is TRUE now) but communication is still not happening. For this case what I need to fix is my Arduino communication protocol I think.

I am open to knowledge in RS-485 half-duplex. Because I understand for the parameter flow control 3 is full/duplex, but for half duplex I dont know what I should go with. I tried with 2 and 4, but either make the operating mode to default to RS-232 as per WAGO I/O CHECK 3 .

Thank you for your kind guidance!

Hi,

for RS-485 half Duplex it should be 4:

TYPE COM_FLOW_CONTROL :
(
	(*:::::: WITH CONTINOUS SEND ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*)
	NO_FLOW_CONTROL             	:=0,		(* RS 232 / fullduplex / without handshake       / with continous send *)
	XON_XOFF                    	:=1,		(* RS 285 / halfduplex / with XON & XOFF         / with continous send *)
	RTS_CTS                     	:=2,		(* RS 232 / fullduplex / with hardware handshake / with continous send *)
	FULLDUPLEX                  	:=3,		(* RS 422 / fullduplex / without handshake       / with continous send *)
	HALFDUPLEX                  	:=4,		(* RS 485 / halfduplex / without handshake       / with continous send *)

	(*------ NEW SINCE JULY 2009 --------------------------------------------------------------------------------------*)
	RS232_FULLDUPLEX_XON_XOFF   	:= 5,		(* RS 232 / fullduplex / with XON & XOFF         / with continous send *)
	RS422_FULLDUPLEX_XON_XOFF   	:= 6,		(* RS 422 / fullduplex / with XON & XOFF         / with continous send *)
	(*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*)

	(*:::::: WITHOUT CONTINOUS SEND ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*)
	NCS_NO_FLOW_CONTROL         	:=20,		(* RS 232 / fullduplex / without handshake       / without continous send *)
	NCS_XON_XOFF                	:=21,		(* RS 285 / halfduplex / with XON & XOFF         / without continous send *)
	NCS_RTS_CTS                 	:=22,		(* RS 232 / fullduplex / with hardware handshake / without continous send *)
	NCS_FULLDUPLEX              	:=23,		(* RS 422 / fullduplex / without handshake       / without continous send *)
	NCS_HALFDUPLEX              	:=24,		(* RS 485 / halfduplex / without handshake       / without continous send *)

	NCS_RS232_FULLDUPLEX_XON_XOFF   := 25,		(* RS 232 / fullduplex / with XON & XOFF         / without continous send *)
	NCS_RS422_FULLDUPLEX_XON_XOFF   := 26,		(* RS 422 / fullduplex / with XON & XOFF         / without continous send *)
	(*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*)

	FLOW_CONTROL_TERMINAL_DEFAULT 	:= 16#7FFF	(* take the settings inside module *)
);
END_TYPE

Then you have to wire according to the image from Quentin.

Try also swapping both wires, that is a common issues.

Do you have tested your Arduino Application if Modbud RTU works?

1 Like