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.

CR300 Modbus


PPeters Jun 28, 2017 11:55 PM

I have hit a road block with a modbus sensor so hoping for some assistance.

I had the sensor currently running on a CR1000 platform but had some conflict issues and reulting instability of the main program so my plan was to shift the sensor to a CR310 as a development platform.

The problem I have is that the sensor will not work on the 310... I can set it up on an 800 and it works fine but I want to use the 310 as I will be using a switch on site for network access.

The code for the 310 was a cut n paste job from the 1000 but I cant see any obvious setting issues, using com1 on the 310 set to 9600 as before on the 1000 (com2)

both codes below (condensed 800) to play spot the difference

any help much appreciated

CR800


'Declare Public Variables


Public ModbusResult
Public Modbus(7) As Float

Alias Modbus(1) = PT1000_R
Alias Modbus(2) = Fluid_DegC
Alias Modbus(3) = LDens_DegC
Alias Modbus(4) = LDens_Period
Alias Modbus(5) = LDens_freq
Alias Modbus(6) = Density
Alias Modbus(7) = Spec_Gravity

Public Batt_Volt
Public Version
Public Prog_Sig
Public J_Day


'Declare Other Variables
Dim LoggerTime(9)

Units PT1000_R = Ohms
Units Fluid_DegC = DegC
Units LDens_DegC = DegC
Units LDens_Period = usec
Units LDens_freq = Hz
Units Density = g/cm3
Units Spec_Gravity = SG(TC)

'Declare Constants
Const Software = 104
Const Edition = 15 ' Increment for changes in program, ie sensors added and offset changes (integer)
StationName ("Manawatu at Teachers College")

'Define Data Tables
DataTable (Data_Status,Flag(1),20)
Sample (1,Batt_Volt,ieee4)
Sample (1,Prog_Sig,ieee4)
Sample (1,Version,ieee4)
EndTable

DataTable (Data_Density,True,-1 )
DataInterval (0,15,Min,10)
Sample (1,PT1000_R,IEEE4)
Sample (1,Fluid_DegC,IEEE4)
Sample (1,LDens_DegC,IEEE4)
Sample (1,LDens_Period,IEEE4)
Sample (1,LDens_freq,IEEE4)
Sample (1,Density,IEEE4)
Sample (1,Spec_Gravity,IEEE4)
Sample (1,ModbusResult,IEEE4)
EndTable

'Define Subroutines


'EndSub
'
'Main Program
BeginProg
Prog_Sig = status.ProgSignature
Version = (Software) + (Edition/100)
Flag(1) = 1
SerialOpen(Com2,9600,2,0,1000)


Scan (30,Sec,3,0) 'Standard sensor activation
' Calculate Julian day
RealTime(LoggerTime())
J_Day = LoggerTime(9)
Battery (Batt_Volt)


CallTable Data_Status
Flag(1)=0

NextScan


SlowSequence
Scan (30,Sec,3,0)

'Call the Density Sensor, L-Dens on modbus slave 1
ModbusMaster(ModbusResult,Com2,9600,1,4,Modbus(),30019,7,3,500,2)

CallTable Data_Density
NextScan

EndProg

and cr310 code


'Declare Public Variables
Public ModbusResult
Public Modbus(7) As Float

Alias Modbus(1) = PT1000_R
Alias Modbus(2) = Fluid_DegC
Alias Modbus(3) = LDens_DegC
Alias Modbus(4) = LDens_Period
Alias Modbus(5) = LDens_freq
Alias Modbus(6) = Density
Alias Modbus(7) = Spec_Gravity

Public Batt_Volt
Public Version
Public Prog_Sig
Public J_Day

Public Flag(5) ' Sets up 4 flags for program control

'Declare Other Variables
Dim LoggerTime(9)

Units PT1000_R = Ohms
Units Fluid_DegC = DegC
Units LDens_DegC = DegC
Units LDens_Period = usec
Units LDens_freq = Hz
Units Density = g/cm3
Units Spec_Gravity = SG(TC)

'Declare Constants
Const Software = 907
Const Edition = 01 ' Increment for changes in program, ie sensors added and offset changes (integer)
StationName ("Manawatu at Teachers College Modbus")


'Define Data Tables
DataTable (Data_Status,Flag(1),200)
Sample (1,Batt_Volt,ieee4)
Sample (1,Prog_Sig,ieee4)
Sample (1,Version,ieee4)
EndTable

DataTable (Data_TCO_Density,True,-1 )
DataInterval (0,15,Min,10)
Sample (1,PT1000_R,IEEE4)
Sample (1,Fluid_DegC,IEEE4)
Sample (1,LDens_DegC,IEEE4)
Sample (1,LDens_Period,IEEE4)
Sample (1,LDens_freq,IEEE4)
Sample (1,Density,IEEE4)
Sample (1,Spec_Gravity,IEEE4)
Sample (1,ModbusResult,IEEE4)
EndTable

'Define Subroutines


'EndSub
'
'Main Program
BeginProg
Prog_Sig = status.ProgSignature
Version = (Software) + (Edition/100)
Flag(1) = -1


Scan (30,Sec,3,0)
RealTime(LoggerTime())
J_Day = LoggerTime(9)
Battery (Batt_Volt)
SerialOpen(Com1,9600,2,0,1000)

'Call the Density Sensor, L-Dens on modbus slave 1
ModbusMaster(ModbusResult,Com1,9600,1,4,Modbus(),30019,7,3,500,2)

CallTable Data_TCO_Density
CallTable Data_Status
Flag(1) = 0
NextScan

EndProg

Thanks 

Paul


PPeters Jul 25, 2017 04:54 AM

If anyone from CSI is reading these I would appreciate some assistance.......

is there any diference in the hardware of the CR310 vs a CR800?

I have redeployed the sensor temporarily with a CR1000 and no issues, using C3/C4 combination so curious why the 310 would not work with C1/C2.

Talking to our local supplier they mentioned something around rs232 levels and ttl? suggesting i try the rs232 port but I had tried this with no luck either

some help much appreciated


GaryTRoberts Jul 25, 2017 05:44 AM

Paul,

A bug was found recently with SerialOpen followed by the ModbusMaster instruction in the CR300 OS.  The format used in serial open was being overridden by the ModBusMaster instruction which was setting it back to the default (0) format.  We are in the process of releasing OS 6 for the CR300.  If you would like, I can send you a beta OS in the morning that has the problem resolved.  gtroberts -at- campbellsci.com.

  Gary


PPeters Jul 25, 2017 08:27 PM

Cheers Gary,

was starting to wonder if issue was more that my code and setup.

I can test the beta but wont be on site till tomorrow as the sensor is now redeployed on a CR1000 

can send through to paul.peters@horizons.govt.nz

thanks

paul

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