MEMS Digital In-Place Inclinometer System
Quick Start Up Guide
ICM0095B
RST Instruments Ltd.
13
F
IGURE
5-7
CR6
CODE
‘Constants and variables definitions
Const n_ipi =
n
'Number of IPI sensors per chain,
replace ‘n’ with
number of IPIs in string
Dim modbus_serial_number(n_ipi) As Long
'IPI Sensor SN for Modbus protocol
Public ipi_sn(n_ipi) = {
xxxxx,yyyyy,…,nnnnn
}
'IPI Sensor SN,
replace “xxxxx” with correct SN for
each IPI, separated by comma
Public modbus_result(n_ipi)
'Modbus 1 bit result code for acknowledge
Public ipi_data(n_ipi,3)
'A Axis, B Axis and Temp data array
Dim i
Public interface_banner As String * 64
‘Define data tables
DataTable (IPI_GEN4_table,1,-1)
Sample(n_ipi*3,ipi_data(),IEEE4)
'Presents the sensor data for all sensors per string
EndTable
‘Main P
rogram
BeginProg
'Open serial port
SerialOpen(ComC1,9600,0,0,128,4)
SerialFlush(ComC1)
'Guard against serial number error causing incorrect data
SerialOut(ComC1,"@@65534 MBA 247 247"+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(ComC1)
'Set devices endianness to standard CDAB
SerialOut(ComC1,"@@65534 TXO 0"+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(ComC1)
'Set & Verify Modbus Addresses
For i = 1 To n_ipi
'up to the number of IPI sensors
'Set device Modbus address command to default 1 to "n_ipi"
SerialOut(ComC1,"@@"+ipi_sn(i)+" MBA "+i+" "+i+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(ComC1)
Next i
Scan (1,Min,0,0)
‘Reading interval per IPI string
'Power Up Bus & query Sensors for current reading
For i = 1 To n_ipi
'Read A Axis, B Axis and Temp starting from 0x30 register
ModbusMaster(modbus_result(i),ComC1, 9600,i,3,ipi_data(i,1),49,3,3,300)
Delay(0,50,mSec)
Next i
CallTable IPI_GEN4_table
‘Call table to store the data
NextScan
EndProg