MIAC low voltage LED lighting

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

MIAC low voltage LED lighting

Post by Sean »

Introduction
This article demonstrates the use of a MIAC (Matrix Industrial Automotive Controller), programmed using Flowcode, to control a multi-channel, low voltage, dimmable, LED lighting system.
Lighting System 2.jpg
Lighting System 2.jpg (59.01 KiB) Viewed 5955 times
These notes detail the development of a multi-channel MIAC lighting control system.

The example program accompanying these notes is written and illustrated using Flowcode. The program includes a software controlled PWM signal generator for efficient multi-channel brightness control and LED brightness characteristic correction.

Technology
Recent developments in technology have allowed LEDs to become a realistic alternative to incandescent bulbs in many lighting applications. The high efficiency and long operating life of LEDs have important environmental implications.

The efficiency of LED bulbs makes them suitable as direct replacements for incandescent bulbs in low voltage lighting systems. Many are commercially available in packages that are compatible with standard light fittings. The bulbs are relatively easy to control and can be built into flexible lighting systems using safe, low voltage, electronic circuits.

A MIAC can provide fully programmable control of up to 8 lighting circuits. Four controlled by transistor outputs (all with PWM control), and four controlled by relays. In addition, there are eight inputs that can be used to read switches, potentiometers, and a variety of sensors.

Each MIAC transistor output is capable of supplying approximately 6Watts at 12V. This means that each channel can control a single bright-white 4W bulb, or several 1W coloured bulbs.

The Relay outputs are not suitable for PWM control, but are capable of supplying 96Watts each at 12V and can be used for low frequency switching of large banks of lamps.

Example program
The example program is a four channel analog to PWM light controller. Each channel (A, B, C, D) can be independently controlled by connecting a suitable analog signal source to the corresponding input (I1 = A, I2 = B, I3 = C, I4 = D)
MIAC_LV_Lighting_Article.fcf
(14.5 KiB) Downloaded 670 times
Main program loop

The main program:
• Initialises all the variables
• Configures and enables the TMR0 interrupt
• Executes a continuous loop

In each cycle of the main loop, the program:
• Samples the voltages present on 4 independent inputs.
• Calculates the required output value for each channel and updates the control variables
• Waits for 50ms

The calculated brightness value for each channel is stored in an array variable, PWM_DUTY[]. The array is read automatically each time the TMR0 interrupt occurs, and the stored values are used to control the signal at each output terminal.

PWM
PWM (Pulse Width Modulation) is an efficient method for simulating analogue levels by rapidly switching a signal on and off at specific time intervals.
The PWM signals used to control the brightness of the lamps in this example are generated in software and controlled by a timer interrupt. This allows PWM control to be available on all four transistor outputs. The resolution of the PWM has been set to 6 bits, which is adequate for this application, and results in a good trade-off between interrupt frequency and PWM cycle period.

The timer interrupt occurs every 85.3μs and increments a byte variable, PWM_COUNTER, by 4, causing a cycle repeat every 64 interrupts (5.46ms - 183Hz).

The duty cycle (brightness) value of each channel is calculated in the main program loop and stored in a four byte array, PWM_DUTY[].
Each time the timer interrupt occurs, the handler macro reads the channel values fro the array and performs the following operations:

IF PWM_COUNTER = 0 (start of a PWM cycle)
Turn ON the output of any channel with a non-zero duty value.
ELSE
Turn OFF the output of any channel with a duty value that matches the current value of PWM_COUNTER.
ENDIF
Increment PWM_COUNTER
MIAC_PWM_LV_Lighting.fcf Macro - Tick 2.JPG
MIAC_PWM_LV_Lighting.fcf Macro - Tick 2.JPG (24.26 KiB) Viewed 5955 times
Example of an interrupt handler for software PWM

Profiling
The lamps used to develop this application are listed as being 'not dimmable'. It would appear that they are dimmable, but the variation in brightness is not linear. The programmability of the MIAC allows a profile to be created that improves the linearity of the brightness control. The example uses an array to convert eight brightness levels (including OFF) to the appropriate PWM duty cycle values.


Suggestions for further development
The example program is a basic introduction to the MIAC capabilities. The program can be modified or expanded to include some of these suggested features:

Sound activation
Light sequencing can be controlled by audio signals (amplified microphone, audio equipment, etc.) applied to the input terminals.

Remote control
By combining this application with the MIAC RC-5 application, lighting levels, colours, and sequences, can be controlled with a domestic, infra-red, remote handset.
Note: Both of these applications use TMR0. Therefore one will need to be modified to work with an alternative timer peripheral.

Automatic brightness adjustment
Channel brightness can be controlled by light sensors (LDRs, Photodiodes, etc.) connected to the input terminals.

Night light
A light sensor can be used as a twilight switch, automatically activating the system at dusk. Individual channels, allocated to separate rooms, can then be switched independently under timer control to give the impression that a building is occupied.
Note: The relay outputs would be suitable for this application, and could control several bulbs on each channel.

Networking
The CAN bus can be used to connect multiple MIACs in a network, increasing the number of channels and potential combinations.
Schematic.JPG
(47.7 KiB) Downloaded 3277 times

Morkel
Posts: 1
Joined: Fri Jul 19, 2013 5:57 pm
Contact:

Re: MIAC low voltage LED lighting

Post by Morkel »

Nice Post.Thanks for sharing it..................:):)

Removed Advertising links .. Martin

Post Reply