Hello,
I was trying to read Input and holding register's values from Woodward MR4A relay through Modbus RTU communication. This woodward MRA4 relay connected with i-Trilogi FMD88-10 PLC through RS485 port and this MRA4 relay support 8data bits, 1 stop bit, even parity with baud rate 19200. I have used two custom functions to check 'command status" by using STATUS(2) and "incoming massage in comm port" by using INCOMM(ch) but the STATUS(2) gives '0' return and b]INCOMM(ch)[/b] gives '-1' return.
This is my i-Trilogi code..
[Fast Scan]
'SETSYSTEM 1, &HFF
'SETSYSTEM 2, &HFF
SETPROTOCOL 3,1 'set port 3 for fixed ModbusRTU protocol
SETPROTOCOL 2,1 'set port 2 for fixed ModbusRTU protocol
SETBAUD 3, &H44 'set port 3 as 8 data bits, 1 stop bit, even parity, baudrate 19200
SETBAUD 2, &H44 'set port 2 as 8 data bits, 1 stop bit, even parity, baudrate 19200
[Every Scan]
SETSYSTEM 6,4 ' set seytem for modbus function code 04
READMB2 12,1,20146,DM[1],2 'read through port 2
call Checkstatus
call checkcom
TIMERPV[T1]=50
CLRIO T1
SETSYSTEM 6,3 ' set system for modbus function code 03
READMB2 12,1,32500,DM[4],6 'read through port 2
call CheckStatus1
call checkcom
custom function [checkstatus] - to check command status
FOR I=1 to 1000
A = STATUS(2)
IF A=1 RETURN:
ELSE
SETLCD 1,1,"ReadFailuire"
ENDIF
NEXT
custom function [checkcom] - to check incoming massage in port 2 or 3
FOR J=1 to 1000
D = INCOMM(2):
IF D>0 RETURN:
ELSE
SETLCD 3,1,"Nothing receive"
ENDIF
NEXT