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.

Protocole ModBus with analizer Serinus and DataLogger CR6


SoporteTechLab Nov 10, 2023 07:33 PM

Hello everyone,

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 )

 DataInterval (0,2,Sec,-1)

 Sample (1,AmbPressure,IEEE4)

 Average (1,AmbPressure,IEEE4,False)

 Sample (1,CellTemp,IEEE4)

 Sample (1,GasConc,IEEE4)

 EndTable

 BeginProg

 'TCPOpen ("192.168.100.020",3000,1,,Handle,1) ' ONLY When i conected the datalogger with TCP/IP                                  

  ModbusMaster(Result,ComUSB,115200,5,3,ModbusData(),-1,2,3,100)

  TCPOpen ("192.168.66.17",6785,1,,HandleSerinus,1) ' direccion ip del serinus -- IP y numero de puerto del Serinus por ahora 8000

  ModbusSlave (HandleSerinus,115200,30,ModIn(),0)

  Scan (1,Sec,3,0)

  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)

 CallTable CapSerinus

  NextScan

EndProg

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

 

BeginProg

 

    Scan (1,Sec,3,0)

      If Flag(1) Then

       PingMe=PingIP("192.168.66.17",3000)

       Flag(1) = False

       IPTrace (TraceMessage)

      EndIf

    NextScan

 

EndProg

 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


JDavis Nov 10, 2023 11:52 PM

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.


SoporteTechLab Nov 11, 2023 02:37 PM

This post is under review.


suzume Dec 30, 2023 05:00 AM

This post is under review.

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