Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

MODBUS RTU(Master) from PLC using CR6


Kel Aug 6, 2021 12:48 PM

Hello, 

I have a CR6 data logger and I wish to obtain data from 5 reading from the address in PLC.

I'm looking for an example of a code that allows me to read the data from the PLC and store it on the CR6. I didn't find an easy way to code it in Shortcut so I need to write it myself but I don't know where to start.

Does anyone has a code that I could use or any tips on how to start?

The characteristic of the sensor are:

- PLC as a Slave Station 1 and always transmitting via register 1316, 1318, 1320, 1322, 1324, the address port is in Word-16 (this setting is completed) 

- CR6 will act like a master to read from that PLC word address and tabulate from RS485B+ connect to C1 and RS485A- Connect to C2

- 9600 baud rate, 8data bits, none parity, 1 stop bit

I tried to write the programme but i am not surer if this is correct

Public PTemp
Public batt
Public ModBus(4), Result

DataTable (Table1,True,-1)
DataInterval (0,1,Sec,10)
Minimum (1,batt,FP2,False,False)
Sample (1,ModBus(),FP2)
EndTable

'Main Program
BeginProg
'Define com port parameters for PLC communication RS485 half duplex
SerialOpen (ComC1,9600,48,0,50,4)

Scan (100,mSec,0,0)
'Panel Temperature
PanelTemp (PTemp,15000)
'Main battery voltage
Battery (batt)
ModbusMaster (Result,ComC1,9600,1,3,ModBus(),1315,2,1,3,0)

'Call Output Tables
CallTable Table1

NextScan
EndProg

Anything that i did wrong?

Log in or register to post/reply in the forum.