4 crbasic programming, 1 programming sequence – Campbell Scientific RTDAQ Software User Manual

Page 80

Advertising
background image

Section 5. Program Creation and Editing

5.1.4 CRBasic Programming

CRBasic is a programming language that has some similarities to a structured
BASIC. There are special instructions for making measurements and for
creating tables of output data. The results of all measurements are assigned
variables (given names). Mathematical operations are written out much as they
would be algebraically. This section provides a summary of a program, its
syntax, structure, and sequence. Refer to the datalogger users manual or the
on-line help for detailed information on program instructions.

5.1.4.1 Programming Sequence

The structure of a datalogger program requires that variables, data tables, and
subroutines be declared before they can be used. The best way to do this is to
put all the variable declarations and output table definitions at the beginning,
followed by the subroutines, and then the program. Below is the typical layout
of a program. Note that the online help has example code for each instruction
to demonstrate the use of the instruction in a program.

Declarations

Make a list of what to measure and calculate.

Declare constants

Within this list, include the fixed constants used,

Declare Public variables

Indicate the values that the user is able to view

while the program is running,

Dimension variables

the number of each measurement that will be

made,

Define Aliases

and specific names for any of the

measurements.

Define data tables

Describe, in detail, tables of data that will be

saved from the experiment.

Process/store trigger

Set when the data should be stored. Are they

stored when some condition is met? Are data
stored on a fixed interval? Are they stored on
a fixed interval only while some condition is
met?

Table size

Set the size of the table in RAM.

Other on-line storage

devices

Should the data also be sent to the external

storage?

Processing of Data

What data are to be output (current value,

average, maximum, minimum, etc.).

Define Subroutines

If there is a process or series of calculations

that needs to be repeated several times in the
program, it can be packaged in a subroutine
and called when needed rather than repeating
all the code each time.

5-20

Advertising