Campbell Scientific CR7 Measurement and Control System User Manual
Page 87

SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES
8-5
04:
P37
Z=X*F
01:
1
X Loc WS
02:
10
F
03:
4
Z Loc [:WS output]
05:
P37
Z=X*F
01:
3
X Loc 0-540 WD
02:
1.8519
F
03:
5
Z Loc [:WD output]
06:
P21
Analog Out
01:
1
EX Card
02:
1
CAO Chan
03:
4
mv Loc WS output
07:
P21
Analog Out
01:
1
EX Card
02:
2
CAO Chan
03:
5
mv Loc WD output
08:
P92
If time is
01:
0
minutes into a
02:
60
minute interval
03:
10
Set high Flag 0 (output)
09:
P69
Wind Vector
01:
1
Rep
02:
180
Samples per sub-interval
03:
00
Polar Sensor/(S, D1, SD1)
04:
1
Wind Speed/East Loc WS
05:
2
Wind Dir./North Loc 0-360 WD
10:
P
End Table 1
8.5 CONVERTING 0-360 WIND
DIRECTION OUTPUT TO 0-540 FOR
STRIP CHART
If 0-360 degree wind direction is output to a strip
chart, the discontinuity at 0/360 will cause the
pen to jump back and forth full scale when the
winds are varying from the north. In the days of
strip charts this was solved with a 0-540 degree
pot on the wind vane (direction changes from
540 to 180 and from 0 to 360 so the pen only
jumps once when the wind is out of the north or
south).
When faced with the necessity of strip chart
output (see previous example), the following
algorithm can be used to change a 0-360
degree input to 0-540. (If you have a 0-540 pot,
it can be used with the 21X since the Wind
Vector Instruction, 69, will work with this output.)
To change 0-360 degrees to the 0-540 degrees,
360 degrees must sometimes be added to the
reading when it is in the range of 0 to 180. The
following algorithm does this by assuming that if
the previous reading was less than 270, the
vane has shifted through 180 degrees and does
not need to be altered. If the previous 0-540
reading was greater than 270, 360 degrees is
added.
This example is written as a subroutine which is
used by the previous example to output an
analog voltage to a strip chart.
Input Location Labels:
1:WS
2:0-360 WD
3:0-540 WD
4:WS output
5:WD output
*
3
Table 3 Subroutines
01:
P85
Beginning of Subroutine
01:
1
Subroutine Number
02:
P89
If X<=>F
01:
3
X Loc 0-540 WD
02:
3
>=
03:
270
F
04:
30
Then Do
03:
P86
Do
01:
11
Set high Flag 1
04:
P94
Else
05:
P86
Do
01:
21
Set low Flag 1
06:
P95
End
07:
P31
Z=X
01:
2
X Loc 0-360 WD
02:
3
Z Loc [:0-540 WD ]
08:
P89
If X<=>F
01:
3
X Loc 0-540 WD
02:
4
<
03:
180
F
04:
30
Then Do