MODEL 6180 VERTICAL IN-PLACE INCLINOMETER SYSTEM
| CRBASIC PROGRAMMING |
21
APPENDIX D.
CRBASIC PROGRAMMING
D.1 SAMPLE CR1000 PROGRAM
The following sample program reads one 6180 sensor string with three biaxial
sensors. The string in this example communicates with the CR1000 through the
control ports C1 and C2, which are setup as COM1. A RS-485 to TTL converter
required.
'Define Data Tables
'Main Program
D.2 SAMPLE CR6 PROGRAM
The following sample program reads one 6180 sensor string with three
addressable sensors. The string in this example communicates with the CR6
through the control ports C1 and C2, which are setup as ComC1. The CR6 has
built in RS 485 capability, so no RS-485 to TTL converter is required.
'Define Data Tables
Public ErrorCode
'Error Code sent back from ModBus Command
Public A_Axis_Degrees(3) 'A Axis Degree Output
Public B_Axis_Degrees(3) 'B Axis Degree Output
Public Celsius(3)
'Temperature Celsius
Public Count
'Counter to increment through sensors
DataTable(Test,1,-1)
Sample (3,A_Axis_Degrees(),IEEE4)
'Store Degree Reading for A Axis
Sample (3,B_Axis_Degrees(),IEEE4)
'Store Degree Reading for B Axis
Sample (3,Celsius(),IEEE4)
'Store Thermistor C Reading
EndTable
BeginProg
'Open COMport with TTL communications at 115200 baud rate
SerialOpen (Com1,115200,16,0,50)
'Read 3 sensors in MEMS String every 10 seconds
Scan (10,Sec,0,0)
'Loop through addresses of connected String
For Count = 1 To 3
'Reset temporary storage for both Degrees and Temp so not to retain
'previous reading
A_Axis_Degrees(Count) = 0
B_Axis_Degrees(Count) = 0
Celsius(Count) = 0
'Flush Serial between readings
SerialFlush (Com1)
'Write to register to begin reading MEMS String
NOTE:
ModbusMaster won't send 0x118 unless "&H119" is
'
entered
ModbusMaster (ErrorCode,Com1,115200,Count,6,1,&H119,1,1,50,0)
'Delay after write register
Delay (1,1,Sec)
'Use Modbus command to retrieve A Axis and B Axis Degree Readings
ModbusMaster (ErrorCode,Com1,115200,Count,3,A_Axis_Degrees(Count),&H101,1,1,50,0)
ModbusMaster (ErrorCode,Com1,115200,Count,3,B_Axis_Degrees(Count),&H103,1,1,50,0)
'Use Modbus command to retrieve Thermistor Celsius from string
ModbusMaster (ErrorCode,Com1,115200,Count,3,Celsius(Count),&H107,1,1,550,0)
'Delay before proceeding to next reading
Delay (1,1,Sec)
Next
'Call Table to store Data
CallTable Test
NextScan
EndProg
Public ErrorCode
'Error Code sent back from ModBus Command
Public A_Axis_Degrees(3)
'A Axis Degree Output
Public B_Axis_Degrees(3)
'B Axis Degree Output
Public Celsius(3)
'Temperature Celsius
Public Count
'Counter to increment through sensors
DataTable(Test,1,-1)
Sample (3,A_Axis_Degrees(),IEEE4)
'Store Degree Reading for A Axis
Sample (3,B_Axis_Degrees(),IEEE4)
'Store Degree Reading for B Axis
Sample (3,Celsius(),IEEE4)
'Store Thermistor C Reading
EndTable