I'm encountering an issue with configuring a Modbus protocol for the CR6 Datalogger and a Gas Analyzer. My aim is to read the registers of the analyzer, but it operates using the Modbus protocol. To facilitate this, I've connected the analyzer to the datalogger via TCP/IP, and the datalogger is further connected to the PC through USB. I'm utilizing the PC400 program and CRbasic for the code.
While verifying the TCP/IP connection using the PingIP function, I consistently receive a 0.00-minute response, indicating no successful connection."
IP Datalogger: 192.168.66.1
IP Gas Analyzer : 192.168.66.17
IP CPU: 192.168.66.15
This is my code for the comunication ModBus :
Units AmbPressure = Torr
Units CellTemp = Grados
Units GasConc = ppm
DataTable (CapSerinus,True,-1 )
'TCPOpen ("192.168.100.020",3000,1,,Handle,1) ' ONLY When i conected the datalogger with TCP/IP
TCPOpen ("192.168.66.17",6785,1,,HandleSerinus,1) ' direccion ip del serinus -- IP y numero de puerto del Serinus por ahora 8000
ModIn(73)=AmbPressure ' Se decide que direccion del protocolo modbus se va leer
ModIn(406)=CellTemp ' Temperatura de la celda
ModIn(356)=GasConc ' Concentracion del Gas 1 (CO para serinus30)
When compiling this code, I encountered differing results from the ModBusMaster function. Specifically, I obtained a result of "1" when connecting the datalogger to the PC via USB and a result of "-11" when connecting the datalogger to the PC via a network connection. However, as per the CRBasic Help section, it states that under normal conditions, the ModBusMaster function should yield a result of "0" if everything is functioning correctly.
To test the Ping between the Gas Analyzer and datalogger use the following code:
Public PingMe, Flag(2) As Boolean, TraceMessage As String * 100
If Flag(1) Then
Flag(1) = False
I would be very grateful if you could help me with this project. If you need any additional information, do not hesitate to ask me.
Thanks in advance
Ping response is often turned off in devices, so a failed ping might not indicate a bad connection.
TCPOpen() in the datalogger will return a handle number >=100 if it was able to open the IP socket. Modbus TCP is usually on IP port 502, and I do not see that port number in your TCPOpen instruction.
ModbusMaster() would be the instruction to use in the CR6 to read registers from the gas analyzer.
This post is under review.