Campbell Scientific CSAT3B CSAT3B Three-Dimensional Sonic Anemometer - Page 86

CSAT3BDestination, Bus, Address, OperatingMode

Page 86 highlights

Appendix C. Example CRBasic Datalogger Programs PanelTemp (panel_temp,250) Battery (battery_volt) 'Measure datalogger panel temperature 'Measure battery voltage. 'CSAT3B(Destination, Bus, Address, OperatingMode) CSAT3B(wind(),1,CPI_ADDR,0) 'Copy and convert CSAT3B for compass wind vector computation. wind_east = -1*Uy wind_north = Ux 'Break up the warning flags into separate bits. diag_integer = diag diag_bits(1) = diag_integer AND &h00000001 diag_bits(2) = diag_integer AND &h00000002 diag_bits(3) = diag_integer AND &h00000004 diag_bits(4) = diag_integer AND &h00000008 diag_bits(5) = diag_integer AND &h00000010 diag_bits(6) = diag_integer AND &h00000020 diag_bits(7) = diag_integer AND &h00000040 diag_bits(8) = diag_integer AND &h00000080 diag_bits(9) = diag_integer AND &h00000100 'Turn on this intermediate processing disable flag when any 'warning flag is set or the data returned is NaN disable_stats(1) = ((diag_integer AND &hffffffff) OR (diag = NaN)) 'Turn on this intermediate processing disable flag only when 'CSAT3B diagnostic warning flags are set disable_stats(2) = ((diag_integer AND &hffffffff) AND NOT (diag = NaN)) 'Compute the online wind vector statistics. CallTable DataWindVec If (DataWindVec.Output(1,1) ) Then GetRecord (wind_out(1),DataWindVec,1) 'Compass wind direction will be 0 to 360 degrees. wind_dir_compass = (wind_dir_compass+CSAT_AZIMUTH) MOD 360 'CSAT wind direction will be 0 to 180 or 0 to -180 degrees. If ( wind_dir_csat ) > 180 Then ( wind_dir_csat = wind_dir_csat-360 ) EndIf CallTable DataSonic CallTable DataStats NextScan SlowSequence Scan(MONITOR_INTERVAL,sec,0,0) 'CSAT3BMonitor(Destination, Bus, Address) CSAT3BMonitor(monitor(),1,CPI_ADDR) CallTable(DataMonitor) NextScan EndProg C-6

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

Appendix C.
Example CRBasic Datalogger Programs
PanelTemp (panel_temp,250)
'Measure datalogger panel temperature
Battery (battery_volt)
'Measure battery voltage.
'CSAT3B(Destination, Bus, Address, OperatingMode)
CSAT3B(wind(),1,CPI_ADDR,0)
'Copy and convert CSAT3B for compass wind vector computation.
wind_east = -1*Uy
wind_north = Ux
'Break up the warning flags into separate bits.
diag_integer = diag
diag_bits(1) = diag_integer AND &h00000001
diag_bits(2) = diag_integer AND &h00000002
diag_bits(3) = diag_integer AND &h00000004
diag_bits(4) = diag_integer AND &h00000008
diag_bits(5) = diag_integer AND &h00000010
diag_bits(6) = diag_integer AND &h00000020
diag_bits(7) = diag_integer AND &h00000040
diag_bits(8) = diag_integer AND &h00000080
diag_bits(9) = diag_integer AND &h00000100
'Turn on this intermediate processing disable flag when any
'warning flag is set or the data returned is NaN
disable_stats(1) = ((diag_integer AND &hffffffff) OR (diag = NaN))
'Turn on this intermediate processing disable flag only when
'CSAT3B diagnostic warning flags are set
disable_stats(2) = ((diag_integer AND &hffffffff) AND NOT (diag = NaN))
'Compute the online wind vector statistics.
CallTable DataWindVec
If (DataWindVec.Output(1,1) ) Then
GetRecord (wind_out(1),DataWindVec,1)
'Compass wind direction will be 0 to 360 degrees.
wind_dir_compass = (wind_dir_compass+CSAT_AZIMUTH) MOD 360
'CSAT wind direction will be 0 to 180 or 0 to -180 degrees.
If ( wind_dir_csat ) > 180 Then ( wind_dir_csat = wind_dir_csat-360 )
EndIf
CallTable DataSonic
CallTable DataStats
NextScan
SlowSequence
Scan(MONITOR_INTERVAL,sec,0,0)
'CSAT3BMonitor(Destination, Bus, Address)
CSAT3BMonitor(monitor(),1,CPI_ADDR)
CallTable(DataMonitor)
NextScan
EndProg
C-6