1 program structure, Program structure -54 – Campbell Scientific LoggerNet Datalogger Support Software User Manual

Page 272

Advertising
background image

Section 7. Creating and Editing Datalogger Programs

The first line of text identifies the type of datalogger program to be written.

This is followed by a comment line and the Program Table Headers and

Execution Interval fields. The Program Table Headers and Execution Interval

fields are protected text that cannot be deleted or commented out. (The asterisk

is used to identify the beginning of a program table in the datalogger.) When

the cursor is moved to the Execution Interval line, the field for the execution

interval is highlighted. A numeric value must be entered or the instructions in

the table will never be executed.

Instructions inserted under the Program Table 1 header will be run based on the

execution interval for that table. Likewise, instructions inserted under the

Program Table 2 header will be run based on the execution interval for Program

Table 2. Program Table 3 is reserved for subroutines that are called by either of

the other tables. Most users find they can write the entire program in Program

Table 1, avoiding complications associated with synchronizing two tables.

Program Table 2 is normally used only when portions of the program require a

different execution interval (placed in Program Table 2).

Program tables in this section refer strictly to sections of the

datalogger program. Do not confuse these program sections with

the data tables created in table-based dataloggers using P84 to

store output data.

When the program is complete, select File | Save from the Edlog menu. A

standard file dialog box will appear in which to type a file name. Edlog

supports long file names for the datalogger programs. Use descriptive names

to help document the program’s function. After saving the file, you will be

prompted to compile the program. When a program is compiled the code will

be checked for errors. After compiling, the datalogger program can be sent to

the datalogger using the Connect Screen.

7.4.2.1 Program Structure

While Edlog is not a structured programming language there are some standard

programming practices that will help you and others understand what the

datalogger program is intended to do.

Comments – Edlog provides the ability to add comments on any blank line

and to the right of all instructions. Liberal use of descriptive comments makes

the program clearer and will help you remember what you were doing when

you come back to it a year or two later. Especially useful are descriptions of

what sensors are connected and how they are wired to the datalogger.

Program Flow – It is easier to follow a program that is written in distinct

sections, each of which handles a specific type of instruction. The

recommended sequence is:

Measure Sensors – In this first section put all the instructions that get data

from the sensors attached to the datalogger. The sensor readings are stored

in input locations, ready for the next section.

Process Measurements – In this section do all the calculations and data

processing to prepare the data for output.

NOTE

7-54

Advertising