C-1
Appendix C. Example CRBasic Data
Logger Programs
The following CRBasic examples cover the most common use cases of the
CSAT3B.
C.1 Simple SDM Program
In this example, SDM communications are used to collect data from a single
CSAT3B.
CRBasic Example C-1. Simple SDM Program
'---------------------------------------------
' Define Constants, Variables, and Aliases
'---------------------------------------------
Const
SDM_ADDR = 3
'SDM Address of Device
Public
CSATVals(5)
Public
CSATMonitorVals(4)
Alias
CSATVals(1) = Ux
Alias
CSATVals(2) = Uy
Alias
CSATVals(3) = Uz
Alias
CSATVals(4) = SonTemp
Alias
CSATVals(5) = Diag
Alias
CSATMonitorVals(1) = BoardTemp
Alias
CSATMonitorVals(2) = BoardHumidity
Alias
CSATMonitorVals(3) = InclinePitch
Alias
CSATMonitorVals(4) = InclineRoll
'---------------------------------------------
' Define Data Tables
'---------------------------------------------
DataTable
(SonicData,1,-1)
Sample
(5,CSATVals(1),IEEE4)
EndTable
DataTable
(MonitorData,1,-1)
DataInterval
(0,5,Sec,10)
Sample
(4,CSATMonitorVals(1),IEEE4)
EndTable
'---------------------------------------------
' Main Program
'---------------------------------------------
BeginProg
Scan
(50,msec,500,0)
'20 Hz Scan
'CSAT3B(Destination, Bus, Address, OperatingMode)
CSAT3B(CSATVals(),0,SDM_ADDR,0)
CallTable
(SonicData)
NextScan
SlowSequence
Scan
(5,sec,0,0)
'5 second scan
'CSAT3BMonitor (Destination, Bus, Address)
CSAT3BMonitor
(CSATMonitorVals(),0,SDM_ADDR)
CallTable
(MonitorData)
NextScan
EndProg