What is it – What can it do
A software application for the low cost Smart 2-Circuit Relay Module. It was created to control lighting in homes, shop, offices etc. The relay module is mounted in a switchboard or electrical enclosure and controlled by safely isolated low voltage switches or other equipment. This allows low voltage switches and wiring to be installed from all control switch points or other equipment. This can reduce the amount of mains power wiring installed, allows greater control flexibility and configuration changes without re-wiring. For example – 2 or 3 way switching simply requires 2 or 3 low voltage switches wired to the one relay module.
- Manual lights : a push button turns a light circuit on or off; press on, press off
- Auto-lights : a trigger input from a movement detector (PIR), vehicle detector, door switch
- Night-lights : the light sensor turns lights on at dusk and off at dawn
- Lighting for safety, security, convenience and power saving
Features:
- 2 lighting circuits = 2 functions per module
- Low voltage switch wiring (reduced cable requirements)
- Auto lighting with timeout (using PIR movement sensor)
- timeout adjustable in 5 minute increment up to 250 minutes
- Daylight switching – Night lights (using the light sensor)
- Programmable delays and light level
- Reconfigurable without re-wiring
- Multiple 2-circuit relay modules can be combined for more circuits
Operation
The lighting controller is intended to be simple, so it’s set up as needed and then left to get on with it. There are no keyboards, remote controls or LCD displays. Set up of the basic function is decided during installation; simple manual control, movement detection with timeout or light sensor controlled circuits. This is partly achieved by the input wiring and partly by programmable setup.
There are seven low voltage inputs that can be connected to manual light switches, movement sensors, door switches, vehicle detectors etc. One is an analog input that can connect to a small light sensor. Input functions are:
- toggle = pulse on, pulse off (used for manual push button control)
- set with timeout = pulse on and it will timeout automatically (used with PIR movement sensors etc.)
- reset = 2 inputs, each turn off both circuits
- light sensor = analog input for 10K CDS sensor
Note: The control inputs operate on release : momentarily pulsed high to +12V.
The two reset inputs are common (they do the same thing) but are electrically separate. This allows two reset sources without affecting each other. One reset could be local ie. a room, corridor or stairwell, and the other reset building wide, all off. One reset source can connect to a number of relay modules.
The toggle inputs is typically connected to the normal room light switch for manual control. Push-button low-voltage light switches can be used. A reset button on the light switch can turn off both circuits. The set inputs provide auto-lights when connected to PIR movement sensors. The timeout period can be set in steps of 5 minutes, up to 250 minutes. The movement sensor triggered auto-lights can be qualified by the light sensor so that they only operate after dusk. The light level trigger point can be set (recorded). Relay Circuit-A can also be set for simple light sensor control; on at dusk, off at dawn (a daylight switch).
The one low voltage output is typically used to drive an indicator or light-switch back-lighting. This also acts as an indicator when in programming mode.
The 2 relays are designated A and B. Each has it’s own 2 inputs (toggle and set). Only relay A has the light-level daylight switching function. Time delays and daylight light-level are saved in EEPROM, so not lost when power is off.
- To enter programming mode, activate inputs 3,4,5 and apply power. Release the inputs and you’re into programming mode.
- The backlight output flashes when in programming mode
- Input-1 = long press to exit or quit programming mode and return to normal operation
- Input-1 = press to reset function selection and counts to zero
- Input-3 = long press to save the change
- Input-3 = function sequence. Cycle through the functions 1,2,3,4,1,2,3,4… etc.
- Input-5 = count (value). each press is one count. ie. +5 minutes on the timeout
- Functions are : 1 = relay A timeout, 2 = relay B timeout, 3 = light-level, 4 = auto-light enable
- Relay timeouts are in 5 minute increments to 255 minutes, which is 51 counts (presses)
- Light level is saved from the current sensor reading.
Relay timeout : Select programming function 1 or 2 using input-3. Pulse input-5 for the count (15 minutes = 3 pulses (x5 mins)). Long press input-3 to save the change
Light level : Select programming function 3 using input-3 and save it using input-3. If a count entry is made using input-5, the light level is reset to FF which disables the function.
The program code
The program is “RLE_1A_LIGHTS-1”. This was created using Microchip MPLAB-X, written in assembly code for the PIC16F676 chip and consists of 2 files; the “pic16f676.inc” definition and “rle_1a_lights_1.asm” main program. The main program file contains everything, interrupt routines and the main loop.
At reset or power-on the PIC16F676 initializes, retrieves the configuration variables from EEPROM then enters the main loop. If the 3 inputs (3,4,5) are active it enters programming mode rather than the main loop. The main loop handles the basic control logic and cycles every 10mS triggered by the conclusion of the timer interrupt. The 10mS timer interrupt handles the real-time delays and repetitive routines including the ADC and input detection for debounce, short-press and long-press detection.
There is a diagnostic serial output function that copies bytes to a pin that can be monitored with an oscilloscope. The serial data is very fast and repeats every 10mS.
text