MEMS Digital In-Place Inclinometer System
Quick Start Up Guide
ICM0095B
RST Instruments Ltd.
18
F
IGURE
5-15
CR310
CODE
'Constants and variables definitions
Const n_ipi =
n
'Number of IPI sensors per chain, replace
‘n’ with number of IPIs in string
Public ipi_sn(n_ipi) = {
xxxxx,yyyyy,…,nnnnn
}
'IPI Sensor SN,
replace “xxxxx” with correct
SN
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 chain
EndTable
'Main Program
BeginProg
'Open serial port
SerialOpen(Com1,115200,0,0,128,4)
SerialFlush(Com1)
'Read in interface banner, set mode on program run --- continuous reading mode
SerialOut(Com1,"MODE 0"+CHR(13),"",1,0)
SerialIn(interface_banner,Com1,200,CHR(13),100)
Delay(0,1,Sec)
SerialFlush(Com1)
'Guard against serial number error causing incorrect data
SerialOut(Com1,"@@65534 MBA 247 247"+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(Com1)
'Set devices endianness to standard CDAB
SerialOut(Com1,"@@65534 TXO 0"+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(Com1)
'Set 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(Com1,"@@"+ipi_sn(i)+" MBA "+i+" "+i+CHR(13),"",1,0)
Delay(0,1,Sec)
SerialFlush(Com1)
Next i
Scan (1,Min,0,0)
'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),Com1,115200,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