8. Program examples
8.1
CRBasic
examples
The
three
program
examples
discussed
in
this
section
are
downloadable
at
/downloads/sdm-cd16ac-example-programs
.
The
programs
demonstrate
controlling
two
SDM-CD16ACAs,
controlling
temperature
and
fans
in
greenhouses,
and
using
an
integer
instead
of
an
array
to
set
the
SDM-CD16ACA
control
outputs.
While
the
programs
are
written
for
the
CR1000X,
they
will
work
with
other
Campbell
Scientific
data
loggers
with
little
or
no
modification.
8.1.1
Controlling
two
SDM-CD16ACAs
The
program,
SDM-CD16AC-two-sdms.dld,
demonstrates
using
two
SDM-CD16ACA
modules
to
control
pumps
and
heaters
based
on
water
level
and
temperature
thresholds.
8.1.2
Control
temperature
and
fans
In
program
SDM-CD16AC_greenhouse-control.dld,
the
SDM-CD16ACA
is
used
to
control
the
temperature
between
23
and
28 °C
in
each
of
five
greenhouses.
In
each
greenhouse,
the
SDM-CD16ACA
controls
a
heating
unit,
a
refrigerating
unit,
and
an
air-mixing
fan
according
to
the
following
conditions.
Heating
unit:
Activate
when
temperature
<
23.5
°C.
Deactivate
when
temperature
>
25.5
°C
Cooling
unit:
Activate
when
temperature
>
27.5
°C.
Deactivate
when
temperature
<
24.5
°C
Mixing
fan:
Activate
whenever
the
heating
or
cooling
units
are
activated.
Activate
for
5
minutes
out
of
every
15
minutes.
The
program
assumes
the
temperature
measurements
have
been
made,
and
the
average
temperature
for
each
greenhouse
is
computed
and
residing
in
the
appropriate
variable.
Input
Location
assignments
are
as
follows:
Variable array
Description
Temp(5)
Avg temp, greenhouse 1..5
Heat(5)
Heater control, greenhouse 1..5 SDM-CD16ACA
Port 1..5
Cool(5)
Cooler control, greenhouse 1..5 SDM-CD16ACA
Port 6..10
SDM-CD16ACA 16 Channel AC/DC Controller
11