This is only a preview of the December 2021 issue of Silicon Chip.
You can view 40 of the 112 pages in the full issue, including the advertisments.
Articles in this series:
Items relevant to "Hummingbird Audio Amplifier":
Items relevant to "SMD Trainer Board":
Articles in this series:
Items relevant to "Digital Lighting Controller Translator":
Items relevant to "USB Cable Tester – Part 2":
Purchase a printed copy of this issue for $11.50.
Digital Lighting Controller Translator By Tim Blythman Last year’s Flexible Digital Lighting Controller project is a fresh design that controls mains-powered lights or addressable RGB LED lighting strips to create spectacular lighting shows. But many people have built our previous lighting controllers from 2010 & 2011. So that you can upgrade without redoing it all from scratch, this Translator allows all of the original Lighting Controller slave units to operate with the new system. T he Digital Lighting Controller published in the October, November & December 2010 issues (siliconchip. com.au/Series/14) allows up to 32 mains-powered incandescent lights or 12V LED strips to be choreographed to music. It is controlled by a master unit based around a dsPIC33FJ64 microcontroller which controls the lights and plays the music. As there weren’t many easier ways to do that at the time, quite a few were built, including from kits. We designed the Flexible Digital Lighting Controller (siliconchip.com. au/Series/351) 10 years later to supersede the older units. Similar in concept, it can control up to 64 lighting channels. It also uses trailing-edge siliconchip.com.au dimming instead of the older style leading-edge dimming that is only really suitable for incandescents. Trailing-edge dimming is ideal for modern mains-powered LED lamps as it mitigates inrush currents by switching on near the mains voltage zero crossing. It is fully compatible with incandescent globes too. We also designed a separate slave unit to handle so-called ‘smart’ low-voltage LED strings, published in December 2020. This includes the options to set up groups of multiple LEDs to cover a wider area. Thus, the new system can control either mains-powered or low-voltage LED lights. Both Flexible slave unit types are addressable, so a combination of mains and low-voltage LEDs can be driven by the same channel in synchrony. But the 2010/11 and 2020 systems are incompatible and use entirely different signalling protocols and control strategies. So it is difficult to upgrade a system using the older Digital Lighting Controller. For example, the older Digital Lighting Controller continually outputs data to precisely control each switching event in time with the mains waveform; there are around 2000 switching events per second. On the other hand, the Flexible Lighting Controller only transmits data if the display needs to change, with the slaves handling mains synchronisation. This small unit brings together the two different Digital Lighting Controller systems. It takes its input from any of the 2020 Flexible Digital Lighting Controller master units (which could just be an Arduino board) and can drive the older Digital Lighting Controller slaves from 2010 or 2011. Altronics still stocks kits for these slave units (Cat K5886 & K5887). The logical way to bridge this gap is with a protocol translator. The Translator we present here receives data in the ‘new’ format and transmits the ‘old’ format. This means that the master unit presented in November 2020 can be used to control the older slave units as well as the newer ones it is designed to interface with. This master from November 2020 is based around the Micromite BackPack hardware and offers a graphical interface lacking on the older unit. So you can now use this master to control any of the four different types of slave unit. It is also possible to use a USBSerial converter to control the Flexible Digital Lighting Controller slaves Australia’s electronics magazine The Translator December 2021 61 Fig.1: the Translator circuit uses the same optoisolated receiver scheme as the newer “Flexible” slave units. A pair of regulators provide the 3.3V and 6V rails needed to drive the older slaves, while four I/O pins produce the data using much the same interface as the original dsPIC33FJ64-based master unit. using a Processing sketch. In fact, the newer protocol is so simple that you can even use an Arduino board as the master of such a system. The old control protocol Both Digital Lighting Controller systems use logic-level signals transmitted over CAT5/CAT6 cable and terminated with RJ45 plugs (similar to Ethernet cables). But that’s really all they have in common. The older system passes 3.3V logic level signals over four of the conductors in the cable; these are used to drive the DATA, CLOCK, LATCH and RESET lines of a 74HC595 shift register. The shift register outputs are then used to drive either Mosfets (for the LED version) or Triacs (for the 230V version). The remaining four lines consist of 6V and 3.3V power supply rails, a ground and a chain length sense line. While the 230V version uses optoisolators in each slave to separate the mains voltage from the control signals, the LED version has no such provision. Thus much of the circuitry is tied to the same voltage rail. In fact, the master provides power and is directly connected to all shift registers in the chain. This system feeds data to the shift registers 20 times each mains halfcycle. The chain length sense line is used to detect the number of connected slaves and can thus reduce the amount of data sent if fewer than the full number of slaves are connected. It also needs to synchronise its data to the mains waveform so that the Features ● Allows Digital Lighting Controller slaves from 2010 & 2011 to be controlled by Flexible Digital Lighting Controller masters (described in 2020) ● 2010, 2011 & 2020 slaves can be mixed and controlled by a single 2020 Master unit ● Compact unit fits in UB5 Jiffy box ● Powered by 9V AC plugpack ● Uses standard CAT5/CAT6 Ethernet cables for wiring 62 Silicon Chip Australia’s electronics magazine Triacs are triggered correctly. It works well but demands high data rates and continuous attention from the master microcontroller. The new protocol The new system delegates much of the control responsibility to the slaves, which each have their own microcontroller. Each slave also has an optoisolator to isolate it from the bus and thus the master. The new protocol is inspired by DMX-512, which is used in professional lighting control systems. DMX512 uses RS-485 level differential signals at 250,000 baud. Our system uses a single-ended logic level signal at 38,400 baud because this is easier to produce and interpret. Like DMX-512, the start of a frame is marked with a ‘break’ condition on the serial data line; this is a period of around 13 bit times of low (not idle state) data level and is not a state that occurs otherwise during normal transmission. The first data byte is 0x00, which sets the frame type, meaning the subsequent data contains lamp brightness values. Other DMX-512 frame types siliconchip.com.au exist but are not used in our system. The actual data follows as consecutive bytes of serial data; the first byte after the 0x00 is sent to the first lamp, the next to the second and so forth, up to 64 lights. If you wish to implement your own master, you can also look at our Arduino and Processing code. The circuit Fig.1 is the circuit of the Translator, which has much in common with the Flexible Digital Lighting Controller slaves (described in the October & December 2020 issues). All three use 14-pin microcontrollers and 6N137 optoisolators to provide isolated reception of the data from the master. IC1 is a PIC16F1705 or PIC16LF1705 microcontroller, the same part as used in the 230V slave unit. CON4 is an ICSP header that you can use to program the chip. A 10kW resistor between pins 1 and 4 of IC1 pulls up the MCLR pin, while a 100nF capacitor provides local bypassing of the 3.3V rail that powers the microcontroller. Pins 1 and 2 of RJ45 jack CON1 are connected across the LED (pins 2 and 3) of OPTO1 with a 220W resistor in series. 1N4148 diode D1 provides reverse polarity protection to the LED by shunting current if power is applied in the reverse direction. In regular operation, the master applies +3.3V or 5V to pin 1 of CON1. Pin 2 will idle at the same voltage but is taken low when the master transmits a ‘0’ bit or a break condition. Thus current only flows when the master’s output is not at the idle voltage. OPTO1 is bypassed by another 100nF capacitor between its pin 5 (circuit ground) and pin 8 (3.3V). The output pin, pin 6, is pulled up by a 1kW resistor to the 3.3V rail. Thus, it idles at the same state as the master (high) with no current flowing. When the master transmits a ‘0’, current flows through OPTO1’s LED, and its internal circuitry causes its pin 6 to be pulled to ground. This scheme provides isolation while also maintaining the correct logic sense. Also, the disconnected state is the same as the idle state, which means the slave does not misbehave if it is not connected to a master. OPTO1’s pin 6 is connected to microcontroller IC1’s pin 5, which is configured to operate as a UART receiver at 38,400 baud. Green LED1 siliconchip.com.au in series with a 1kW resistor is also connected between the 3.3V rail and OPTO1’s output. It thus illuminates whenever the master transmits a ‘0’. While OPTO1 is probably not necessary for most applications, it is possible to connect the Translator to a computer to implement a ‘simple master’ using the Processing application. In this case, it is cheap insurance to avoid the possibility of any damage to the computer’s USB port. Keep in mind that there is no slot in the PCB, so OPTO1 will not provide isolation from mains voltages, and the clearance and creepage requirements are not met. Pins 8-11 of IC1 are connected to another RJ-45 jack, CON2, to produce data in the ‘old’ protocol. Each pin has a series 100W resistor to limit fault current and a 10kW pull-down resistor to set a safe default state while the microcontroller is starting up. For more detail on the operation of the old protocol, you can refer to the article in the October 2010 issue (siliconchip.com.au/Article/315). The pins provide the DATA, CLOCK, LATCH and RESET signals using IC1’s SPI and GPIO peripherals. IC1’s pin 7 (RC3) is connected to the CHAIN SENSE line of CON2 and is pulled down to ground by a 4.7kW resistor. Each slave has a 10kW resistor pulling this line up to its 3.3V rail, so the voltage on this pin depends on the number of slaves connected. Thus, the number of slaves can be determined by using the micro’s analog-to-digital converter (ADC) peripheral to read the voltage on this pin. Pin 3 (RA4) on IC1 is connected to a yellow LED through a series 1kW resistor to ground. It is used to flash error codes by the microcontroller’s firmware. Pin 6 (RC4) of IC1 is connected to one side of the AC supply input via a 1MW resistor and is used to detect the mains polarity and thus keep track of the mains phase. The resistor allows pin 6 to be pulled high or low by the AC waveform while limiting the current to a minimal level, so the micro’s input pin will not be damaged. Power supply 9V AC to power the circuit comes in through barrel jack CON3. We need to use AC power to allow the circuit to sense the phase of the mains waveform so that it can drive slaves controlling Australia’s electronics magazine mains-powered lights. An AC plugpack provides a safe and simple way of doing this, as well as providing power. Current flows into bridge rectifier BR1 and the resulting pulsed DC is filtered by the first of three 100μF electrolytic capacitors. REG1 is a 7806 regulator that provides a 6V rail stabilised by the second 100μF capacitor. A transformer driving a bridge rectifier and filter capacitor results in a high peak current draw as the AC waveform approaches its maximum amplitude. Therefore, a 10W series resistor has been added to limit the peak current. This reduces distortion of the AC waveform and thus improves zero-crossing detection. Red LED2’s anode is connected to the 6V rail, while its cathode is connected to circuit ground via a 1kW resistor. Thus LED2 lights up when power is present. The 6V rail also feeds REG2, an MCP1700 3.3V regulator, and a third 100μF capacitor to generate a 3.3V rail. The 6V and 3.3V rails are needed for compatibility with the slaves from the older system. Software Since many of the Translator functions are similar to those of the newer slaves, we reused some of that code. After the initial setup, the firmware does little more than check the peripheral interrupt flags to know if anything needs to be done, as there are no user inputs to monitor and act on. The setup code initialises the UART (to receive serial data from OPTO1) and SPI (for shift register data output) peripherals. A timer is set to fire around 7800 times per second. Also, the ADC peripheral is enabled, and the various I/O pins are configured for their respective roles. In the main loop, the UART is checked for incoming data and if it is detected as lamp data, it is processed immediately into arrays of shift register data for sending to the slaves. Each data byte takes up to 85μs to process and, at 38,400 baud, can arrive once every 260μs. Each byte received consists of 10 bits including the start and stop bits. The timer fires every 128μs and is used to increment a counter, so each mains half-cycle is split into 78 divisions. In the main loop, the software checks if the incoming AC waveform has flipped polarity and uses an December 2021 63 internal counter to mark that point with respect to the counter. Compensation is made for the fact that the pin does not change state precisely at the zero crossing; the pin transition voltage level is above 0V and varies depending on whether it is positive-going or negative-going. The microcontroller sets a second counter to provide a signal synchronised with each mains half-cycle. Checking the AC waveform and adjusting the counters can take up to 7μs, which is not a significant amount of time compared to the other activities that occur. Starting at the 20th (of 78) points in the cycle, the shift register bitmaps are fed to the output in turn. These 78 points are chosen to partially compensate for the instantaneous mains voltage varying over the cycle, resulting in a smoother brightness ramp. There is no setting that will give perfectly linear results for all incandescent globes, and LEDs will naturally not be affected in the same way, but the chosen numbers should give a good middle ground for all lamp types. The points are closer together near the peak and further apart near the zero crossing, which has the added benefit of diminishing the effects of jitter on the slave Triacs switching off. Scope 1 shows the timing of these data bursts. The green line is the output of the transformer, not the mains waveform itself, hence is it far from sinusoidal. Delivering this data takes around 75μs. So in the worst case of a data byte being received simultaneously with an SPI transmission, the timer could be delayed slightly. If this delay is ever longer than a 128μs timer cycle, timer counts will be missed. However, output waveform corruption due to missed timer events should not occur under normal operation, although small amounts of jitter (up to about 50μs) might occur under the very worst conditions. Note that the Translator has been programmed to only work on 50Hz mains systems. The timing is probably too tight for it to work properly on 60Hz systems. Status indicator LED Every timer cycle also triggers a check to update the status LED. Every two seconds, the AC waveform, incoming data and outgoing chain are checked. If a fault is detected, the LED flashes; otherwise, it remains solidly lit. One flash indicates that no incoming data has been received in the preceding two seconds. If you see two flashes, no downstream chain sense resistors have been detected. Three flashes let you know that no transitions have been seen in the AC waveform. Performing these checks and updating the LED state can take up to 15μs. Construction The Translator is built on a PCB coded 16110206 which measures 79mm x 45mm – see Fig.2. This fits neatly into a UB5 Jiffy box. Start by fitting and soldering the resistors as marked on the PCB silkscreen. Use a multimeter to doublecheck the resistance of each part before mounting it. Note that the resistors along the right-hand side of the board appear to be arranged in pairs, but some are not! The sole diode is next to CON1 at the bottom left of the PCB. Be sure to match the cathode mark to the silkscreen. Then fit the two 100nF capacitors, one adjacent to IC1 and one near OPTO1. Bridge rectifier BR1 is at the bottom centre of the PCB. You should ensure that its + mark goes to its bottom left, as shown on the silkscreen. Push it down against the PCB before soldering, then trim all its leads close to the PCB. Solder the two parts in DIL packages next, IC1 and OPTO1. There is room to use sockets if you wish, although Scope 1: the timing of the latch pulses relative to the mains waveform. The AC waveform is quite significantly distorted due to the properties of the transformer and the brief current inrush into the capacitor leading up to the waveform peaks. Still, it’s good enough to sense the zero crossings. The more closely-spaced pulses near mains peaks provide more even brightness steps for incandescent lights without affecting mains-powered LEDs too much. 64 Silicon Chip Australia’s electronics magazine siliconchip.com.au Fig.2: assembling the PCB is relatively straightforward; fit the parts as shown here, paying particular attention to the orientations of IC1, OPTO1, the electrolytic capacitors, diode D1 and the LEDs. If you experience issues due to control tones affecting timing, then a small value capacitor (10pf) between pins 6 and 14 of IC1 may help. there is little need for this as IC1 can be programmed in-circuit via CON4, even after it is soldered in place. Ensure OPTO1 and IC1 are orientated correctly, with their number 1 pins to the upper left of the PCB. Straighten the leads to allow them to be inserted, then tack two leads and ensure the parts are flat against the board before soldering the remaining leads. To install REG1, bend its leads back 90° around 7mm from the regulator body. Thread them through the PCB and fit one of the machine screws from the back of the PCB, then secure the regulator with the nut and washer on the front of the tab. Carefully align the regulator to be square within its footprint and tighten the nut firmly, but taking care not to twist the part. When you are happy with this, solder the leads from the back of the PCB and trim the excess. Fit REG2, making sure that it matches the outline on the silkscreen. Push down firmly and solder the leads. Mount the three electrolytic capacitors next, observing the polarity markings; all three have their positive lead closest to CON2 on the right of the PCB. Now fit the barrel socket at CON3. It may require some extra heat and solder to secure the larger tabs. You should also try to keep the part parallel to the Parts List – Digital Lighting Translator 1 double-sided PCB coded 16110206, 79mm x 45mm 1 9V AC plugpack with 2.1mm inner diameter barrel plug 2 PCB-mount RJ45 sockets (CON1, CON2) [Altronics P1448] 1 2.1mm inner diameter PCB-mount barrel socket (CON3) 1 5-way male pin header (CON4; optional, for programming IC1 in-circuit) 1 UB5 Jiffy box 4 M3 x 12mm tapped spacers 9 M3 x 6mm machine screws 1 M3 nut and washer (for REG1) 4 self-adhesive rubber feet Semiconductors 1 PIC16F1705 or PIC16LF1705 microcontroller, DIP-16, programmed with 1611020F.HEX (IC1) 1 W02M/W04M bridge rectifier (BR1) [Jaycar ZR1304] 1 6N137 optoisolator, DIP-8 (OPTO1) 1 7806 6V linear regulator, TO-220 (REG1) 1 MCP1700-3.3 low-dropout 3.3V linear regulator, TO-92 (REG2) 1 green 3mm LED (LED1) 1 red 3mm LED (LED2) 1 yellow 3mm LED (LED3) Altronics kit will be available 1 1N4148 signal diode (D1) Altronics has announced that they will be Capacitors making a kit for this project, code K5888. 3 100μF 25V electrolytic 2 100nF 63V MKT Resistors (all 1/4W axial 1% metal film) 1 1MW 5 10kW 4 1kW 1 220W 4 100W 1 10W siliconchip.com.au Australia’s electronics magazine edge of the PCB for neatness. If you wish to fit an ICSP header for programming IC1, you should use a straight (rather than right-angled) header. This can be left in place without fouling the box if it is mounted vertically. It can be mounted under or on top of the PCB as there is around 12mm of clearance on both sides. We recommend placing it underneath, as you might find that the adjacent capacitor prevents the programmer from being fully inserted onto the header from above. Next, solder the two RJ45 sockets, CON1 and CON2. They have clips to lock them in place, but it’s still a good idea to solder one lead and check that they are flat against the PCB and parallel to its edge before soldering the remaining leads. The only remaining components are the LEDs. If you wish to fit them now, leave 10-12mm from the top of their flanges to the PCB so that they sit just behind the front panel. However, it is better to leave them out until you can confirm their positioning against the assembled enclosure. Note that LED1 is green (data), LED2 is red (power) and LED3 is yellow (status). Programming IC1 Now is a good time to program microcontroller IC1 if this is required. If you buy the microcontroller from the Silicon Chip Online Shop, it will already be programmed, and you can skip this step. You can use a PICkit 3, PICkit 4 or Snap programmer. If you don’t have a programming application, we recommend using the MPLAB X IPE, which can be downloaded for free from Microchip’s website. Connect the programmer to CON4, December 2021 65 Fig.3: you might find that your UB5 Jiffy box already has small divots in the base to mark the four holes to be drilled. The side cuts start from the top of the box, so they can easily be made with a hacksaw or similar. Fig.4: before applying this panel artwork to the lid of your Translator, you can also use it as a template to mark the LED hole positions. Since the input and output connections are via identical RJ45 sockets, the panel label is a handy guide to making sure you don’t mix them up. 66 Silicon Chip Australia’s electronics magazine aligning the arrow on the programmer with the arrow on the PCB, both of which mark pin 1. From the IPE, choose the PIC16F1705 from the Parts list (or the LF version if you’re using that) and then click Connect. Browse to the HEX file, open it, then click the Program button and ensure that the “Program/Verify Complete” message appears. If you have already fitted the LEDs, the red LED should illuminate, indicating the presence of power, and the yellow LED should light up or flash after about a second. The green LED will do nothing until a signal is provided at CON1. Enclosure The PCB mounts in the bottom of a UB5 Jiffy box. If you want to test the Translator, we recommend drilling the top first, as you can use this to fit and align the LEDs. Fig.3 shows the drilling and cutting that is needed to complete the Translator. Three 3mm holes are needed for the LEDs. You can also download and print (or photocopy) our lid artwork (Fig.4) and use this to position the holes for the LEDs. We have a helpful guide to preparing panels: siliconchip. com.au/Help/FrontPanels Drill these holes as shown and then you can attach the panel artwork. If you haven’t fitted the LEDs, insert them into their respective holes and rest the lid over the top. By holding the lid against the tops of the RJ45 sockets and aligning the PCB to be centred on the lid, you can adjust the LED positions so that they fit nicely. They can then be soldered in place and their leads trimmed. This method has the advantage of compensating for any drilling inaccuracies. You can then remove the lid and siliconchip.com.au test the PCB. The drilling and cutting for the base looks a bit more elaborate but is not too involved. The Jiffy boxes that we are using have small divots at exactly the marked locations in the base of the box, so these are easy to align if your box has them. These are 3mm holes to suit the M3 machine screws. Mount the tapped spacers inside the base of the box using four screws. The square cutouts in the ends of the box are for the RJ45 sockets. Mark these with a pencil and use a hacksaw to make the vertical cuts. Score the horizontal cut with a sharp knife, and you should be able to gently flex and then snap the tab out with combination pliers. Check the fit of the sockets and use a file to open up the holes and tidy them if needed. The RJ45 sockets should sit level with the top of the base of the box. The final hole is for the barrel jack. We’ve indicated a 10mm hole to suit the plug we are using, but you should check that you don’t need a differentlysized hole to suit the plug’s body. This hole is best drilled by starting with a smaller ‘pilot’ bit, allowing you to check that the hole is aligned correctly before being enlarged. Make increasingly larger holes with larger bits, or use a step drill or tapered reamer to open the hole out further, then attach the PCB to the spacers using the remaining four screws. Completion It’s a good idea to run some final tests before closing it all up. Apply power via the barrel jack. The red power LED should light up, and you should be able to measure voltages relative to ground at REG1’s tab. Lead/pin 3 (closest to IC1) should measure close to 6V, while lead 1 will be around 12V for a 9VAC input. The 3.3V rail is best checked at IC1’s pin 1 (closest to the edge of the PCB). If these voltages are out by much, check around the bridge rectifier, capacitors and regulator, particularly for reversed parts. Yellow LED3 should be flashing once or twice every two seconds; any flashing pattern indicates that the micro is operating. If it is flashing three times, it is not detecting the AC phase correctly. If any ribs on the lid prevent it from sitting down flat against the RJ45 sockets, these can be removed by carefully cutting or filing them away. Align the lid to the LEDs and secure the lid with the screws included with the Jiffy box. Then apply the rubber feet to avoid damage from the screws on the bottom of the box. REAL VALUE AT $19.50 * PLU S P&P Using it Connect the CON1 “Data in” socket to any of the master units described in the October, November and December 2020 articles. These can be as simple as an Arduino board with two wires of half of an Ethernet cable wired to their headers (see photo below). Back then, we also presented a small PCB that can be attached to a CP2102 USB-serial adaptor, allowing a computer to act as a Master. It can be controlled using our Processing program. Some serial terminal programs may also be able to generate data for testing. Take care not to mix up the two connectors on the Translator. Doing so probably won’t cause damage, but it definitely won’t work. The green LED will flicker when the Translator receives data, indicating it’s probably wired up correctly. If all is well, connect any of the slaves described in the October 2010 or October 2011 issues to the CON2 “Data out” port. If you are only using LED slaves, then it is possible to run the Translator from a DC supply; in this case, we recommend a 9-12V DC plugpack. Note that the yellow LED will flash to indicate a fault with a missing AC waveform, but the Translator will continue to produce control signals. The Translator only translates the first 32 channels from CON1, so if you are using a mix of newer and older slaves, set the addressing switches on the newer slaves to the 33-64 range to make the best use of the available SC address space. An Ethernet cable terminated with jumper wires turns an Arduino into a Flexible Lighting Controller Master. siliconchip.com.au Silicon Chip Binders Australia’s electronics magazine Are your copies of SILICON CHIP getting damaged or dog-eared just lying around in a cupboard or on a shelf? Can you quickly find a particular issue that you need to refer to? Keep your copies safe, secure and always available with these handy binders These binders will protect your copies of SILICON CHIP. They feature heavy-board covers, hold 12 issues & will look great on your bookshelf. H 80mm internal width H SILICON CHIP logo printed in gold-coloured lettering on spine & cover Silicon Chip Publications PO Box 139 Collaroy Beach 2097 Order online from www. siliconchip.com.au/Shop/4 or call (02) 9939 3295 and quote your credit card number. *See website for delivery prices. December 2021 67