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.

modbusclient on a CR300


Benjamin.vial Apr 5, 2024 12:34 PM

Hi,

I try to read a modbus sensor (SMP-3 pyranometer).

I tried a lot of parameters but I have made no progress, I thin I'm missing something and loosing time because of this, could you please help me ?

Here my prog :

 

'CR300/CR310
'Created by Short Cut (4.4)

Public BattV
Public PTemp_C
Public DiffVolt
Public Result
Public rtu_var_8(10)

Units BattV=Volts
Units PTemp_C=Deg C
Units DiffVolt=mV

DataTable(modbus,True,-1)
	DataInterval(0,60,Min,10)
	Average(1,DiffVolt,FP2,False)
EndTable

DataTable(soh,True,-1)
	DataInterval(0,1440,Min,10)
	Minimum(1,BattV,FP2,False,False)
	Average(1,PTemp_C,FP2,False)
EndTable

BeginProg

	Scan(10,Sec,1,0)
		Battery(BattV)
		PanelTemp(PTemp_C,50)
		VoltDiff(DiffVolt,1,mV2500,1,True,500,50,1,0)

		SerialOpen (Com1,19200,2,0,50)
		ModbusClient (Result,Com1,19200,8,04,rtu_var_8(),40000,1,3,50,1)

		CallTable modbus
		CallTable soh
	NextScan
EndProg

 

The most disturbing is that "Result" variable display no result code, but only increment 1 as the "Record No" variable in Public table.

According to the sensor documentation, I'm trying to read the body temp. (register 8), that's an Input Register (function 04), with a start register of 30000 (according to the modbus help doc), I don't know the lenght (1, but I tried other number), and I add a Modbus option 3 to get a 16bit signed integer, according to the sensor doc too.

Previously of this, I set the Com1 (C1/C2) in parity Even, in 8 bits and 1 stop.


Sam Apr 7, 2024 06:40 PM

"Result" variable holds the results of the communication attempt. "Result" will be 0 if communication is successful. If "Result" is incrementing by 1, the Datalogger is failing to communicate with the sensor.

What are some things that would lead to failed communication?

* The sensor is not powered, so cannot respond

* The sensor is not wired to the Datalogger correctly, so it cannot receive the command or respond

* The serial port has not been opened

* The serial port has not been configured correctly (baud rate, parity, stop bit, data bit)

You noted that you have a CR300 and Kipp & Zonen SMP3. Your program indicates that you are using COM1.

The SMP3 manual, tells us that the SMP pyranometer has two types of data connections - one is RS-485 (Modbus RTU) and the other is analog out.

The CR300 does not have a native RS-485 port.

So it is important to understand if you have a RS-232-to-RS-485 or TTL-to-RS-485 converter sitting between the CR300 COM1 and the SMP3 sensor. If you do not, communication between the CR300 and SMP3 over serial will not be successful.


Benjamin.vial Apr 9, 2024 05:47 AM

Hello Sam,

Ok thanks for this, I didn't get that modbus is actually RS485, and indeed no support of this on CR300.

I have two options :

- Take a conveter for the RS485 / 232 conversion. Is Campbell sell basic conveter ? The MD485 seem a little over featured for my application, but it's the only one I've seen..

- Maybe use the analog +/- channel of the SMP3 but, that's too bad to have a modbus digital output and no be able to use it (and with digital output I can't go throught dozens meters of wire without loss.

What do you think about it ?


Benjamin.vial Apr 22, 2024 06:30 AM

Hi,

I close this problematic by buying a CR350, don't have the time to investigate further.

Thanks for your help,

bye.

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