Hi all,
I want to allow RTU RS485 comunication between a Controllino Mega and a Wago PLC.
I'm using a Wago PFC200 750-8212 and a Serial Card 750-653/003-000 .
Here the manual of the serial module.
https://www.wago.com/medias/m07500653-00000000-0en.pdf?context=bWFzdGVyfGRvd25sb2Fkc3w0NDEwODF8YXBwbGljYXRpb24vcGRmfGRvd25sb2Fkcy9oNGMvaDkzLzk4NjY5NzI0MzAzNjYucGRmfDRhZWZiOWI3NjI5M2U2ZGYzYmQwMTRkODlmY2FlYzQyM2M4ZmEyODcwMTU2MjA4OWZlZGQ5ZDMwNTgzOTJlODY&attachment=true
I'm using the wiring diagram at page 13 (Bus connection).
I've connected the TX+ and RX+ to Controllino RS485 + terminal and the TX- and RX- to the RS485 - terminal of the controllino.
Connected the Controllino to the 24v and serial monitor listening through USB.
I'mm using the RS485 demo code on Controllino
itialize serial port for debug messages. */
Serial.begin(9600);
/* Initialize CONTROLLINO RS485 direction control DE/RE pins and Serial3 */
Controllino_RS485Init(9600);
Controllino_RS485RxEnable();
Serial.println("Recieving RS485... 1");
}
void loop() {
// send data only when you receive data:
if (Serial3.available() > 0)
{
// read the incoming byte from RS485
incomingByte = Serial3.read();
// say what you got:
Serial.print("I received (DEC): ");
Serial.println(incomingByte, DEC);
// and send it back to RS485
Controllino_RS485TxEnable();
Serial3.write(incomingByte);
Serial3.flush(); // wait until the trasmission is complete
Controllino_RS485RxEnable();
}
}
And the demo code on CodeSys
PROGRAM PLC_PRG
VAR
test1 : BYTE;
test2 : BYTE;
mySerialMaster : FbMbMasterSerial := (
xConnect := TRUE,
udiBaudrate := 9600,
usiDataBits := 8,
eParity := eTTYParity.None,
eStopBits := eTTYHandshake.None,
ePhysical := eTTYPhysicalLayer.RS485_Halfduplex,
eFrameType := eMbFrameType.RTU,
tTimeOut := T#50MS
);
utQuery : typMbQuery := (
bUnitId := 1,
bFunctionCode := 16#04,
uiReadAddress := 0,
uiReadQuantity := 10,
uiWriteAddress := 0,
uiWriteQuantity := 8,
awWriteData := [1,1,1,1,1,1,1,1,1]
);
xTxTrigger : BOOL;
utResponse : typMbResponse;
tonDelay : TON := (PT := T#20MS);
END_VAR
IoConfig_Globals_Mapping.an1 := 27648;
tonDelay( IN := (NOT tonDelay.Q) AND (NOT xTxTrigger));
xTxTrigger S= tonDelay.Q;
mySerialMaster(
I_Port := IoConfig_Globals.RS485_Interface_Adjust,
utQuery := utQuery,
xTrigger := xTxTrigger,
utResponse := utResponse
);
Any idea?
Thanks