Power Management - 6-Channel DMX Dimmer - AN2302 - Farnell
Power Management - 6-Channel DMX Dimmer - AN2302 - Farnell
Power Management - 6-Channel DMX Dimmer - AN2302 - Farnell
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Application Note Abstract<br />
<strong>Power</strong> <strong>Management</strong> - 6-<strong>Channel</strong> <strong>DMX</strong> <strong>Dimmer</strong><br />
<strong>AN2302</strong><br />
Author: Petro Kobluk<br />
Associated Project: Yes<br />
Associated Part Family: CY8C27443<br />
GET FREE SAMPLES HERE<br />
Software Version: PSoC Designer 4.2<br />
Associated Application Notes: None<br />
Basic principles of 6-<strong>Channel</strong> <strong>DMX</strong> <strong>Dimmer</strong> operation are described in this Application Note. A <strong>DMX</strong> dimmer can be used to<br />
control the brightness of remote lighting in theaters, discos, and concert halls. The device is controlled via a <strong>DMX</strong> interface.<br />
The structure, device function algorithm, interconnection circuits, <strong>DMX</strong> Protocol, and fundamental design aspects based on the<br />
PSoC® device are considered.<br />
Introduction<br />
Nowadays computer-controlled equipment techniques,<br />
consoles, and control panels are used to control effects<br />
and stage lighting in theatres, discos, concert halls, etc.<br />
The <strong>DMX</strong> <strong>Dimmer</strong> is used to convert the device input<br />
signal into an analog representation of lamp brightness<br />
(power).<br />
Table 1. 6-<strong>Channel</strong> <strong>DMX</strong> <strong>Dimmer</strong> Characteristics<br />
Number of <strong>Channel</strong>s 6<br />
Lamp <strong>Power</strong> Depending on TRIAC Used<br />
<strong>Power</strong> Supply DC 5V, 100 mA<br />
AC Synchronization AC 110-220V, 47-63 Hz, Automatic Turning<br />
Address Range From 1 to 512<br />
Service Features <strong>DMX</strong> Bus Sleep-Mode Support<br />
<strong>DMX</strong> Protocol<br />
<strong>DMX</strong> protocol was established by the United States<br />
Institute for Theatre Technology (USITT) in 1986. This<br />
protocol represents standard interface for data<br />
communication between devices that are used for lighting.<br />
In 1990, revisions were made and now the protocol is<br />
known as USITT <strong>DMX</strong>512.<br />
The <strong>DMX</strong> protocol uses the RS485 standard, which<br />
defines electrical interface, voltage, and current.<br />
This standard supports receiver and transmitter “ground”<br />
connection to the cable core screen in order to lower the<br />
influence of external noise and improve electrical safety.<br />
The <strong>DMX</strong> <strong>Dimmer</strong> has the following characteristics (see<br />
Table 1).<br />
But the values of transmitter and receiver “ground” line<br />
voltage can be different, which causes current to pass<br />
through the cable screen. If the value of this current is too<br />
great, the <strong>DMX</strong> cable and the circuit can be destroyed.<br />
In order to correctly work devices that use <strong>DMX</strong>, to control<br />
the interface, and also improve usage safety, it is<br />
necessary to implement galvanic isolation on the <strong>DMX</strong><br />
receiver devices.<br />
The <strong>DMX</strong> data stream is passed in the form of a burst that<br />
is repeated continually. This data burst consists of the<br />
synchro preamble that informs the receiver when it starts.<br />
August 25, 2005 Document No. 001-31164 Rev. ** 1<br />
[+] Feedback
This stream contains the values of each channel from 1 to<br />
512, or less (see Figure 1, Table 2). The bit rate in the<br />
<strong>DMX</strong> protocol is 250 kB. So, the duration of every bit is 4<br />
µs. The number of channels passed is not fixed, but is<br />
limited by the standard, which is from 24 to 512.<br />
Figure 1. Structure of a <strong>DMX</strong>512 Signal<br />
<strong>AN2302</strong><br />
If the information is given over all 512 channels, then the<br />
maximum frequency that the information is updated is at<br />
44,115 Hz. The maximum frequency that the information is<br />
transmitted can be 836 Hz, which corresponds to<br />
24 channels. Upon a long signal delay (more than 1s), the<br />
device can enter <strong>DMX</strong> sleep mode.<br />
1 2 3 6 7<br />
9<br />
Table 2. Data Stream Description and Duration<br />
Item Description Duration<br />
1 Space for Break (Reset) Min. 88 µs<br />
2 Mark After Break (MAB) 8 µs – 1s<br />
3 Slot Time 44 µs<br />
4 Mark Time Between Slots 0 µs – 1s<br />
5 Start Bit 4 µs<br />
6 Least Significant Data Bit 4 µs<br />
7 Most Significant Data Bit 4 µs<br />
8 Stop Bit 4 µs<br />
9 Mark Before Break (MBB) 0 µs – 1s<br />
Start byte <strong>Channel</strong> 1 <strong>Channel</strong> 512<br />
4 5<br />
8<br />
Lamp <strong>Power</strong> Phase Control<br />
The TRIAC and lamp interconnection circuit example is<br />
shown in Figure 2. This setup allows the control of lamp<br />
brightness by varying the delay between AC line zerocrossing<br />
and TRIAC ON events (see Figure 3). When<br />
control impulses are sent to the TRIAC, it switches to ON<br />
state. The TRIAC OFF state is automatically triggered<br />
when the voltage falls to zero at the next zero-crossing<br />
event.<br />
Note The dimmer can be used with varying AC<br />
frequencies; therefore, the AC line frequency needs to be<br />
measured in order to provide correct dimmer operation<br />
regardless of the actual power supply parameters.<br />
August 25, 2005 Document No. 001-31164 Rev. ** 2<br />
[+] Feedback
<strong>DMX</strong> <strong>Dimmer</strong><br />
110-220 V AC ~<br />
AC mains<br />
zero-crossing<br />
Triac control<br />
Voltage in Lamp<br />
110-220 V AC~<br />
Figure 2. TRIAC and Lamp Interconnection Circuit Example<br />
TRIAC<br />
The <strong>DMX</strong> <strong>Dimmer</strong> block diagram is shown in Figure 4. The<br />
<strong>DMX</strong> Receiver receives data in accordance to the preset<br />
address range and translates them in the TRIAC Control<br />
Unit. When the value of the voltage is zero, the AC<br />
Synchronizer (zero-crossing detector) generates the<br />
lockout pulses that are used to delay initialization of the<br />
counters.<br />
<strong>DMX</strong><br />
AC<br />
<strong>DMX</strong> Receiver<br />
Synchronizer<br />
from AC<br />
TRIAC CONTROL<br />
LAMP<br />
Figure 3. Timetable of Lamp <strong>Power</strong> Phase Control<br />
Delay 1 Delay 2 Delay 3<br />
Figure 4. <strong>DMX</strong> <strong>Dimmer</strong> Block Diagram<br />
Triac Control<br />
Unit<br />
t<br />
t<br />
t<br />
t<br />
<strong>AN2302</strong><br />
The TRIAC Control Unit has 6 independent counters.<br />
When the lockout pulse enters from the AC Synchronizer,<br />
the counters start their operation. If the counter reaches<br />
the preset brightness compare value, the control impulse<br />
for the TRIAC ON event is generated to turn the TRIAC<br />
on.<br />
Note The power supply of the AC Synchronizer and lamp<br />
must be the same.<br />
<strong>Channel</strong> 1<br />
<strong>Channel</strong> 2<br />
***<br />
<strong>Channel</strong> 5<br />
<strong>Channel</strong> 6<br />
August 25, 2005 Document No. 001-31164 Rev. ** 3<br />
[+] Feedback
<strong>DMX</strong> <strong>Dimmer</strong> Operation<br />
Figure 5 illustrates the <strong>DMX</strong> <strong>Dimmer</strong> circuit.<br />
J1<br />
J2<br />
<strong>DMX</strong><br />
J3<br />
DC<br />
(B)<br />
R1<br />
100k<br />
(A)<br />
2<br />
1<br />
110-220 AC<br />
1<br />
2<br />
3<br />
4<br />
5<br />
2<br />
1<br />
1<br />
DV1 1n4148<br />
R2<br />
10k<br />
R5<br />
100k<br />
DF04 832A<br />
3<br />
4 - +<br />
D1<br />
R3<br />
51.1k<br />
R6<br />
10k<br />
2<br />
(C)<br />
DV2<br />
8V<br />
(D)<br />
VCC 8<br />
RO 1<br />
RE 2<br />
DE 3<br />
6<br />
7<br />
5<br />
U4<br />
DO/RI<br />
DO/RI<br />
GND DI<br />
75LBC176A<br />
4<br />
VCC<br />
C8<br />
10u<br />
C1<br />
47u<br />
2<br />
+<br />
OUT<br />
3<br />
-<br />
V-<br />
7<br />
U1A<br />
Gnd<br />
LM311<br />
V+ 8<br />
4<br />
1<br />
VCC2<br />
C9<br />
0.1u<br />
R8 2k<br />
1<br />
C10<br />
0.1u<br />
2<br />
C11<br />
0.1u<br />
Figure 5. <strong>DMX</strong> <strong>Dimmer</strong> Circuit<br />
1<br />
2<br />
U5 H11L1<br />
U2 H11L1<br />
C12<br />
0.1u<br />
In order to isolate the high voltage section from other parts<br />
of the circuit, it is necessary to do galvanic isolation using<br />
the optoisolator, U2 H11L1.<br />
R7<br />
1.47k<br />
6<br />
4<br />
5<br />
VCC<br />
VCC<br />
6<br />
4<br />
5<br />
R15<br />
270R<br />
<strong>AN2302</strong><br />
August 25, 2005 Document No. 001-31164 Rev. ** 4<br />
R4<br />
270R<br />
F100<br />
<strong>DMX</strong><br />
1<br />
U6<br />
Vs<br />
+Vout<br />
6<br />
14<br />
SYNCin SYNCout<br />
8<br />
2<br />
0Vin<br />
0Vout<br />
5<br />
DCP010505BP<br />
SW1<br />
S2<br />
C13<br />
10u<br />
SW2<br />
S1<br />
VCC<br />
U3<br />
Vcc<br />
28<br />
TR6<br />
R9 C2<br />
SLP<br />
1<br />
2<br />
3<br />
4<br />
P0[7]<br />
P0[5]<br />
P0[3]<br />
P0[1]<br />
P0[6]<br />
P0[4]<br />
P0[2]<br />
P0[0]<br />
27<br />
26<br />
25<br />
24 F100 TR5<br />
47R<br />
R10<br />
0.47u<br />
C3<br />
SW8<br />
SW6<br />
SW4<br />
SW2<br />
5<br />
6<br />
7<br />
8<br />
P2[7]<br />
P2[5]<br />
P2[3]<br />
P2[1]<br />
P2[6]<br />
P2[4]<br />
P2[2]<br />
P2[0]<br />
23<br />
22<br />
21<br />
20<br />
SW7<br />
SW5<br />
SW3<br />
SW1<br />
TR4<br />
47R<br />
R11<br />
47R<br />
0.47u<br />
C4<br />
0.47u<br />
9<br />
SMP Xres<br />
19<br />
TR3<br />
R12 C5<br />
SW9<br />
TR6<br />
TR4<br />
TR2<br />
10<br />
11<br />
12<br />
13<br />
P1[7]<br />
P1[5]<br />
P1[3]<br />
P1[1]<br />
P1[6]<br />
P1[4]<br />
P1[2]<br />
P1[0]<br />
18<br />
17<br />
16<br />
15<br />
<strong>DMX</strong><br />
TR5<br />
TR3<br />
TR1 TR2<br />
47R<br />
R13<br />
0.47u<br />
C6<br />
14<br />
Vss<br />
CY8C27443_DIP28<br />
TR1<br />
47R<br />
R14<br />
0.47u<br />
C7<br />
SLP<br />
SW9<br />
SW8<br />
SW7<br />
SW6<br />
SW5<br />
SW4<br />
SW3<br />
SW2<br />
SW1<br />
C14<br />
0.1u<br />
SW3<br />
S0<br />
47R<br />
VCC<br />
U7 LP2950-5.0<br />
3<br />
IN OUT<br />
1<br />
GND<br />
2<br />
0.47u<br />
C15<br />
10u<br />
C16<br />
0.1u<br />
VCC2<br />
C17<br />
0.1u<br />
Zero-crossing detection is implemented using U1, a lowcost<br />
LM311 comparator. At Point “A” (after the diode<br />
bridge), the voltage is in the form of a fully-rectified<br />
sinusoid (Figure 6).<br />
Figure 6. Clocking Unit Voltages of Points A, B, C Relative to Point D<br />
Point “A”<br />
Point “B”<br />
Point “C”<br />
Comparator Out<br />
8.7 V<br />
8 V<br />
AC Synchronize<br />
Out t<br />
t<br />
t<br />
t<br />
t<br />
8<br />
7<br />
6<br />
5<br />
4<br />
3<br />
2<br />
1<br />
Triacs<br />
J4<br />
[+] Feedback
The zener diode DV2 and capacitor C1 forms the 8V DC<br />
level relative to point «D». Voltage is scaled down to 1.3V<br />
by the voltage divider formed from R3 and R6. The 1.3V is<br />
used as a reference for negative comparator input. In point<br />
«В», voltage is in the form of a fully-rectified sinusoid.<br />
Voltage is supplied on positive input of the comparator by<br />
the voltage divider across R2 and R5. The comparator<br />
detects zero-crossing events and transmits them via the<br />
optocoupler, U2.<br />
The complexity of zero-crossing detection is compensated<br />
for by stable and reliable operation, noise-immunity, and<br />
testing in many industrial applications, including<br />
automated welding machines.<br />
Figure 7. PSoC Internal User Module Configuration<br />
<strong>AN2302</strong><br />
The <strong>DMX</strong> receiver operates from PSoC’s RX8 receiver<br />
and Counter8 (Figure 7). The signal is supplied for the<br />
RX8 receiver and Counter8 through the RS485 differential<br />
receiver, U4 75LBC176A, and the optocoupler, U5. In order<br />
to provide galvanic isolated power supply for the U4<br />
receiver, the U6 DCP010505BP DC/DC converter and U7<br />
low-drop LP2950-5.0 DC regulator are used.<br />
The TRIAC control unit is built using PWM generators and<br />
the output signal is differentiated using a first order RC<br />
high pass filter.<br />
August 25, 2005 Document No. 001-31164 Rev. ** 5<br />
[+] Feedback
It is important to provide good heat sink for the TRIACS,<br />
which are used to control the power lamp. This is why they<br />
are placed outside the PCB.<br />
CONTROL<br />
CONTROL<br />
R<br />
1K1<br />
Figure 8. TRIAC Interconnection Circuit<br />
(a) Low Lamp <strong>Power</strong>, (b) High Lamp <strong>Power</strong><br />
R Db<br />
1K<br />
Db<br />
1<br />
2<br />
<strong>AN2302</strong><br />
Figure 8 shows two different TRIAC circuits (depending on<br />
lamp power, low or high). The TRIAC, with a built-in<br />
optocoupler, is used for the galvanic isolation control<br />
circuit. This isolates the circuit from the power circuits.<br />
Diode Db provides differential network capacitor discharge.<br />
TRIAC DRIVER<br />
1<br />
2<br />
(a)<br />
TRIAC DRIVER<br />
MOT3061<br />
SW1, SW2, and SW3 are used to set the address of the<br />
device and enable <strong>DMX</strong> bus sleep mode. The maximum<br />
number of channels specified by the <strong>DMX</strong>512 Protocol is<br />
512. The starting channel address is set by 3 DIP<br />
switches, described as follows:<br />
SW1/1 – is the address MSB, bit 8,<br />
SW2/4 – 7,<br />
SW2/3 – 6,<br />
SW2/2 – 5,<br />
SW2/1 – 4,<br />
SW3/4 – 3,<br />
SW3/3 – 2,<br />
SW3/2 – 1,<br />
SW3/1 – is the address LSB, bit 0.<br />
SW1/2 and SW1/3 – are reserved.<br />
SW1/4 is used to set <strong>DMX</strong> bus sleep mode. If there is no<br />
signal on the <strong>DMX</strong> line for more than 1s, (see the <strong>DMX</strong><br />
Protocol), sleep mode activates and all lamps are switched<br />
off. If sleep mode is not enabled, the device continues to<br />
power itself at the lamp’s last values of brightness (power).<br />
6<br />
4<br />
(b)<br />
S202T01<br />
6<br />
4<br />
R<br />
POWER TRIAC<br />
~AC LINE<br />
CS20-12io1<br />
~AC LINE<br />
The <strong>DMX</strong> receiver receives the signal on the RX8. The<br />
Counter8 is used to detect the break signal, the duration of<br />
which is at minimum 88 µs. The <strong>DMX</strong> line is sent on the<br />
RX8 receiver and Counter8 simultaneously (see Figure 7).<br />
The break signal is detected by triggering a counter<br />
interrupt. The GPIO interrupt is used to reset Counter8.<br />
The GPIO interrupt is activated from the same <strong>DMX</strong> line.<br />
RX8 chooses the data bytes from the <strong>DMX</strong> bus, and<br />
increments the software channel counter.<br />
CMP comparator is used to generate zero-crossing<br />
interrupts, because the GPIO interrupt resource is already<br />
taken and PSoC has no dedicated flag registers to<br />
determine which GPIO pin triggered the interrupt.<br />
Program Operation<br />
The data are received in real-time from the <strong>DMX</strong> line and<br />
TRIAC control unit. That is why it is very important to<br />
separate these functions. If one of these functions misses<br />
its specified deadline, faulty operation can occur.<br />
August 25, 2005 Document No. 001-31164 Rev. ** 6<br />
[+] Feedback
Using the software PWM to control the TRIACS is not an<br />
optimal solution. Program operation is based on<br />
processing short interrupts. When there is no active<br />
interrupt handling, the device is waiting but inactive. The<br />
duration of the data burst, which is received by the RX8, is<br />
only 44 µs.<br />
Table 3. Interrupt Sources<br />
<strong>AN2302</strong><br />
With the PSoC system clock (IMO) of 24 MHz, the data<br />
burst takes 1056 cycles. The sum of the interrupt handler<br />
execution times must be less than this time. Five sources<br />
of interrupts are used (see Table 3). To minimize their<br />
duration they are written in assembly.<br />
# Source Type IMO Cycles (Maximum)<br />
1 Counter8 Terminal Count 35<br />
2 RX8 Receiver Full 284<br />
3 GPIO Rising Edge 23<br />
4 Analog Column1 Rising Edge 193<br />
5 Sleep Timer Terminal Count 78<br />
The PSoC initialization flowchart is shown in Figure 9.<br />
Initialization consists of two functions. First, AC line<br />
frequency calibration occurs and second, initialization of<br />
variables and modules occurs. These variables are<br />
necessary for device operation.<br />
Initialization<br />
bCount = 0<br />
wFrequency = 0<br />
M8C_EnableIntMask<br />
(INT_MSK0,<br />
INT_MSK0_ACOLUMN_1);<br />
M8C_EnableGInt;<br />
CMPPRG_1_Start<br />
(CMPPRG_1_HIGHPOWER);<br />
wFrequency == 0<br />
-<br />
Figure 9. PSoC Initialization Flowchart<br />
M8C_DisableIntMask<br />
(INT_MSK0,<br />
INT_MSK0_ACOLUMN_1)<br />
Counter8_WritePeriod(175)<br />
CounterCLK = VC1<br />
CounterENABLE = Row0Input2<br />
VC2 = 1<br />
VC3Divider =<br />
CalibrationFrequency<br />
(Counter8_bReadCounter())<br />
+<br />
b<strong>Power</strong>1 = 0<br />
b<strong>Power</strong>2 = 0<br />
b<strong>Power</strong>3 = 0<br />
b<strong>Power</strong>4 = 0<br />
b<strong>Power</strong>5 = 0<br />
b<strong>Power</strong>6 = 0<br />
bSl = 0<br />
M8C_EnableIntMask<br />
(INT_MSK0,<br />
INT_MSK0_ACOLUMN_1)<br />
Counter8_EnableInt()<br />
Counter8_Start()<br />
RX8_EnableInt()<br />
M8C_EnableIntMask<br />
(INT_MSK0,INT_MSK0_GPIO)<br />
M8C_EnableIntMask(INT_MSK<br />
0, INT_MSK0_SLEEP)<br />
PWM8_1_EnableInt()<br />
PWM8_2_EnableInt()<br />
PWM8_3_EnableInt()<br />
PWM8_4_EnableInt()<br />
PWM8_5_EnableInt()<br />
PWM8_6_EnableInt()<br />
IDLE Loop<br />
August 25, 2005 Document No. 001-31164 Rev. ** 7<br />
[+] Feedback
AC line frequency calibration is carried out only when the<br />
device is turned on and is intended to adjust TRIAC turnon<br />
angle setting appropriately for the utilized line<br />
frequency.<br />
AC Line<br />
Counter8<br />
PWM8<br />
Period<br />
Figure 10. Calibration Procedure<br />
16 AC Line Half Cycles<br />
<strong>AN2302</strong><br />
There are 255 lamp brightness levels. The value of the<br />
PWM generator period is set constant and equal to<br />
256 clock pulses. The VC3 divider supplies the clock. The<br />
duration of the PWM period must be equal to exactly ½ of<br />
AC line period (Figure 10).<br />
1<br />
T= CountValue<br />
2Fmains t<br />
After Calibration<br />
This is done by tuning the VC3 divider during the<br />
calibration procedure. It operates in the following way:<br />
Counter8 starts counting during 16 AC line zero-crossing<br />
comparator interrupts (16 half cycles). The count value is<br />
used for VC3 divider calculation in the<br />
CalibrationFrequency() routine using the following<br />
formulas:<br />
CntValue<br />
1<br />
=<br />
Cnt 2 ⋅ f<br />
Clock<br />
Equation 1<br />
256 1<br />
=<br />
PWM Clock 2 ⋅ f<br />
Equation 2<br />
CntValue<br />
256<br />
=<br />
Cnt PWM<br />
VC =<br />
3<br />
Clock Clock<br />
CntValue ⋅VC<br />
256<br />
cal<br />
3<br />
Equation 3<br />
Equation 4<br />
VC3 cal , the value during the calibration procedure, is set to<br />
100 and f is the AC line frequency.<br />
For increased measurement precision, the calibration<br />
procedure integrates 16 half cycles of the AC line<br />
frequency. For correct Counter8 and PWM8 during these<br />
16 half cycles, the clock frequency is reduced by a factor<br />
of 16 by setting VC2 = 16 instead of the normal value<br />
VC2=1.<br />
wFrequency is a flag that shows that calibration has<br />
competed. Once the program starts, this flag is reset and<br />
the AnalogColumn1 interrupts are enabled. The flag reset<br />
is done in the master program by the AnalogColumn1<br />
interrupt handler. After that, the values of the necessary<br />
dividers are set and Counter8 settings are modified for use<br />
as a break detector.<br />
At the second part of PSoC initialization, the variables and<br />
necessary modules for device initialization are carried out.<br />
First, the variables, which contain the brightness of each<br />
lamp, are reset. Next, the necessary interrupt permission<br />
flags are set and two modules start: Counter8 and CMP.<br />
When the break signal passes over the <strong>DMX</strong> line, the<br />
Counter8 interrupt handler is brought in. The<br />
wAddressCounter variable is reset and the RX8 is<br />
restarted in the Counter8 interrupt handler (Figure 11).<br />
Figure 11. Counter8 Interrupt Flowchart<br />
Counter8 INTERRUPT<br />
wAddressCounter RESET<br />
RX8 RESET<br />
August 25, 2005 Document No. 001-31164 Rev. ** 8<br />
Return<br />
t<br />
t<br />
[+] Feedback
The GPIO is used for the zeroing of Counter8 (this is in the<br />
absence of an enable signal on the Counter8). See<br />
Figure 12.<br />
Figure 12. GPIO Interrupt Flowchart<br />
GPIO INTERRUPT<br />
Counter8 RESET<br />
Return<br />
The SleepTimer interrupt handler flowchart is shown in<br />
Figure 13.<br />
Figure 13. SleepTimer Interrupt Flowchart<br />
SleepTimer INTERRUPT<br />
PRT0DR[1] == 1<br />
+<br />
bSl == 0<br />
+<br />
b<strong>Power</strong>1 = 0;<br />
b<strong>Power</strong>2 = 0;<br />
b<strong>Power</strong>3 = 0;<br />
b<strong>Power</strong>4 = 0;<br />
b<strong>Power</strong>5 = 0;<br />
b<strong>Power</strong>6 = 0;<br />
Return<br />
-<br />
-<br />
<strong>AN2302</strong><br />
Initialization of the variables that contain lamp brightness<br />
value is done under the following conditions: <strong>DMX</strong> bus<br />
sleep-mode support switched ON and interrupt handler is<br />
not set from RX8 bSl flag during the one-second time-out<br />
period.<br />
The AnalogColumn1 interrupt handler from the comparator<br />
bus consists of two functions. First the device relative to<br />
the AC line frequency is calibrated and second, the PWMs<br />
are initiated. The flowchart of the AnalogColumn1 interrupt<br />
handler is shown in Figure 14. Once the wFrequancy flag<br />
is cleared (calibration has not yet occurred),<br />
incrementation of the bCount counter is done. When the<br />
counter value is equal to zero, the Counter8 starts. When<br />
the counter value is equal to 16, the Counter8 stops and<br />
the calibration completion flag is set.<br />
If calibration was done, the interrupt handler from the<br />
comparator stops all PWMs and sets PulseWidth of all<br />
PWMs according to preset lamp brightness (which is<br />
saved in the b<strong>Power</strong>1-6 variables in main.c).<br />
August 25, 2005 Document No. 001-31164 Rev. ** 9<br />
[+] Feedback
Figure 14. AnalogColumn1 Interrupt Flowchart<br />
+<br />
Counter8 STOP<br />
wFrequency = 1<br />
bCount == 16<br />
-<br />
-<br />
bCount ++<br />
If the data byte enters from the <strong>DMX</strong> line, the RX8<br />
interrupt handler is invoked (see Figure 15). It reads the<br />
data and status bytes. If wCountAddress contains more<br />
than 512 channels, or errors in the byte status are<br />
detected (OverrunError, FramingError), the RX8 stops.<br />
Counter8 is used to restart the RX8 interrupt handler. This<br />
means that a new data burst has entered. On the other<br />
hand (the value of address counter is correct and there are<br />
no errors), the device address is formed in the wSwitch<br />
variable and then compared with the value of the address<br />
counter. If the address of any lamp matches the value of<br />
the address counter, the data byte is put in the<br />
corresponding variable. After the comparison, the address<br />
counter is incremented.<br />
The RX8 interrupt handler also sets the bSl flag, which<br />
means the <strong>DMX</strong> bus is active. If the value of lamp<br />
brightness is 255, the TRIACS will malfunction (because<br />
voltage of the AC line frequency is not enough to support<br />
the TRIAC ON state). Therefore, lamp brightness must be<br />
no greater than 254. The difference between 254 and 255<br />
is 0.02%, which is imperceptible to the human eye.<br />
Return<br />
Analog Column1 INTERRUPT<br />
wFrequency == 0<br />
PWM8_1 STOP<br />
PWM8_2 STOP<br />
PWM8_3 STOP<br />
PWM8_4 STOP<br />
PWM8_5 STOP<br />
PWM8_6 STOP<br />
PulseWidth1 = b<strong>Power</strong>1<br />
PulseWidth2 = b<strong>Power</strong>2<br />
PulseWidth3 = b<strong>Power</strong>3<br />
PulseWidth4 = b<strong>Power</strong>4<br />
PulseWidth5 = b<strong>Power</strong>5<br />
PulseWidth6 = b<strong>Power</strong>6<br />
PWM8_1 START<br />
PWM8_2 START<br />
PWM8_3 START<br />
PWM8_4 START<br />
PWM8_5 START<br />
PWM8_6 START<br />
<strong>AN2302</strong><br />
August 25, 2005 Document No. 001-31164 Rev. ** 10<br />
-<br />
bCount == 0<br />
+<br />
Counter8 START<br />
bCount ++<br />
+<br />
In order to increase noise immunity (oscillations of electric<br />
supply network), all PWMs stop when their counter value<br />
is equal to zero. This triggers the TerminalCount interrupt<br />
handler for each PWM. This technique eliminates phase<br />
error accumulation caused by AC frequency measurement<br />
errors.<br />
[+] Feedback
Figure 15. RX8 Interrupt Flowchart<br />
RX8 INTERRUPT<br />
bStatus =RX8_bReadRxStatus<br />
bData=RX8_bReadRxData<br />
bSl=1<br />
bData == 255<br />
-<br />
(FramingError ) |<br />
(wAddressCounter >512) |<br />
(OverrunError)<br />
-<br />
wSwitch = PRT2DR<br />
wSwitch+1 = PRT1DR[7]<br />
if(wAddressCounter =wSwitch+0)<br />
b<strong>Power</strong>1=bData;<br />
if(wAddressCounter =wSwitch+1)<br />
b<strong>Power</strong>2=bData;<br />
if(wAddressCounter =wSwitch+2)<br />
b<strong>Power</strong>3=bData;<br />
if(wAddressCounter =wSwitch+3)<br />
b<strong>Power</strong>4=bData;<br />
if(wAddressCounter =wSwitch+4)<br />
b<strong>Power</strong>5=bData;<br />
if(wAddressCounter =wSwitch+5)<br />
b<strong>Power</strong>6=bData;<br />
wAddress Counter ++<br />
Return<br />
+<br />
+<br />
bData=254<br />
RX8 STOP<br />
<strong>AN2302</strong><br />
August 25, 2005 Document No. 001-31164 Rev. ** 11<br />
[+] Feedback
TRIAC Control, Synchronization<br />
Signal Waveforms<br />
Figure 16 shows the four waveforms collected.<br />
AC line frequency<br />
Signal on AC Synchronizer output (in Figure 5 it is<br />
called “F100”)<br />
Signal on PWM output<br />
TRIAC control pulse<br />
Figure 16. TRIAC Control and Synchronization Signal Waveforms<br />
Figure 17. Board<br />
<strong>AN2302</strong><br />
August 25, 2005 Document No. 001-31164 Rev. ** 12<br />
[+] Feedback
Summary<br />
The optimal structure for a multi-channel dimmer system<br />
(more than 6 channels) is a two-chip design (Figure 18).<br />
The <strong>DMX</strong> Protocol receiver can be implemented using the<br />
low-cost, CY8C21xxx PSoC device family. The 16-channel<br />
PWM generator can be built using the CY8C29xxx family<br />
or even a software implemented multi-channel PWM<br />
generator. In this case, the second chip can be from the<br />
CY8C21xxx family as well.<br />
OPTO<br />
AC Zero -<br />
Crossing<br />
Detector<br />
21 Family<br />
<strong>DMX</strong><br />
Receiver<br />
Data<br />
Ready for<br />
Next<br />
Figure 18. 16-<strong>Channel</strong> <strong>DMX</strong> System<br />
21 or 29 Family<br />
Zero-Crossing Module<br />
Frequency Calibration<br />
PWM Control<br />
Up to 16<br />
TRIACS<br />
Lamp 1<br />
Lamp 16<br />
<strong>AN2302</strong><br />
August 25, 2005 Document No. 001-31164 Rev. ** 13<br />
[+] Feedback
About the Author<br />
Name: Petro Kobluk<br />
Title: Application Engineer<br />
Background: Petro graduated from National<br />
University “Lviv Polytechnic”<br />
(Ukraine) in 2001 with a degree<br />
specializing in computer<br />
systems.<br />
Contact: petro_kobluk@ukr.net<br />
<strong>AN2302</strong><br />
In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new documentation<br />
number and revision code (001-xxxxx, beginning with rev. **), located in the footer of the document, will be used in all subsequent revisions.<br />
PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, and PSoC Express are trademarks<br />
of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.<br />
Cypress Semiconductor<br />
198 Champion Court<br />
San Jose, CA 95134-1709<br />
Phone: 408-943-2600<br />
Fax: 408-943-4730<br />
http://www.cypress.com/<br />
© Cypress Semiconductor Corporation, 2005-2007. The information contained herein is subject to change without notice. Cypress Semiconductor<br />
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any<br />
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or<br />
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as<br />
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The<br />
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies<br />
Cypress against all charges.<br />
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide<br />
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a<br />
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative<br />
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress<br />
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source<br />
Code except as specified above is prohibited without the express written permission of Cypress.<br />
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT<br />
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the<br />
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or<br />
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a<br />
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems<br />
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.<br />
Use may be limited by and subject to the applicable Cypress software license agreement.<br />
August 25, 2005 Document No. 001-31164 Rev. ** 14<br />
[+] Feedback