Hydrologic Measurement Techniques

BAE356/CE326/FOR463

Datalogger Programming

Instructor: Timothy Link (885-9465, , office: CNR 203E)

Objective

To become familiar with Campbell CR10X dataloggers, write a simple datalogger program and learn how to upload and download programs and data from the loggers.

Introduction

Automated measurement of environmental variables is really automated measurement of an electrical signal, such as voltage, current, pulses, etc., that is generated by a sensor. A datalogger is a device to measure and record these electrical signals.

There are a wide variety of dataloggers available to record a wide variety of environmental variables such as temperature, humidity, precipitation, wind speed, stream stage height, soil water content, etc. Many loggers available today are designed to measure only 1 or 2 variables, such as temperature and humidity, or events (e.g. tips on a tipping bucket rain gauge). The advantage of these loggers is that they are generally inexpensive (<$100 per logger), reasonably accurate, and easy to program. The main disadvantage is that they are limited in the number and types of variables that they can record.

On the other side of the spectrum, there are loggers that have multiple input channels, can be programmed to record a variety of different electrical signals and control (e.g. switch on/off) electrical devices. The advantage of these loggers is that they can be used for an almost infinite number of sensor configurations, and can be customized for a wide variety of communication options (e.g. short-haul modems, coaxial cable, dial-up modems, radio telemetry, etc.). The disadvantage is that they are expensive (CR10X loggers are ~$1400), and are non-intuitive to program.

Campbell Scientific Inc. (CSI) dataloggers are widely used for many types of environmental data collection. For example, some USGS gauge stations are equipped with CSI loggers with external modems and voice synthesizers so that the public can obtain the flow at a particular station over the phone. At one point the HVAC system at the CSI headquarters was even controlled by a CSI datalogger and control module!

Campbell CR10 Datalogger

Today we’ll be working with CR10 dataloggers. CSI makes a range of other loggers with more or less channels and storage capacity. The updated version of the CR10, the CR10X is widely used because it contains about the right amount of channels to operate a small meteorological station and non-volatile memory. The current equivalent logger is the CR1000 which uses CRBasic as a programming language, however there are still many of the older loggers in service which use the older Edlog programming language that we’ll use in this laboratory session.

See the CR10X overview…

Procedure:

1.) Power up logger and connect to computer as instructed in class.

2.) Start LoggerNet – Campbell’s support software (note: the previous version of this software was called PC208W, but is essentially the same)

You should get a graphical user interface (GUI) that looks like this:

3.) Check communication

a.) Click: SetupAdd…CR10

Select CR10 (or appropriate datalogger model) and click Add Now.

b.) Click: Connect

Select the station you just added from the list on the left  Click Connect

Note Datalogger and PC clock in upper right corner of dialog box

Verify that the computer clock is correct (time.gov)  Click Set Station Clock

This synchronizes the datalogger clock to the PC clock

4.) Start Program
Go back to the Support Software GUI and click Edlog

This will open Edlog

Click FileNew to get the basic program shell as shown below.

Select theCR10 radio button, and click OK

You should get a screen that looks like this:

5.) Write Program

Here are the basic elements that you will want your program to have:

1.) Execution interval

2.) Instructions to read sensors

Use Edit  Insert Instruction

Right clicking on an instruction’s field you give a list of available options

3.) Instructions to output selected data to final storage at a specified time interval.

4.) Program comments (lines preceded by a semicolon) indicating what the instructions in the program are doing, and listing serial numbers and calibration coefficients (if applicable) of all sensors used.

6.) Compile Program

To compile the program click: Compile  Compile Program, or save your file.

Compiling the program will check the program for errors and create the following files:

(¡¡ Warning !! Just because a program compiles doesn’t mean that it’s going to do what you want it to !!)

Download (*.DLD) File: this is the binary program file that you will upload to the logger.

Final Storage Label (*.FSL) File: this file lists the variables that will be output to the different storage locations.

Program Trace Information (*.PTI) File: this file lists the program instructions and time that it takes to complete each instruction.

Edlog Program File (*.CSI): this is the file that you create or edit in Edlog.

7.) Upload Program

Open the datalogger connection, and connect the logger (if needed).

Click Associate DLD Program, and select your program

Click Send, and a dialog box will pop up when your program has been successfully uploaded.

8.) Monitor Program

On the datalogger connection screen, select the numeric display tab on the bottom.

Observe the data values changing.

Are the numbers reasonable?

Do the sensors respond to perturbations?

9.) Download data

After your program runs for several minutes, download the collected data.

Select the Tools tab on the datalogger connection window.

Click the collect button to download data to your computer.

Select the View button on the Datalogger Support Software window, or import your data into Excel or other spreadsheet program.

10.) Write a wiring diagram

Write down a listing of the sensors that you will be installing on your logger, and what terminal block each colored wire should go to (see attached example).

This step is critical, because otherwise, when you go to install your station you will have no clue where the wires should go !!

Datalogger Programming Lab Exercise.

Program your CR10 to do the following:

1.) Measure the air temperature (in °C) on 3 Type-T thermocouples every 1 s.

  • A note on thermocouple measurements:
    Thermocouples produce a differential voltage that is proportional to the temperature difference between the thermocouple junction and the terminal strip (reference temperature). For this exercise, just use the logger internal temperature as the reference temperature.

2.) Measure the total precipitation (in mm) with a tipping-bucket raingauge.

  • Use the Pulse Count Instruction configured for switch closure.
  • Assume that the rain gauge is calibrated to record 0.01 inches per tip. A multiplier of 0.254 should therefore be used.

3.) Measure the incoming solar radiation in (W m-2) with a Matrix Sol-a-meter pyranometer.

4.) Measure windspeed with an anemometer with photochopper output.

5.) Output the year, date, time, average temperatures, totalized precipitation, average solar radiation and average wind speed every 1 min.

Generate 5-10 minutes of data:

- place one sensor in a hot location (e.g. top of computer monitor)

- place one sensor in a warm location (e.g. side of computer monitor)

- place one sensor in a cool location (e.g. table top)

- move them around – put some variability in the data!

- generate a series of pulses on the simulated raingauge and anemometer

- generate some radiation variability

What to turn in:

For this exercise, turn in a lab report following the outline listed on the course syllabus. For this lab, your writeup should be very brief, since there is little data analysis and interpretation involved.

For your results and discussion, you should address and answer the following questions:

  • Did your program work as expected? If not, what was the problem?
  • What changes or refinements might you consider making to your program?
  • How long will your program run before the data will stop or begin to overwrite assuming that the logger you are using has 62,280, i.e. the default number of final storage locations?
  • How many seconds does it take your program to execute without output?
  • How many seconds does it take your program to execute with output?

You should also include the following items in your appendix:

1.) A listing of your Edlog program (*.CSI) file.

note: be sure to thoroughly comment your program, including serial numbers of the sensors you are using !!

2.) A printout of the Final Storage Label (*.FSL) file

3.) A printout of the Program Trace Information (*.PTI) file

4.) Plots of 5-10 minutes of output data produced by your program

5.) A wiring diagram for your logger installation.

Example Wiring Diagrams:

Mica Creek Supplemental Met Station Wiring Diagram
Temperature/Humidity Probe
HMP45CCR10Xcomment

red12Vpower

yellowSE1temp. signal

blueSE2RH signal

blackAGpower ground

purpleAGsignal reference

screenGshield

orangeC1power control

Mechanical Anemometer
Met-One 034B

redP1pulse input

blackGpulse reference

clearGshield

greenSE3direction signal

blueE1switched excitation

whiteAGsignal reference

Snow Depth Sensor
Judd Snow Depth Sensor

red12Vpower

blackGpower ground

clearGshield

greenC2power controller

white3Htemp and depth inputs

brown3Ltemp and depth inputs

bluenot used

Soil Temperature Probe
CS107s

redSE7temp. signal

blackE2excitation

whiteAGground

clearGshield

Soil Water Content Sensor
CS616

red12Vpower

greenSE8water content signal

orangeC3power control

blackGoutput ground

clearGshield/power ground

SE / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 11 / 12
DIFF / 1 / 2 / 3 / 4 / 5 / 6 / G / EX1 / EX2 / G / EX3 / EX4 / G / CAO1 / CAO2 / G / P1 / G / P2 / G / P3 / G / P4 / G
H / L / G / H / L / G / H / L / G / H / L / G / H / L / G / H / L / G
o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o
com odd H / com odd L / ground / com even H / Com even L / ground / orange / green / white/purple / CS616_1 grn / CS616_2 grn / 3X4WPB100 / black HMP
AM16/32 (4x32 mode) / HMP45C212
SE / 13 / 14 / 15 / 16 / 17 / 18 / 19 / 20 / 21 / 22 / 23 / 24 / POWER OUT / CONTROL I/O
DIFF / 7 / 8 / 9 / 10 / 11 / 12 / G / 5V / G / SW12 / G / 12V / 12V / G / C1 / C2 / C3 / C4 / G / C5 / C6 / C7 / C8 / G
H / L / G / H / L / G / H / L / G / H / L / G / H / L / G / H / L / G
o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o / o
green metone / CNR1/CG1 heat / SR50black / HMP/SR50 red / metone white / AM16/32 res / AM16/32clock / HMPyellow / metone orange / metone blue / SR50 green / CS616_1orange / CS616_2orange / SR50 whire/clear
s
Working title: SE23X
Sensor Information
KH20: s/n 1489 path(x) 1.332, Kw -0.1542 XKw -0.205, full vapour range
CNR1_hi s/n 020381; sensitivity 10.03 uV/W/m2 mult:99.701
CR 23X MICROLOGGER
s/n:???? - University of Wales - in Saskatoon / * switch control - C4, 12V and red on HMP45C

Example Edlog Program:

;{CR10X}

;

; /======\

; | Logger Program for Mica Creek Supplemental Met Stations |

; | Sensors: |

; | Vaisala HMP45C Temp/RH probe |

; | Met-One 034B windset |

; | CS107 Thermistor |

; | Judd Sonic Snow Depth Sensor |

; | CS616 Soil Water Content Sensors |

; \======/

;

*Table 1 Program

01: 10.0000 Execution Interval (seconds)

;Check battery voltage

1: Batt Voltage (P10)

1: 1 Loc [ bv ]

;Enable Vaisala RH/Temp Probes

2: Do (P86)

1: 41 Set Port 1 High

;Vaisala Temp/RH meter

;Pause for 150 ms for reading to stabilize

3: Excitation with Delay (P22)

1: 1 Ex Channel

2: 0 Delay W/Ex (units = 0.01 sec)

3: 15 Delay After Ex (units = 0.01 sec)

4: 0 mV Excitation

;Measure air temp and output in degrees C

4: Volt (SE) (P1)

1: 1 Reps

2: 5 2500 mV Slow Range

3: 1 SE Channel

4: 2 Loc [ Ta ]

5: .1 Mult

6: -40 Offset

;Measure RH and output as a fraction

5: Volt (SE) (P1)

1: 1 Reps

2: 5 2500 mV Slow Range

3: 2 SE Channel

4: 3 Loc [ RH ]

5: 0.001 Mult

6: 0 Offset

;Power off Vaisala

6: Do (P86)

1: 51 Set Port 1 Low

;Compute saturation vapor pressure

7: Saturation Vapor Pressure (P56)

1: 2 Temperature Loc [ Ta ]

2: 11 Loc [ e_sat ]

;Compute vapor pressure for averaging

8: Z=X*Y (P36)

1: 11 X Loc [ e_sat ]

2: 3 Y Loc [ RH ]

3: 10 Z Loc [ e_a ]

;Met-One 034B Wind Speed & Direction

9: Pulse (P3)

1: 1 Reps

2: 1 Pulse Channel 1

3: 22 Switch Closure, Output Hz

4: 4 Loc [ u_speed ]

5: .7990 Mult

6: .2811 Offset

;Set wind speed to zero if wind is not blowing

10: If (X<=>F) (P89)

1: 4 X Loc [ u_speed ]

2: 1 =

3: .2811 F

4: 30 Then Do

11: Z=F (P30)

1: 0 F

2: 0 Exponent of 10

3: 4 Z Loc [ u_speed ]

12: End (P95)

;Met 1 Wind Direction

13: AC Half Bridge (P5)

1: 1 Reps

2: 25 2500 mV 60 Hz Rejection Range

3: 3 SE Channel

4: 1 Excite all reps w/Exchan 1

5: 2500 mV Excitation

6: 5 Loc [ u_dir ]

7: 720.0 Mult

8: 0.0 Offset

;Measure snow depth every 0.5 hours

14: If time is (P92)

1: 0 Minutes (Seconds --) into a

2: 30 Interval (same units as above)

3: 1 Call Subroutine 1

;Measure CS107 Soil Temp Probe

15: Temp (107) (P11)

1: 1 Reps

2: 7 SE Channel

3: 2 Excite all reps w/E2

4: 6 Loc [ CS107_1 ]

5: 1.0 Mult

6: 0.0 Offset

;Measure CS616 Water Content Probe every 0.5 hours

16: If time is (P92)

1: 0 Minutes (Seconds --) into a

2: 30 Interval (same units as above)

3: 30 Then Do

17: CS616 Water Content Reflectometer (P138)

1: 1 Reps

2: 8 SE Channel

3: 3 C3 is first of sequential Control Ports used

4: 12 Loc [ period_1 ]

5: 1.0 Mult

6: 0.0 Offset

;Convert period to VWC using factory calibration for loam soil

18: Polynomial (P55)

1: 1 Reps

2: 12 X Loc [ period_1 ]

3: 7 F(X) Loc [ vwc_1 ]

4: -0.0663 C0

5: -0.0063 C1

6: 0.0007 C2

7: 0.0 C3

8: 0.0 C4

9: 0.0 C5

;End instruction for If -> Then Do instruction

19: End (P95)

; /======\

; | OUTPUT DATA TO FINAL STORAGE EVERY 0.5 hr |

; \======/

20: If time is (P92)

1: 0000 Minutes (Seconds --) into a

2: 30 Interval (same units as above)

3: 10 Set Output Flag High (Flag 0)

21: Set Active Storage Area (P80)^14085

1: 1 Final Storage Area 1

2: 300 Array ID

22: Real Time (P77)^16946

1: 1220 Year,Day,Hour/Minute (midnight = 2400)

23: Average (P71)^32112

1: 1 Reps

2: 2 Loc [ Ta ]

24: Average (P71)^21201

1: 1 Reps

2: 10 Loc [ e_a ]

25: Wind Vector (P69)^6508

1: 1 Reps

2: 0000 Samples per Sub-Interval

3: 00 Sensor/Output Option

4: 4 Wind Speed/East Loc [ u_speed ]

5: 5 Wind Direction/North Loc [ u_dir ]

26: Maximum (P73)^27830

1: 1 Reps

2: 0 Value Only

3: 4 Loc [ u_speed ]

;Output avg. soil temp, vwc, Judd temp, and snow depth

27: Average (P71)^11268

1: 4 Reps

2: 6 Loc [ CS107_1 ]

; /------\

; | END FINAL STORAGE DATA OUTPUT |

; \------/

*Table 2 Program

02: 0.0000 Execution Interval (seconds)

*Table 3 Subroutines

; /======\

; | Subroutine to measure Judd sonic depth sensor |

; \======/

1: Beginning of Subroutine (P85)

1: 1 Subroutine 1

;Turn sensor on

2: Do (P86)

1: 42 Set Port 2 High

;Wait 0.6s for sensor to output Ta

3: Excitation with Delay (P22)

1: 2 Ex Channel

2: 60 Delay W/Ex (units = 0.01 sec)

3: 0 Delay After Ex (units = 0.01 sec)

4: 0 mV Excitation

;Measure air temperature

4: Volt (Diff) (P2)

1: 1 Reps

2: 5 2500 mV Slow Range

3: 3 DIFF Channel

4: 9 Loc [ Judd_temp ]

5: .2 Mult

6: -273 Offset

;Make depth measurement & perform error checking

5: Excitation with Delay (P22)

1: 2 Ex Channel

2: 180 Delay W/Ex (units = 0.01 sec)

3: 0 Delay After Ex (units = 0.01 sec)

4: 0 mV Excitation

;output depth in cm

;!!! CHANGE OFFSET !!!

6: Volt (Diff) (P2)

1: 1 Reps

2: 5 2500 mV Slow Range

3: 3 DIFF Channel

4: 8 Loc [ Snow_z ]

5: -.5 Mult

6: 0 Offset

;Power Off to Judd

7: Do (P86)

1: 52 Set Port 2 Low

;Return to main program

8: End (P95)

End Program

-Input Locations-

1 bv 1 0 1

2 Ta 1 2 1

3 RH 1 1 1

4 u_speed 1 3 2

5 u_dir 1 1 1

6 CS107_1 1 1 1

7 vwc_1 1 1 1

8 Snow_z 1 1 1

9 Judd_temp 1 1 1

10 e_a 1 1 1

11 e_sat 1 1 1

12 period_1 1 0 1

13 ______0 0 0

14 ______0 0 0

15 ______0 0 0

16 ______0 0 0

17 ______0 0 0

18 ______0 0 0

19 ______0 0 0

20 ______0 0 0

21 ______0 0 0

22 ______0 0 0

23 ______0 0 0

24 ______0 0 0

25 ______0 0 0

26 ______0 0 0

27 ______0 0 0

28 ______0 0 0

-Program Security-

0000

0000

0000

-Mode 4-

-Final Storage Area 2-

0

-CR10X ID-

300

-CR10X Power Up-

3

-CR10X Compile Setting-

3

-CR10X RS-232 Setting-

-1

-DLD File Labels-

0

-Final Storage Labels-

0,Ta_AVG~2,32112

1,e_a_AVG~10,21201

2,u_speed_S_WVT~4,6508

2,u_dir_D1_WVT~5

2,u_dir_SD1_WVT~5

3,CS107_1_AVG~6,11268

3,vwc_1_AVG~7

3,Snow_z_AVG~8

3,Judd_temp_AVG~9

4,Year_RTM,16946

4,Day_RTM

4,Hour_Minute_RTM

5,300,14085

6,u_speed_MAX~4,27830

Example Final Storage Location (*.FSL) File:

Final Storage Label File for: CONTROL_MET_STN.csi

Date: 10/25/2003

Time: 15:25:19

300 Output_Table 30.00 Min

1 300 L

2 Year_RTM L

3 Day_RTM L

4 Hour_Minute_RTM L

5 Ta_AVG L

6 e_a_AVG L

7 u_speed_S_WVT L

8 u_dir_D1_WVT L

9 u_dir_SD1_WVT L

10 u_speed_MAX L

11 CS107_1_AVG L

12 vwc_1_AVG L

13 Snow_z_AVG L

14 Judd_temp_AVG L

Estimated Total Final Storage Locations used per day 672

Example Program Trace Information (*.PTI) File:

Program Trace Information File for: CONTROL_MET_STN.csi

Date: 10/25/2003

Time: 15:25:19

T = Program Table Number

N = Sequential Program Instruction Location Number

Instruction = Instruction Number and Name

Inst ExTm = Individual Instruction Execution Time

Block ExTm = Cumulative Execution Time for program block,

i.e., subroutine

Prog ExTm = Cumulative Total Program Execution Time

Output Flag High

Inst Block Prog Inst Block Prog

ExTm ExTm ExTm ExTm ExTm ExTm

T|N|Instruction (msec) (msec) (msec) (msec) (msec) (msec)

------

1|1|10 Batt Voltage 8.3 8.3 8.3 8.3 8.3 8.3

1|2|86 Do 0.3 8.6 8.6 0.3 8.6 8.6

1|3|22 Excitation with Delay 150.5 159.1 159.1 150.5 159.1 159.1

1|4|1 Volt (SE) 4.8 163.9 163.9 4.8 163.9 163.9

1|5|1 Volt (SE) 4.8 168.7 168.7 4.8 168.7 168.7

1|6|86 Do 0.3 169.0 169.0 0.3 169.0 169.0

1|7|56 Saturation Vapor Pressure 4.5 173.5 173.5 4.5 173.5 173.5

1|8|36 Z=X*Y 1.5 175.0 175.0 1.5 175.0 175.0

1|9|3 Pulse 2.2 177.2 177.2 2.2 177.2 177.2

1|10|89 If (X<=>F) 0.6 177.8 177.8 0.6 177.8 177.8

1|11|30 Z=F x 10^n 1.0 178.8 178.8 1.0 178.8 178.8

1|12|95 End 0.2 179.0 179.0 0.2 179.0 179.0

1|13|5 AC Half Bridge 34.3 213.3 213.3 34.3 213.3 213.3

1|14|92 If time is 0.7 214.0 214.0 0.7 214.0 214.0

----Subroutine 1------

3|1|85 Beginning of Subroutine 0.0 0.0 214.0 0.0 0.0 214.0

3|2|86 Do 0.3 0.3 214.3 0.3 0.3 214.3

3|3|22 Excitation with Delay 600.5 600.8 814.8 600.5 600.8 814.8

3|4|2 Volt (Diff) 4.9 605.7 819.7 4.9 605.7 819.7

3|5|22 Excitation with Delay 1800.5 2406.2 2620.2 1800.5 2406.2 2620.2

3|6|2 Volt (Diff) 4.9 2411.1 2625.1 4.9 2411.1 2625.1

3|7|86 Do 0.3 2411.4 2625.4 0.3 2411.4 2625.4

3|8|95 End 0.2 2411.6 2625.6 0.2 2411.6 2625.6

-----End Subroutine 1 ------

1|15|11 Temp (107) 9.9 223.9 2635.5 9.9 223.9 2635.5

1|16|92 If time is 0.7 224.6 2636.2 0.7 224.6 2636.2

1|17|138 CS616 Water Content Reflectometer * 224.6 2636.2 * 224.6 2636.2

1|18|55 Polynomial 4.0 228.6 2640.2 4.0 228.6 2640.2

1|19|95 End 0.2 228.8 2640.4 0.2 228.8 2640.4

1|20|92 If time is 0.7 229.5 2641.1 0.7 229.5 2641.1

Output Flag Set @ 120 for Array 300

1|21|80 Set Active Storage Area 0.3 229.8 2641.4 0.3 229.8 2641.4

1|22|77 Real Time 0.2 230.0 2641.6 3.8 233.6 2645.2

Output Data 3 Values

1|23|71 Average 1.7 231.7 2643.3 5.9 239.5 2651.1

Output Data 1 Values

1|24|71 Average 1.7 233.4 2645.0 5.9 245.4 2657.0

Output Data 1 Values

1|25|69 Wind Vector 21.4 254.8 2666.4 74.0 319.4 2731.0

Output Data 3 Values

1|26|73 Maximum 2.2 257.0 2668.6 8.0 327.4 2739.0

Output Data 1 Values

1|27|71 Average 5.0 262.0 2673.6 19.1 346.5 2758.1

Output Data 4 Values

Program Table 1 Execution Interval 10.000 Seconds

Table 1 Estimated Total Program Execution Time in msec 2673.6 w/Output 2758.1

Table 1 Estimated Total Final Storage Locations used per day 672

Estimated Total Final Storage Locations used per day 672

*Execution time is unknown.