Dataq DI-159 User Manual page 38

Table of Contents

Advertisement

DI-159 PLC Hardware Manual
DI-159 PLC register variables
Variables can also be dimensioned as DI-159 PLC register variables at absolute addresses with
the following statements:
dim varabs at address addr
dim varabs as (short|byte) at address addr
dim varabs[n] at address addr
dim varabs[n] as (short|byte) at address addr
Note that you can trivially crash your DI-159 PLC by accessing registers incorrectly.
Persistent integer (32 bits) flash variables
Variables can also be dimensioned as persistent integer (32 bits) flash variables with the fol-
lowing statements:
dim varflash as flash
dim varflash[n] as flash
Persistent flash variables retain their values from one run of a program to another (even if
power is lost between runs), unlike RAM variables which are cleared to 0 at the start of every
run.
Note that since flash memory has a finite life (100,000 writes, typically), rewriting a flash var-
iable should be a rare operation reserved for program configuration changes, etc. To attempt to
enforce this, StickOS delays all flash variable modifications by 0.5 seconds (the same as all
other flash memory updates).
Pin variables
Finally, variables can be dimensioned as pin variables, used to manipulate or examine the state
of DI-159 PLC I/O pins with the following statements:
dim varpin as pin pinname for (digital|analog|frequency)
(input|output)
dim varpin[n] as pin pinname for (digital|analog|frequency)
(input|output)]
These are discussed in detail below, in the sections on
Frequency
Output.
Examples
> new
Digital
I/O,
Analog
38
StickOS
Input, and

Advertisement

Table of Contents
loading

Table of Contents