Tutorial 7 — time control
Part 2 — Tutorials. Continues the project from Tutorial 6.
What you will build
Outside lights that switch on at dusk and off at dawn, all year, with no schedule to maintain
A garden watering system that runs on selected days
A holiday mode that runs between two dates
11.1 Programs are actors
Everything so far has been triggered by a person pressing something. A program is triggered by time — and once defined, it behaves exactly like any other actor. You drag a wire from it and give that wire an action and a function, just as you did with a button.
Programs have two actions:
Program value switch ON
the program becomes active
Program value switch OFF
it becomes inactive
That is the whole idea. A program turns "it is 07:00 on a Tuesday" into something you can wire.
The three kinds
Periodical
a moment, repeating
watering at 06:00 on Mondays and Thursdays
Two-state
on/off stretches across a week
night-time setback, weekday-only equipment
Continuous
one stretch between two dates
holiday mode, seasonal switching
Heating uses two more — Heating/Cooling - week and Heating/Cooling day — which you already met in Tutorial 6.
All of them live in Managers → System manager → System programs.
11.2 Dusk to dawn, without a schedule
The best schedule for outside lights is no schedule. Sunset moves by three hours across the year; any fixed time you pick will be wrong for ten months.
The Astronomical-Module calculates sunrise and sunset from the date and your location, and presents them as ordinary digital inputs you can wire.
Add the module
Project → Device manager.
Select the central unit, then click New slave.
Choose Astronomical-Module → OK.
Only one astronomical module is allowed per project, and its address is fixed.
Tell it where the building is
Select the module and open Parameters:
Description
Sun and moon
Use city
tick it, then pick the nearest of 50 predefined cities from City
Longitude / Latitude
or untick Use city and type the coordinates to two decimals
Coordinates are more accurate; a city is faster and close enough for lighting.
What it gives you
Sunshine-DIN1 … Sunshine-DIN4
daylight — ON from sunrise, OFF from sunset
New-Moon-DIN
ON when less than 25 % of the moon is lit
Moon-First-Quarter-DIN
ON between 25 % and 75 %
Full-Moon-DIN
ON at 75 % or more
Moon-Third-Quarter-DIN
ON between 25 % and 75 %
There are four sunshine inputs because each can carry its own offset. That is the useful part:
Sunrise Offset
−82801 … +82801 seconds
negative = before the calculated sunrise, positive = after
Sunset Offset
−82801 … +82801 seconds
the same, for sunset
So Sunshine-DIN1 can be true daylight, Sunshine-DIN2 can switch 30 minutes before sunset (Sunset Offset = -1800) for the drive lights, and Sunshine-DIN3 can switch an hour after sunrise for something else.
Wire the outside light
Device manager → expand the astronomical module and give
Sunshine-DIN2a Sunset Offset of-1800and a Sunrise Offset of0.Design workspace tab → drag an input icon onto the plan → Connect it to
Sunshine-DIN2→ name itDaylight.Function workspace tab → Add connection → drag
Daylight→ your outside light (reuseStair lightif you have no outdoor circuit).Wire manager → name it
Outside light — dusk to dawn→ add two functions:Action:
Digital IN switch OFF→ User function:DIGITAL_ONAction:
Digital IN switch ON→ User function:DIGITAL_OFF
Close, save, upload.
Read it carefully — the logic is inverted on purpose. The input is daylight, so: daylight ends → light on, daylight begins → light off.
Sunrise, sunset and moon phase are calculated when the project is saved to the central unit. They are not recalculated live from an internet source, so the CU's clock and time zone must be right. Check them in CU configuration (Chapter 22).
11.3 A periodical program — watering
A periodical program fires at a moment, repeatedly.
Managers → System manager → System programs → +.
Choose Periodical → OK.
Fill in:
Program name:
WATERING_MORNINGActivation time/dispersion:
06:00
Choose one of three repeat modes:
Every week
weekly
which days of the week
Every month
monthly
which days of the month
Selected months
daily
which months of the year
Pick Every week and tick Monday and Thursday.
Click ✓.
You must tick at least one day or month. With none selected, the confirm button stays unavailable. It is easy to miss and looks like the dialog is broken.
Now wire it:
Design tab → drag a program icon onto the plan and assign it
WATERING_MORNING.Function tab → Add connection → drag the program → your watering valve output.
Wire manager → name it
Watering→ +:Action:
Program value switch ONUser function: a
Digital_Impulse_ONof your chosen duration — say a 20-minuteDIGITAL_IMPULSE_20MINyou define in Function manager
Save, upload.
The impulse does the timing, so you need no "off" program at all.
Connecting programs, timers and counters. These live inside the central unit rather than on a bus, so you may find yourself dragging a wire from the central unit icon. When you do, a Select devices to create wires dialog opens and you choose which timer, counter or program you meant.
11.4 A two-state program — night setback
A two-state program is on for some stretches of the week and off for others — the same style of weekly graph you drew for heating.
System programs → + → Two-state → OK.
Program name:
NIGHTSelect a day and place time stamps, up to 16 per day:
Mark adds a single time stamp
Mark then Window adds a pair — use this for a "from 22:00 to 06:00" block
Set each stretch on or off by clicking below the stamps. Green is ON, red is OFF.
Right-click the day label → tick target days or use Working days / Weekend / All week → Copy actual program.
✓.
Wire Program value switch ON → dim the corridor lights to 10 %, and Program value switch OFF → back to normal. The building now has a night mode.
Two-state programs, like heating time plans, can be edited live after the first upload — change the graph and confirm with ✓.
11.5 A continuous program — holiday mode
A continuous program is a single stretch between two dates.
System programs → + → Continuous → OK.
Fill in Program name, Start date and Stop date.
✓.
It switches ON at 00:00:00 on the start date and OFF at 23:59:00 on the stop date.
Wire Program value switch ON → HEATING_COOLING_HOLIDAY_PLAN on your heating area, and Program value switch OFF → HEATING_COOLING_NORMAL_PLAN. Set the dates before the client leaves and the house looks after itself.
11.6 Choosing the right one
Something at a fixed clock time, on chosen days
Periodical
Something on for stretches of the week
Two-state
Something between two calendar dates
Continuous
Something that tracks the sun through the year
Astronomical module
Temperature by hour of the week
Heating/Cooling - week (Ch. 10)
A delay after an event
not a program — a timer (Ch. 12)
The last row matters. Programs answer "what time is it?". Timers answer "how long since something happened?". Reaching for a program when you needed a timer is a common wrong turn.
What you learned
A program is an actor, with
Program value switch ON/OFFas its actionsPeriodical = a repeating moment · Two-state = weekly on/off stretches · Continuous = between two dates
The astronomical module gives sunrise, sunset and moon phase as digital inputs
Four sunshine inputs, each with its own Sunrise/Sunset Offset in seconds
Sun times are calculated at upload, so the CU clock and time zone must be correct
Programs need at least one day or month ticked before they can be saved
Try this before moving on
Give
Sunshine-DIN3a Sunrise Offset of+3600and use it for something that should start an hour after dawn.Build a two-state program that only allows the doorbell to sound between 08:00 and 21:00 — you will use it as a condition in the next chapter.
Set up a continuous program for the summer and use it to disable your heating boost button.
Next: Chapter 12 — Tutorial 8: logic and conditions — timers, counters, system bits, and rules that fire only sometimes.