This is only a preview of the April 2002 issue of Silicon Chip. You can view 27 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Automatic Single-Channel Light Dimmer":
Items relevant to "Build A Water Level Indicator":
Items relevant to "Easy-To-Build Bench Power Supply":
Items relevant to "6-Channel IR Remote Volume Control, Pt.2":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
. . . dimming with the power of a PIC
Pt.1: By JOHN CLARKE
This single-channel fully automatic high-power light dimmer
has a host of control features because it is driven by a PIC
microcontroller. It will drive incandescent lamp loads up
to a total of 2400 watts.
26 Silicon Chip
www.siliconchip.com.au
T
HE SILICON CHIP Touch/Remote
Controlled Dimmer, described
in the January and February
2002 issues, was a low power device,
suitable for lamp loads up to 250W.
That’s OK for dimming the lights in
your lounge room or bedroom but
useless for dimming high power stage
lights or a bank of lights in a hall or
church.
For that purpose you need a high
power dimmer and that is the reason
for this completely new design. It is
specially designed to drive the high
power lamps used in stage lighting,
up to a total of 2400W. It has all sorts
of control features such as preset
brightness levels, dimming rates, flash
on and off buttons and so on.
Our last high power dimmer, featured in the August 1994 issue, was
a fairly basic design with just a slider
knob to control the brightness. This
new design has no slider knob but
can dim up or down manually or
automatically and has LED bargraphs
to indicate the brightness levels, dimming rates and more.
Features
The SILICON CHIP Automatic Light
Dimmer is housed in a rugged diecast
metal case measuring 170 x 120 x
55mm. We used a diecast metal box
for two reasons: first because stage
light dimmers often have a rugged
life and second, the case provides
heatsinking for the Triac which is the
power control device at the heart of
the circuit.
At one end of the case is the 240VAC
mains cord, a 3-pin mains socket for
the lamp, a power switch and a fuse
holder. On the front panel are two LED
bargraphs, a large LED brightness indicator and no less than eight switches
of various sorts.
Along the bottom edge of the control
are three rocker switches, two of which
are spring-loaded centre-off types.
Want to dim the lights up or down?
Use the DIM switch in the lefthand
corner. Push it up to go brighter; down
for dimmer.
Want to flash the lights to full
brilliance? Push the FLASH switch
on. Want to flash them off? Push the
FLASH switch off. This can be done at
any time, regardless of other settings
or modes.
Dimming can be manual or automatic, depending on the setting of the
Automatic/Manual Dimming switch
www.siliconchip.com.au
SPECIFICATIONS
Maximum lamp power ��������������������2400W
Minimum lamp power ���������������������60W (lower power lamps may flicker)
Phase angles ���������������������������������5.8° for maximum brightness and 174°
for minimum brightness
Auto Dimming rates ������������������������0, 0.5s, 1s, 1.5s, 2s, etc in 39 steps up
to 40s maximum
Dimming steps �������������������������������102 typical beyond initial preheat setting
up to full brightness
Dimming display �����������������������������39 levels
Triac gate drive period ��������������������80µs
in the right-hand corner. When dimming automatically, pushing the DIM
switch UP lets the lamp(s) brighten up
to the preset brilliance. Pushing the
DIM button DOWN, dims the lamp(s)
back down to zero.
Brightness can be preset to one of
39 brightness levels with the LEVEL
UP/DOWN rocker switch. Brightness
levels are indicated on a 20-LED bargraph. Yes, we know we said there
are 39 brightness levels? So how do
you indicate 39 levels with 20 LEDs?
The trick is that we use 20 LEDs to
indicate 20 levels from maximum
to minimum but the intermediate
brightness levels are indicated with
two adjacent LEDs – its harder to
describe than to use.
So as the level is increased, we get
one LED, then two adjacent LEDs, then
the top one of that adjacent pair, then
the next adjacent pair and so on. This
one-two-one LED sequence indicates
39 levels.
The same 20-LED bargraph can
also show the Flash brightness setting
which is preset using the DIM/FLASH
switch, in conjunction with the up/
down rocker switch to the left of the
bargraph.
Filament preheat
When high power lamps are initially switched on, their cold filaments
have a very low resistance and so they
have very high surge currents. This
is bad enough at switch-on but if a
lamp is to be repeatedly flashed on,
as it can be with this dimmer, then the
repetitive surge currents can destroy
the Triac and also blow out the filament of the lamp itself. To reduce this
problem, the lamp filament is always
run with a low value of “preheat”
current, typically with the filament
glowing a dim red.
Preheat setting is done by pressing
the DIM UP, LEVEL UP and Store
Settings switches all together. We will
discuss this later in this article.
The actual lamp brightness is indicated in two ways on the display.
Firstly, there is a large 10mm LED
which glows according to the lamp
brightness. Second, the 20-LED bar-
MAIN FEATURES
•
•
•
•
•
•
•
•
•
•
High power lamp control
Maximum lamp brightness preset
Minimum lamp brightness preset for filament preheating
Automatic or manual dimming between brightness presets
Separate flash on and flash off
Flash brightness preset
Dimming rate programmable from instant through to 40 seconds
A and B dimming rate selection
Lamp brightness indication
Automatic dim up and dim down indication
April 2002 27
in the two bargraphs are in “dot” mode
– ie, single LEDs glowing – rather than
“bar” mode.
When dimming automatically,
dimming can be stopped at any time
by momentarily pressing the DIM UP/
DOWN switch in the opposite direction to the dimming. So if the lamp is
in the process of dimming up, dimming can be stopped by momentarily
pressing the DIM DOWN switch. If this
switch is held down or pressed again,
then the dimmer will begin dimming
down. Similarly, if dimming down in
auto mode, dimming can be stopped
by momentarily pressing the DIM UP
switch.
Dimming rate
Scope 1: this somewhat distorted mains sinewave is straight out of a power
point. While nominally 240V AC, 50Hz, in this case it’s actually 250V AC and
the frequency is just a tad low (neither of which is unusual).
Scope 2: this scope shot shows the power being made available to the load very
late in the half cycle so that it effectively receives just under 40V. In this case,
the lamp would be barely glowing.
graph indicates actual brightness and
preset brightness levels. Actual lamp
brightness is shown with a flashing
LED in the bargraph, while the DIM or
FLASH preset levels are shown by a
constant LED. If the two levels are the
same, the indicating LED will shimmer
rather than glow constantly.
By the way, all the LED indications
28 Silicon Chip
PLEASE NOTE!
The scope waveforms in this article
are shown to explain the operation of
the circuit. DO NOT try to reproduce
these waveforms yourself – it is
much too dangerous.
Automatic and manual dimming
occurs at a preset RATE. You can set
two dimming rates (A and B) with
each one ranging from instantaneous
to 40 seconds, in 0.5s increments, as
displayed on the right-hand bargraph.
The topmost LED indicates the longest dimming time and therefore the
slowest rate.
When automatic dimming is in
progress, the topmost LED in the Rate
20-LED bargraph display flashes for
dimming up while the lowest LED
flashes when dimming down.
Some controls cannot be used when
dimming is in process. These are the
Level Up/Down, Rate Up/Down and
Store Settings switches. These switch
es are locked out of service during
dimming to prevent any possible
lamp flickering which may happen if
there is any attempt to operate several
functions at the one time.
The A and B dimming rate settings,
the Dim and Flash pre
sets and the
minimum level preheat setting can
be stored so that these settings will
be remembered when the dimmer is
used next time, after being switched
off. This is done by pressing the “Store
Settings” switch.
In fact, it is important to press this
switch after the minimum level filament preheat has been set so that this
will always be set correctly.During
this time, the LED bargraph display
momentarily goes off as an acknowledgement that storage has taken place.
When ever the dimmer is first
switched on, the lamp brightness is set
to fully off and no filament preheating
is applied. This means that no power is
supplied to the lamp. The dimmer will
begin to provide power to the lamp
www.siliconchip.com.au
Fig.1 the block diagram of the Auto Dimmer circuit. The key device is the
PIC16F84A-20/P microcontroller. It accepts inputs from the transformer and
switches and provides outputs to switch a Triac and drive the LED displays.
as soon as the Flash or Dim switches
are pressed.
Phase-controlled Triac
As with any light dimmer, the circuit uses a phase-controlled Triac to
set the lamp brightness. The principle
is virtually the same as outlined in the
January 2002 article on the Touch-controlled Dimmer. For those readers who
did not see that article, we will go
through the details again.
Our mains electricity supply is a
240VAC 50Hz sinewave which goes
positive for 10ms, back through zero
and then negative for 10ms. This returns to zero and again goes positive.
Normally a lamp is connected across
this supply whenever it is switched
on.
In a dimmer circuit, we delay apwww.siliconchip.com.au
plying power to the lamp during each
half-cycle of the mains waveform and
switch it off each time the voltage goes
through zero to effectively provide less
power and so dim the lamp.
This timed switching of the power
is performed by a Triac which can be
triggered on by a short pulse at its gate.
The Triac will then only turn off when
the current through it drops below a
certain threshold value. In practice,
when driving a resistive load this
means that the Triac switches off when
the mains voltage is near 0V. The accompanying oscilloscope waveforms,
repeated from the January 2002 issue,
show how it works.
The first oscilloscope waveform
(Scope 1) is the mains sinusoidal
voltage measured on the Active output of a power point. Note that the
mains voltage shown here is closer to
250VAC and it is by no means unusual
to have such a high voltage.
The second oscilloscope waveform
(Scope 2) shows the waveform applied
to the lamp when it is dimmed to a
low brightness. In this case, the lamp
is powered about 150° from the start of
each mains half-cycle and is switched
off at 0V.
Note that the lamp voltage is applied
for both positive and negative excursions of the mains active and the RMS
voltage is around 39V.
The third oscilloscope waveform
(Scope 3) shows the lamp voltage
when the dimmer is set for close to
maximum brightness. Now the voltage
is switched on early in each mains
half-cycle so that almost the full mains
waveform is applied. Again the lamp
is switched off at 0V. The RMS voltage
is now a lot higher, at 242V.
The circuit for the lamp dimmer
obtains this phase control by dividing
April 2002 29
Scope 3: this waveform shows triggering very much earlier in the cycle, so that
the lamp receives almost all the available power. In this case, the lamp would
be at virtually full brilliance.
up each half cycle (180°) of the mains
waveform into 250 discrete sections.
Thus, each discrete section is equiv
alent to 0.72° (180/250).
The overall range of phase control
in the dimmer circuit is restricted to
a minimum count of 8 (5.8°) and a
maximum count of 241 (174°).
Block diagram
Fig.1 shows the general arrangement of the dimmer circuit. The key
device is the PIC16F84A-20/P microcontroller. It accepts inputs from the
transformer and switches and provides
an output to switch the Triac. Its other
outputs drive the LED displays.
IC1 operates from a 20MHz timebase
and this clocks a timer which counts
up until it reaches 40µs. The output
then clocks the brightness counter
which counts from 0 through to 250
for each 10ms half-cycle of the mains
voltage. This is locked to the mains
waveform via the zero voltage negative edge detector which resets the
brightness counter to zero each time
the mains voltage drops to zero.
An important part of this circuit is
the feedback from the brightness counter back to the internal timer. This is
required to lock the internal timer rate
to the brightness counter and adjusts
so that the counter is just on the verge
of counting to 250 at the occurrence
of the zero voltage signal from the
30 Silicon Chip
mains. Any deviation from this locked
arrangement will produce flickering in
the phase controlled lamp.
The current required lamp brightness is stored in the brightness level
register and this value is compared
with the brightness counter value
using an exclusive comparator. The
exclusive comparator output drives
the optocoupled Triac driver (IC4)
when both the brightness counter and
the brightness level register are the
same value.
Input signals from switches S1-S8
provide the controls to set the dimming brightness, flash brightness,
dimming rate and so on, as described
above. Input response logic decides
what action to take when one of these
switches are pressed.
Circuit diagram
The circuit for the Automatic Dimmer is shown in Fig.2. As already
noted, IC1, the PIC16F84A-20/P microcontroller, is the heart of the circuit.
This IC runs at 20MHz, by virtue of the
20MHz crystal (X1) connected to pins
15 & 16. It needs to run at this speed
in order to perform all the necessary
functions of driving the LED displays
and monitoring the switches without
this interfering with providing the
trigger pulses to the Triac.
The two bargraphs, comprising
LEDs 1 to 40, are driven via IC2, IC3
and transistors Q1-Q5. However, while
the LEDs are physically arranged as
two 20-LED bargraphs, they are connected in a matrix of five rows and
eight columns. They are driven in
multiplex fashion, under the control
of IC1, IC2 and IC3.
Each of the five transistors drives
the commoned anodes of its row of
LEDs via a 47Ω resistor. The eight columns are each driven via a Darlington
transistor in the cathode driver (IC3).
Each of the eight base inputs in IC3 is
driven by 4017 counter IC2 which is
clocked by IC1. Only one column is
driven at a time and the required LEDs
in that column are driven by the row
drivers, Q1-Q5.
Each time IC2 is clocked by IC1, one
of its eight outputs goes high to drive
IC3 to display the next column.
After the last column is lit, IC2 is
clocked again so that the “8” output
goes high. This output is not connected
to the circuit and so all the columns
(and all LEDs) are off.
Next, IC1 checks switches S1-S4
to see if they have been operated. It
does this by pulling the RB3-RB7 lines
(pins 9-13) low in turn, to check if its
pin 18 is pulled low via a switch and
diodes D1-D5.
So for example, if RB7 is brought
low and S1 is open, pin 18 of IC1 will
remain high via the 10kΩ pullup resistor. If the switch is closed, the low RB7
output will pull pin 18 low via diode
D1. The diodes ensure that the RB7RB3 outputs are not shorted together if
more than one switch is closed. Note
that bringing the RB7-RB3 lines low
will also drive transistors Q1-Q5, so
it is important that the columns are
off. This is why IC1 can only check
these switches when the (unused) “8”
output of IC2 is high.
After this switch test, IC2 is reset via
a high RB1 signal from IC1. Now the
“0” output is high to drive column 1
again. Switches S5 to S8 are tested for
closure using the high outputs from
IC2 and the RA0 input, pin 17, of IC1.
Normally pin 17 is held low via a
10kΩ resistor. If the “0” output (pin
Fig.2 (right): the full circuit details
of the Auto Dimmer. Microcontroller
IC1 controls optoisolator IC4 which in
turn controls Triac1 to vary the lamp
brightness. It also drives transistors
Q1-Q5 and IC2 to switch the LED
displays.
www.siliconchip.com.au
www.siliconchip.com.au
April 2002 31
This is the view inside the prototype with the wiring almost completed. The full
assembly details will be published in Pt.2 next month.
3) of IC2 is high and switch S5 is
closed, then RA0 will be pulled high
via diode D6. If the switch is open
then RA0 will remain low. Diodes
D6-D12 ensure that IC2’s outputs are
not shorted together if more than one
switch is closed.
Triac drive
The RA3 and RA4 outputs of IC1
drive IC4, the MOC3021 optocoupled
Triac driver, via a 220Ω resistor. When
these outputs are high, the LED inside
IC4 is off. When these pins go low, the
LED is driven and this activates the
internal Triac between pins 4 and 6
to drive the gate of Triac1, a BTA41600B. The gate drive current comes
via 360Ω and 470Ω resistors from the
240VAC mains Active line The .047µF
capacitor is included as a “snubber” to
prevent false switching of the Triac by
transients on the mains Active.
The gate drive pulse to Triac1 is set
at 80µs which is sufficient time to ensure that it latches on for the duration
of the mains half cycle.
32 Silicon Chip
Triac1 is a BTA41-600B, a 600V 40A
device which has been specified to
cope with the very high surge currents
which occur when switching a 2400W
incandescent lamp load. Typically,
the surge current at switch-on can be
10-15 times the normal load current;
ie, the surge current could be 100150 amps and could last for several
milliseconds.
WARNING!
Part of the circuitry used in this
Automatic Light Dimmer operates at
240VAC (see Fig.2) and is potentially
lethal. Do not touch any part of this
circuit while the unit is plugged into
the mains and do not operate the
circuit outside its earthed metal case.
This project is for experienced constructors only. Do not build it unless
you are entirely familiar with mains
wiring practices and construction
techniques.
The Triac must also be able to cope
with the very high fault currents that
occur when high power lamps blow
their filaments. When this happens,
the broken sections of the filament
can establish an arc between the
stem supports and this arc current
continues until the stem fuse blows.
Considering that this arc current can
be many hundreds of amps, the Triac
has to be very rugged.
EMC filtering
The rapid switching of the Triac,
combined with high currents, means
that this circuit can generate a lot of
interference. So we have included a
two-stage filter network comprising L1
& C1 and L2 & C2. The 4.7MΩ resistor
across the Active and Neutral output
discharges the capacitors when power
is off to prevent these from being left
charged.
The first stage in the filtering uses
an powdered iron toroid for the 40µH
inductor L1. This type of inductor is
quite lossy for frequencies above about
1MHz and so in conjunction with the
0.1µF capacitor, it attenuates much
of the electromagnetic interference
www.siliconchip.com.au
Fig.3: this simple circuit is used to derive the low-voltage AC and DC supply rails for the dimmer.
(EMI) caused by the rapid switching
of the Triac. However, it is not a good
filter below 1MHz, particularly for frequencies between 10kHz and 100kHz
which must also be attenuated to prevent EMI above the allowable limits.
This is where the second filter
comes into play. It comprises a toroidal
core with two windings. The core has
a high permeability ferrite material so
that we can obtain a much higher value
of inductance without an excessive
number of turns on the toroid. However, the combination of high inductance
and high load current means that the
core is easily saturated by the magnetic
flux generated when current flows
through the windings.
This is why we have two windings
on the core; so that any flux generated by one winding is opposed by the
second winding. This means the net
magnetic flux in the core adds up to
zero and so saturation does not occur.
However, if we say that the flux generated by one winding is cancelled by
the flux in the second, then how does
the filter work?
Clearly, flux cancellation does occur
for the low frequency part of the load
current but for the high frequencies,
which are bypassed by C2, flux cancellation does not take place and so
the twin windings give a high effective inductance for the interference
frequencies we are trying to get rid of.
LED brightness indication
As mentioned previously, we use a
large LED on the front panel to mimic
the lamp brightness. This is driven
by the RA2 output of IC1 which goes
low when the Triac is driven to light
the LED via a 470Ω resistor. It is then
switched off at the end of each mains
half-cycle. Note that the drive to
LED41 does not occur for the filament
preheat period, where the lamps are
effectively off.
Low voltage power for the circuit
comes from transformer T1, as shown
on the circuit of Fig.3. Its centre-tapped
secondary feeds diodes D13 and D14
and the 470µF capacitor filters the DC
which is fed to the 7805 3-terminal
regulator, REG1. This provides the +5V
rail for the ICs and the LEDs.
Most of the circuitry is isolated
from the mains by transformer and the
optocoupler IC4. The portion of the
circuit in the top right-hand corner
of Fig.2 is at 240VAC mains and is
potentially lethal.
Zero crossing detection
Because IC1 must provide precisely
timed trigger pulses to the Triac, it
needs be synchronised to the 240VAC
mains waveform. To do this, IC1 monitors the 15VAC waveform from the
transformer at its RB0 input, pin 6.
This is used to detect the zero crossing
point of the mains voltage.
The 15VAC signal is filtered with a
two-stage RC filter comprising 220Ω &
2.2kΩ resistors and 1µF & 0.1µF capacitors. This rolls of frequencies above
about 700Hz to remove transients from
the mains. The 100kΩ resistor to the
RB0 input is included because there
is a diode within IC1 which clamps
the voltage when it goes 0.7V below
ground. The resistor limits current in
the clamping diode.
That’s all for this month. Next month
we will conclude with all the construction and setting up details.
SC
UM66 SERIES TO-92
SOUND GENERATOR.
THESE LOW COST IC’S
ARE USED IN MANY TOYS,
DOORBELLS AND NOVELTY
APPLICATIONS
1-9
$1.10
10-24 $0.99
25+
$0.88
www.siliconchip.com.au
April 2002 33
|