CS115 Barometric Pressure Sensor
5.1.4Period Averaging Measurement Example for CR5000 in a Fast Executing Program at 10Hz
EXAMPLE 4. Sample Program for CR5000
‘CR5000
'
'Sample Program to Measure CS115 Barometric Pressure Sensor
' |
|
' |
|
Public | CS115_Freq, Pressure |
Units | Pressure = mb |
BeginProg
Scan (100,mSec,3,0)
'Turn CS115 ON one minute before every hour
'
If (IfTime (59,60,min)) Then WriteIO (1,1)
'Period Avgeraging instruction must be executed every scan, and 'cannot be inside the "If" statement. The measured value, therefore, is 'first written into a temporary variable called "CS115_Freq".
PeriodAvg (CS115_Freq,1,mV5000,33,0,1,10,20,1.0,0)
'Once CS115 is turned on one minute before every hour, and
'the correct measurement is made, it is copied into the current variable 'called "Pressure". The sensor is, then, turned off.
'
If IfTime(0,60,min) Then
Pressure = CS115_Freq
'Turns CS115 OFF
'
WriteIO (1,0)
EndIf
NextScan
EndProg
11