Skip to main content

Scheduler (Sunrise & Sunset)

Loading...

Here is a cool demonstration of the Scheduler's capabilities: This project takes advantage of the special Sunrise and Sunset features offered by the Scheduler."Sunrise" and "Sunset" refer to the "official" sunrise and sunset times for the specified geographical coordinates. Obviously, these times change throughout the year.

The project defines two schedules, one for sunrises, and one for sunsets. The corresponding On Scheduled Event blocks then turn a relay on or off. The relay is meant to control a street light.

For the application to work correctly for a given location, it must be preset with this location's coordinates. This is done through the Latitude and Longitude properties of the General page. The Time Zone must be set correctly as well. Linking these three properties to settings and exposing the settings through the web or LUIS interface will enable your users to deploy the devices anywhere in the world.

scheduler_sunrise_sunset

Controlling a Relay

This is the first project that touches on controlling IO lines. The application drives a relay; this is done through the light_on_when_low variable.

TPS relays are activated by bringing their control lines LOW, which is what the light_on_when_low variable name means.

IO lines are named on the Hardware tab: Click on Tibbit #03_1 to see the names of its control lines:

sunrise_1

As soon as a Tibbit like this one is added to the hardware configuration, several linked variables -- one for each IO line -- are created. You can see these "auto-generated variables" on the Variables page of the Features tab.

sunrise_2

This is similar to how you get auto-generated variables when you add a timer or a setting to your project.

Auto-generated variables linked to IO lines are of the boolean type. As we explained in Variables and Arithmetic, in addition to the four main variable types available to AppBlocks users, a few additional types are lurking in the system. These types often exist for interfacing AppBlocks with the outside world. The boolean type is one such case.

You probably know that IO lines of digital devices can be configured as inputs or outputs. Driving a relay requires an output. Just having Tibbit #03-1 in the hardware configuration already defines all related IO lines as outputs, and this is why you don't have to deal with line configuration for this Tibbit. Other Tibbits, for example, #04-1, which has optically isolated inputs, require their IO lines to be inputs, so this is configured automatically as soon as you "insert" them. There is also the third category of Tibbits with bidirectional IO lines. For such Tibbits, you must manually define the line direction for each IO line. One example of such Tibbits is #00-1 (four direct IO lines). You will meet this Tibbit in the Access Control 6: Real Inputs project.

Monitoring the Relay State

On the AppBlocks Demo Kit (ADK), the relay used in this project is connected to a green LED marked "RL1." The LED is on when the relay is on.