beautypg.com

Campbell Scientific CR510 Basic Datalogger User Manual

Page 100

background image

SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES

8-4

PROGRAM

*

Table 1 Program

01:

10.0

Execution Interval (seconds)

01:

Pulse (P3)
1:

1

Reps

2:

1

Pulse Input Channel

3:

2

Switch Closure

4:

10

Loc [ Precip_1 ]

5:

.254

Mult

6:

0

Offset

02:

Pulse (P3)
1:

1

Reps

2:

3

Pulse Channel 3

3:

2

Switch Closure

4:

11

Loc [ Precip_2 ]

5:

.254

Mult

6:

0

Offset

03:

If time is (P92)
1:

0

Minutes (Seconds --) into a

2:

60

Interval (same units as above)

3:

10

Set Output Flag High

04:

Real Time (P77)
1: 0110

Day,Hour/Minute

05:

Totalize (P72)
1:

2

Reps

2:

10

Loc [ Precip_1 ]

INPUT LOCATIONS

10 Precip_1
11 Precip_2

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, 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
CR510 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 to output an analog voltage to a strip
chart.

*

Table 3 Subroutines

01:

Beginning of Subroutine (P85)
1:

1

Subroutine 1

02:

IF (X<=>F) (P89)
1: 10

X Loc [ 0_540_WD ]

2:

3

>=

3: 270

F

4: 30

Then Do

03:

Do (P86)
1: 11

Set Flag 1 High

04:

Else (P94)

05:

Do (P86)
1: 21

Set Flag 1 Low

06:

End (P95)

07:

Z=X (P31)
1:

2

X Loc [ 0_360_WD ]

2: 10

Z Loc [ 0_540_WD ]

08:

IF (X<=>F) (P89)
1: 10

X Loc [ 0_540_WD ]

2:

4

<

3: 180

F

4: 30

Then Do

09:

If Flag/Port (P91)
1: 11

Do if Flag 1 is High

2: 30

Then Do

10:

Z=X+F (P34)
1: 10

X Loc [ 0_540_WD ]

2: 360

F

3: 10

Z Loc [ 0_540_WD ]

11:

Z=X (P31)
1: 10

X Loc [ 0_540_WD ]

2:

6

Z Loc [ 0_540_out ]