Preserving Variables Through User Settings; Data Tables; B-5. Using Setsettings To Preserve Variables - Campbell CR300 Series Operator's Manual

Hide thumbs Also See for CR300 Series:
Table of Contents

Advertisement

B.4 Preserving Variables through User Settings
NOTE
CRBasic Example B-5. Using SetSettings to Preserve Variables
'This program example increments a counter every second.
'If for any reason the counter is reinitialized to 0,
'it is set to the value stored in the UserVal() array in User Settings.
Public
counter
BeginProg
If
counter = 0
Then
Scan
(1,Sec,0,0)
counter = counter +1
SetSetting
("UserVal(1)",counter)
NextScan
EndProg
B.5 Data Tables
Appendix B. Introduction to CRBasic Programming
When a program compiles, all variables are initialized. A program is
recompiled after a power failure or a manual stop. For instances that require
variables to be preserved through a program recompile, the CR300 has User
Settings. Entries in User Settings are not erased when a program is recompiled.
User Settings include two arrays: UserStr() and UserVal(). Each array has 12
fields. UserStr() holds only strings, and UserVal() holds only floating point
values. Each can be entered manually in Device Configuration Utility in the
Settings Editor | User Settings tab, or they can be written through a CRBasic
program using the SetSetting() instruction.
User settings are stored in flash memory. To avoid corrupting the
flash memory, edit these settings infrequently.
counter = Settings.UserVal(1)
Data are stored in tables as directed by the CRBasic program. A data table is
created by a series of CRBasic instructions entered after variable declarations
but before the BeginProg instruction. These instructions include:
DataTable()
'Output Trigger Condition(s)
'Output Processing Instructions
EndTable
A data table is essentially a file that resides in CR300 memory. The file is
written to each time data are directed to that file. The trigger that initiates data
storage is tripped either by the CR300 clock or by an event, such as a high
temperature. The number of data tables is limited to 20. Data tables may store
individual measurements, individual calculated values, or summary data such
as averages, maxima, or minima. See CRBasic Example B-6.
B-7

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr300-rf407Cr300-rf412Cr300-rf422

Table of Contents