Hello,
I purchased a CR310 which is connected with a Vaisala WXT weather station. The protocol between the CR310 and the Vaisala is SDI-12.
I made with ShortCut an initial program in order to send the table via the FTPClient. The transferts are correct.
Thus I add the instructions in order to put the CR310 in modbusslave. I used the Campbell docs.
The program compiled right. (the source of it is pasted below).
If I use a pyModbus in Python or a soft as Modbus Doctor the Modbus connection goes right on the 502 port but the returned sequence has errors.
I already made a lot of tests, modifs on the prg but it's always bad.
Thus if somebody has an idea on my mistake it will be very usefull.
For info the prg is still running on the CR310 and I receive always the table via the FTPClient. For test I had comment the FTPClient line without success.
I thank you very much for your help.
Didier Brunel
The source:-----------------------------------------------
'CR300 Series
'Created by Short Cut (4.0)
' Inclut la fonction ModBusSlave
' DB 17nov20
'Declare Variables and Units
Public BattV
Public PTemp_C
Public WXT(7)
Public FTPResult
Public ModbusVariable(8)
Public DummyVar As Boolean
Alias WXT(1)=WindDir
Alias WXT(2)=WS_ms
Alias WXT(3)=AirTC
Alias WXT(4)=RH
Alias WXT(5)=BP_mbar
Alias WXT(6)=Rain_mm
Alias WXT(7)=HAmount
Units BattV=Volts
Units PTemp_C=Deg C
Units WindDir=Degrees
Units WS_ms=meters/second
Units AirTC=Deg C
Units RH=%
Units BP_mbar=mbar
Units Rain_mm=mm
Units HAmount=hits/cm^2
'Define Data Tables
DataTable(CALF_Vaisala,True,-1)
DataInterval(0,1,Min,10)
Sample(1,WindDir,FP2)
FieldNames("Vent_Dir")
Sample(1,WS_ms,FP2)
FieldNames("Vent_Vitesse")
Sample(1,AirTC,FP2)
FieldNames("Temp_Air")
Sample(1,RH,FP2)
FieldNames("Hygro")
Sample(1,BP_mbar,FP2)
FieldNames("Pression_mbar")
Sample(1,Rain_mm,FP2)
FieldNames("Pluie_mm")
Sample(1,HAmount,FP2)
FieldNames("Grele_counts")
Sample(1,BattV,FP2)
FieldNames("V_CR310")
EndTable
'Main Program
BeginProg
'Main Scan
' Configuration de la CR310 en ModBus SLAVE
ModbusSlave (502,115200,1,ModbusVariable(),DummyVar,2)
Scan(5,Sec,1,0)
'Default CR300 Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default CR300 Datalogger Processor Temperature measurement 'PTemp_C'
PanelTemp(PTemp_C,50)
'WXT520 Weather Transmitter measurements 'WindDir', 'WS_ms', 'AirTC',
'RH', 'BP_mbar', 'Rain_mm', and 'HAmount'
SDI12Recorder(WXT(),C1,"0","R!",1,0,-1)
'Reset all WXT520 Weather Transmitter measurements if NaN is returned to WXT(1)
If WXT(1)=NaN Then Move(WXT(),7,NaN,1)
'ModbusVariable(1) = WindDir
'ModbusVariable(2) = WS_ms
'ModbusVariable(3) = AirTC
'ModbusVariable(4) = RH
'ModbusVariable(5) = BP_mbar
'ModbusVariable(6) = Rain_mm
'ModbusVariable(7) = HAmount
'ModbusVariable(8) = BattV
ModbusVariable(1) = 1
ModbusVariable(2) = 1
ModbusVariable(3) = 4
ModbusVariable(4) = 5
ModbusVariable(5) = 7
ModbusVariable(6) = 1
ModbusVariable(7) = 1
ModbusVariable(8) = 2
'Call Data Tables and Store Data
CallTable CALF_Vaisala
NextScan
SlowSequence
Do
Delay(1,10,Sec)
FTPResult = FTPClient ("134.59.147.2", "xxxxxxx", "xxxxxxx", "CALF_Vaisala", "/isismo/CALF/METEO/CALF_Vaisala", 9, 0, 1, Min, -1008)
Loop
EndProg
The indentations were removed during the copy/paste process
Additionnal info for my former post:
I tried different Modbus softwares in order to tests the ModBusSlave on my CR310.
Le last one is ModPoll under Win10. For the 3 softs the error answer is in fact:
"Illegal Data Address exception response"
It's difficult to found a solution because the Campbells docs are not very good and on different docfiles, online, etc
The protocol ModBus is quite simple, and I don't see a solution. I post a question on the Hotline.L One answer was to purchase the comercial CRBasic editor, which is useless for me. I have access to the entire CRBasic doc on line.
Thus if somebody as an idea.
As a last test I tried to write this very short program to test ModBusslave:
----
'CR300 Series
'Created by Short Cut (4.0)
' TESTS BASIQUES POUR DEBUGGER ModbusSlave
' DB 26nov20
'Declare Variables and Units
'Par defaut cest du FLOAT 32 bits
Public ModbusVariable(8)
Public DummyVar As Boolean
'Main Program
BeginProg
' Configuration de la CR310 en ModBus SLAVE
ModbusSlave (502,115200,1,ModbusVariable,DummyVar,2)
'ModbusSlave (502,115200,1,ModbusVariable(),DummyVar,2)
'ModbusSlave (502,115200,1,ModbusVariable,DummyVar,0)
'etc, etc,
Scan(5,Sec,1,0)
'je met volontairement des valeurs numerique pour tester
ModbusVariable(1) = 1
ModbusVariable(2) = 1
ModbusVariable(3) = 4
ModbusVariable(4) = 5
ModbusVariable(5) = 7
ModbusVariable(6) = 1
ModbusVariable(7) = 1
ModbusVariable(8) = 2
NextScan
EndProg
------
As I said in may former post I already made a lot of tests on its parameters.
I thank you very much in advance,
Best regards,
Didier Brunel.
Some Modbus systems expect floating point data in reverse byte format. Try using "0" in the ModbusSlave instruction, "ModBusOption" parameter.
Hello nsw,
As you can see in my last post I already tested 0 and others values in this little test prg.
For memo in my initial prg with all the weather stuff the result is exactly the same.
Due to the return msg of my 3 Modbus utilities I think the problem is about the "data address" notion.
In the docs the concept is quite difficult for me to understand.
Thus take the example shown in my above post.
1- Which parameters have to be set in the Modbusslave fonction in order to read the 8 values of my variable from a Modbus utility ?
2- On a Modbus utility side which parameters must be set (type, number, addresses, etc) in order to read them ?
I thank you very much in advance for your help.
Best regards,
Didier Brunel.
Some Modbus systems require floating fnaf point data in reverse byte format. Try using "0" in the ModbusSlave instruction, "ModBusOption" parameter.