B-1
Appendix B. Example Program
This program example is for a weather station measuring wind speed, wind
direction, temperature, and relative humidity. Each parameter is scaled to 0 to
10000 mVDC, and output to a SCADA system through the SDM-CVO4.
CRBasic Example B-1. CR1000X Program Using an SDM-CV04 to Output to a SCADA
System
Public
WS_ms
Public
WD_0_360
Public
Temp_C
Public
RH
Public
WD_0_540
Public
CVO4Output(4)
Alias
CVO4Output(1) = WSOut
Alias
CVO4Output(2) = WDOut
Alias
CVO4Output(3) = TempOut
Alias
CVO4Output(4) = RHOut
'Code for DataTable OneMin
DataTable
(OneMin,1,-1)
DataInterval
(0,1,Min,0)
WindVector
(1,WS_ms,WD_0_360,IEEE4,0,0,0,0)
Average
(1,Temp_C,IEEE4,0)
Sample
(1,RH, IEEE4)
EndTable
BeginProg
Scan
(1,Sec,1,0)
'Code for 03002 wind measurements, WS_ms & WD_0_360:
PulseCount
(WS_ms,1,P1,5,1,0.75,0.2)
BrHalf
(WD_0_360,1,mV1000,1,Vx1,1,1000,True,2000,60,355,0)
'Code for HMP60 measurement, AirTC and RH:
VoltSe
(Temp_C,1,mV1000,3,0,0,60,0.1,-40.0)
VoltSe
(RH,1,mV1000,2,0,0,60,0.1,0)
' Call Data Table
CallTable
(OneMin)
'Convert 0-360 WD to 0-540:
If
WD_0_540 >= 270
AND
WD_0_360 <180
Then
WD_0_540 = WD 360
Else
WD_0_540 = WD_0_360
EndIf
'Scale the measurements for the SDM-CVO4 to output 0-10000 mV
WSOut = WS_ms*200
'WS: 0-50 m/s = 0-10000 mV
WDOut = WD_0_540 *18.59
'WD: 0-540 deg = 0-10000mV
TempOut= 100*(40)
'Temp: -40-60 deg C = 0-10000 mV
RHOut = RH *100
'RH: 0-100 % RH = 0-10000 mV
'Send mV outputs to SDM-CVO4 using the option to override the switch settings
SDMCVO4
(CVO4Output(),4,0,10)
NextScan
EndProg