Gas station without pumps

2022 October 27

LED board schematic

Filed under: Uncategorized — gasstationwithoutpumps @ 12:40
Tags: , , ,

I did a series of posts about the LED boards that I designed for lighting and strobes (starting with Summer project in 2014), but I just realized in going over the posts that I never posted the schematic nor explained how the board worked. I had to dig out the Eagle files on my old laptop to find the schematic, then redo it in Scheme-It to make it look reasonable.

Schematic for the LED board. This design is version 8, and is the one I actually had made.

The resistor R1 is a current-sensing resistor, measuring the current through the nFET Q2 and the LED. When the current is high enough, the voltage on the base of Q1 becomes large enough to turn on the NPN transistor Q1, lowering the gate voltage on Q2 and starting to turn the nFET off.  When the current is low, Q1 is off and the resistor R2 pulls the gate voltage for Q2 up, turning on the nFET more strongly. The Schottky diode D1 is just there to protect the LED from large reverse voltages if the board is hooked up backwards.

Power is dissipated in 4 places: the LED itself, Q2, R1, and D1. Based on the measurements in LED board I-vs-V curve,  the current is limited to about 118mA, so the voltage on the base is about 0.555 V when Q1 starts to turn on and R1 dissipates about 65mW. There is some current going through R2 and Q1 that doesn’t go through the LED (probably about 1–2mA), depending on the voltage applied to the whole board, but it is only about 1% of the total current, so I’ll ignore it—we may have another 30mW dissipated in R2.

I probably should measure the voltages across R1, on the base of Q1, on the gate of Q2, on the drain of Q2,  and across D1 to get detailed information about where the power is really being dissipated.  I think that the voltage across the LED should be about 6V when the board is fully on, and the voltage drop across the Schottky diode should be small (maybe 0.1V for 12mW).  For board voltages before the current limitation cuts in, almost all the power goes to the LED.  At higher voltages, the extra voltage drop and power dissipation is all in Q2, with around 700mW dissipated in Q2 when the board voltage is 6V higher than where the current limitation starts and 700mW delivered to the LED. That’s about as high as I’d be willing to go for continuous lighting, even with a heat-sink on the board.

I should be able to make the measurements fairly easily with the Analog Discovery 2, and I might do so later this week. One thing I’m curious about is whether the drop in current with higher board temperature is due to changes in the characteristics of the NPN transistor or the nFET.  The nFET is dissipating most of the power, so its junction temperature is probably changing much more, though the LED and the nFET together warm up the whole board, so the NPN transistor is getting warm also.

2018 July 19

Dropping old LED lighting project

Filed under: Uncategorized — gasstationwithoutpumps @ 14:28
Tags: , , , , ,

About 4 years ago, I started a project to replace the breakfast room ceiling fan (which my wife has always hated) with an LED fixture of my own design.  In order to do this, I designed some custom LED boards that could work over a range of voltages with PWM control of the brightness and I made some desk and table lamps using the boards, as well as a stroboscope (Summer project, LED board I-vs-V curve, Summer project 2, Desk lamp, Newer dimmer software, LED strobe using dimmer boardHalloween 2016, … ).

Although I have had the electronics done for the breakfast room fixture for about 3 years, I’ve not been able to come up with a mechanical design that I think will look good.  Also, the task of cutting the conduit in the attic to install an outlet for the wall-wart power supply did not appeal to me, so I kept putting off the project.

Last weekend, my wife, my son, and I went to the local Habitat for Humanity ReStore, ostensibly to look for cabinet handles and doors, but mainly just to browse. While there, we saw a used drum light ceiling fixture that was on sale for only about $16 (it is one that normally sells for around $120 new from Home Depot).  Since I had pretty much given up on coming up with a design using my LED boards that would look good, and my wife liked the drum fixture, we bought it and my son helped me install it.

The hardest part of the installation was probably pulling new wire through the conduit, since I did not want to use the old cloth-covered solid copper wire that was there.  I also added a grounding screw to the junction box for the lamp, since the old ceiling lamp had no ground connection.

Here is the “new” ceiling lamp in daylight.

Here is the ceiling lamp with 3 2700K LED bulbs.

Lining up the screw holes of the fixture with the screw holes of the junction box was also a bit tricky—my son’s holding the fixture while I fussed with that was a big help.

The whole project cost under $30: $16 for the fixture, <$3 for screws and wire, $7.50 for 3 LED bulbs. The new lamp is not dimmable (because of the cheap bulbs I chose), but that feature was not really needed for the breakfast room anyway.

So I now have a lot of spare LED boards that I need to find a project for—I’ve used a few of the boards for the desk lamp and stroboscope projects, but I don’t really need another desk lamp or stroboscope.  Anyone have any ideas?

2015 December 27

Theater lights

Filed under: Uncategorized — gasstationwithoutpumps @ 00:02
Tags: , , , ,

My son and I have started on his summer project while he is home for winter break—to build a moderately bright, adjustable color theater light for WEST Performing Arts, the children’s theater troupe he has worked with for the past 11 years (including the two years before they split off from Pisces Moon).

The design is still very much in flux (we’re on our third processor choice already), and we haven’t done any parts ordering or physical prototyping yet, just thinking about circuits, parts, and layout.  We are currently planning an RGBW light with DMX control, with 20W each of red, green, and blue LEDs, and 40W of warm white LEDs, all mounted in a PAR-38 can (using an old can from WEST, rather than buying a new can).  The light will be a simple flood, which is easier to construct than a fresnel or spot light, because we don’t have to concentrate all the light into a small spot for manipulating with lenses.  Currently WEST uses 75W or 100W incandescent bulbs in their PAR cans, so the LED light should be three or four times brighter.  There are RGBW lights from China that are about the same brightness as we’re aiming for, but they are larger and more expensive—we’re aiming for a budget of about $100 a light for parts.  (We’d not be able to sell them any cheaper than the commercial lights—this is just a hobby project to make one or two lights for the theater.)

The theater has a few 15W RGB lights with DMX control, the American DJ Mega Tripar Profile, but they are only 5W per channel (not really bright enough) and it is not clear what functionality the DMX controller for them has (we didn’t look at it or find out the model number).  Because the set was a very cheap lighting set, it probably can’t handle the greater functionality we’re planned for the RGBW lights, so we’ll probably have to find or design a simple DMX controller that can be run from a Mac laptop. There are some open-source DMX controller projects on the web, but their user interfaces may be a bit too complicated for the kids (or non-techy staff) running the light booth for WEST. It is not clear whether we can design a simpler interface for a small number of lights that provides easy access to all the functionality of the lights.  There is also the question whether a traditional control board with sliders or an all-virtual laptop-based controller is a better interface for beginning lighting techs.

We might even want to look at an iPad-based controller, like Luminair ($90), LightingPad (discontinued), and RunTheShow (free, but limited to controlling their particular hardware). LightingPad says that they have pulled the product until they can update for iOS8, which was released over a year ago—since iOS9 has come out before they updated to iOS8, it seems unlikely that they will ever be able to keep up with the churn in the iPads (a complaint I’ve heard from other iPad app developers—Apple makes it very difficult for older apps to keep running, requiring a full-time developer just to keep up with Apple breaking things on each release).  Hmm, I seem to have talked myself out of developing an iPad app, but we probably should make sure our hardware can run with controllers like Luminair.

For laptops, there are open-source projects like Elios and WhiteCat.  Elios is an open-source project in Java, but it hasn’t been updated for a couple of years, so may be a dead project.  WhiteCat seems rather complicated, based on the screenshots at http://www.le-chat-noir-numerique.fr/index_eng.html, and most of the documentation is in French, which neither my son nor I reads.

Since we’re mainly interested in running on MacBooks, the OS-X-only code from LightKey may be usable.  They have a free version with 24 channels that might be usable, though upgrading to more channels gets into an expensive subscription model.

The controls we are planning for the RGBW light were 16-bit PWM on each of the 4 channels, plus a strobe frequency (in units of 0.1Hz, with 0–5 and 250–255 having special meanings—probably always off and always on).  Because the DMX512 protocol only has one byte per channel, the light would need 9 channels, and the free version of LightKey could only control 2 such lights.

The Tripar Profiles can be configured as anywhere from 1 to 7 channels:

  1. choice of 16 preset colors (“color macros”);
  2. 16 colors plus 1-byte dimmer;
  3. RGB;
  4. RGB plus master dimmer;
  5. RGB, dimmer, color macros;
  6. RGB, color macros, strobing, master dimmer;
  7. RGB, color macros, strobe or program speed, preset programs, master dimmer.

The preset programs are mainly for running the light as a standalone light show without a DMX controller, so we would not want to emulate that.  The 4-channel RGB,dimmer function is intended as a workaround for the low resolution of 8-bit PWM control—you pick the color at full brightness, then multiply by the dimmer setting to get the overall effect.  Since we are planning to use 16-bit PWM, we can get more precise color control even at dim light settings.  If we mix our light with the Tripar Profiles, we would probably use the Tripar Profiles in 4-channel mode (unless we needed strobing, in which case we’d use 6-channel mode).

I mentioned above that we’d been through three different processor choices.  At first we thought of using a Teensy board, because we’re familiar with ARM programming, the Teensy boards are easy to program, and they can be treated like a through-hole part for doing prototyping (by adding some header pins).  But the boards are a bit large, and a bit expensive ($11.65 for a Teensy LC), so we next considered using an ATtiny2313A processor (again, the ATtiny is easily programmed and I have some experience with the ATtiny13, which I used for the PWM on my desk lamps).  Unfortunately, the ATtiny2313A provides only 2 16-bit PWM channels (plus 2 8-bit channels), which is not really adequate.  Using two ATtiny2313A chips would work, but for less money and less board real estate, we can use a PIC32MX110F016B-I/SP and get 16-bit PWM on a 40MHz clock for a 610.4Hz PWM frequency.  The flexibility of the pin remapping on the PIC32 is attractive here, as it can simplify the routing of the board.

The processor not only has to interpret the DMX commands and provide PWM outputs, it also has to support the RDM (remote data management) protocol of modern DMX devices (the Tripar Profiles don’t, but there is no real excuse for not supporting RDM these days).

Here is a rough block diagram of the current design:

Each LED here is nominally a 10W LED module.

Each LED here is nominally a 10W LED module.

We’ve given some thought to the heat sink, fan, and mounting brackets for everything, but there is still more work to be done to make sure that we can really dump all the waste heat and keep the LEDs sufficiently cool.  We’re currently looking at about $80 in parts for the light (not including the can, which we’ll get from WEST) plus another $15 to make a USB-DMX interface that can handle the RDM protocol.  Those numbers may change a fair amount as we play with the design.

The two boards are each about 10cm by 5cm, which cost only $12 (for 10 copies) from Smartprototyping.  My son has done preliminary layouts of them, to see how big the boards would be and determine any mechanical problems we might encounter.

2015 July 31

Newer dimmer software

Filed under: Uncategorized — gasstationwithoutpumps @ 17:16
Tags: , ,

I just posted yesterday about new software for my PWM dimmers that provides smoother control of the light levels (having 256 levels plus off, rather than 63 levels plus off) with a 256:1 brightness range rather than the approximately 256:6 range of the previous code.

There was a bit of a problem with the lowest light level—it was more like 1/20th as bright as the second highest, rather than 1/2, and it flickered annoyingly. The other low light levels were also rather far apart, causing noticeable steps in brightness for about the first 10 steps.

So today I rewrote the code to have a genuine 512:1 brightness range (plus off), without the super-dim setting. This was a bit tricky to do, because the ATtiny13A has only a single 8-bit counter to use for PWM or any other timing.  I also wanted the minimum on-time for a pulse to be at least 5µs and the maximum PWM period to be less than 5ms.

What I did was to use the 8-bit PWM for the higher brightness levels, but turn it off for 3 PWM periods out of 4 for the low light levels.  I use the timer overflow interrupt to keep track of which PWM period I’m on, and to turn the PWM on or off.  To avoid glitches, I wait until the counter has counted up past the end of the PWM pulse, so that the PWM is only turned on or off when the output is low.  (That’s not quite true—for turning the light off or operating in the top half of brightness, I can switch the PWM mode at any time—it is only when I’m trying to do one out of four PWM periods that I need to be careful about glitches.)

I don’t have a full 1024-bit PWM range.  In addition to OFF, I have 303 light levels, 63 for low light levels (from a duty cycle of 2/1024 to 64/1024 in steps of /1024) and 240 for high light levels (from a duty cycle of 17/256 to 256/256 in steps of 1/256)

The conversion from the linear 10-bit analog-to-digital reading (0–1023) to pulse lengths is done by the following method:

if ADC >= 512
    use SHORT PWM (256)
    expon = ADC>>7
    frac = 0x80 + (ADC & 0x7f)
    pulse_len = 1+ (frac>> (7-expon))
else if ADC >= 8
    use LONG PWM (1024)
    pulse_len = 1 + (ADC >> 3)
else
    turn PWM off

The transition between the short and long PWM periods is evident in a plot of the pulse width and duty cycle:

For the first half of the range, I use a linear scaling for potentiometer to brightness, and for the second half I use a stepwise linear approximation to an exponential.

The minimum pulse width is about 6.7µs, and the long PWM period is about 3.4ms.  There is a trivial modification to allow 1/1024 duty cycle (change the first threshold from 8 to 4), but the shortest pulse is then too short to turn on the LED boards, giving either a very dim light or no light, depending on exactly how low the drain voltage gets in the available time.

I also added some hysteresis to the reading of the analog-to-digital converter, to avoid flicker from digitization noise when the value was near a threshold. The new code is a bit bigger than the previous code (372 bytes instead of 222), but still well below the 1kB limit of the flash.

I’ll need to reprogram the desk lamps again.

2015 July 30

New dimmer software

Filed under: Uncategorized — gasstationwithoutpumps @ 15:46
Tags: , , , , ,

Based on the success of the stroboscope software, I rewrote the dimmer software for my desk lamp (see LED lamp projects for more about the lamps).  The new software provides smoother control of the light levels (having 256 levels plus off, rather than 63 levels plus off) and now has a 256:1 brightness range rather than the approximately 256:6 range of the previous code.

I removed a lot of the general-purpose crap that was inherited from core13 (which was in turn stripped down from the Arduino core software).  I did not get rid of all of core13, so I could probably take out another 50–100 bytes, but the code is down to 222 bytes (and the ATtiny13A has 1kB of flash, so I’m way below the limit).

The actual brightness range of the new dimmer is a bit more than 256:1, because on the shortest pulse the FET doesn’t turn all the way on.  The pulse duration from the ATtiny13A is approximately 3.4µs times the brightness level (9.6MHz clock divided down by 4 and by 8), but I had deliberately slowed the FET transitions by adding a series resistor to the gate, so that nFET doesn’t finish turning on for 5.2µs (as judged by the end of the Miller plateau on the gate).  So at the lowest brightness level, the nFET does not turn all the way on and the voltage on the drain only gets down to 3.5V, which leaves 5.5V across the LED board—enough to turn on the LED, but with only about 10mA, not 118mA. At this low level, the LEDs sometimes flicker, perhaps as a result of some thermal feedback effects. The all flicker together, so the effect is probably in the dimmer’s nFET, not on the LED boards.

ATtiny output (green) and gate voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length.   The gate voltage has not quite reached the end of the Miller plateau before being discharged again.

ATtiny output (green) and gate voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length. The gate voltage has not quite reached the end of the Miller plateau before being discharged again.

ATtiny output (green) and drain voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length.  The BitScope BS-10 oscilloscope clips the voltage to 5.5V—it actually goes to 9V.

ATtiny output (green) and drain voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length. The BitScope BS-10 oscilloscope clips the voltage to 5.5V—it actually goes to 9V.

At the next brightness level, the drain voltage does drop to 0V for at least 2.4µs and stays low enough for the LED board to be at maximum current (below 2.5V) for at least 5.5µs.  There is an enormous difference in brightness between length 2 and length 1 pulses (more like 1:20 than 1:2), because of the low current for pulse length 1, but for length 2 and longer the steps in brightness are pretty much as one would expect from the pulse lengths.

ATtiny output (green) and gate voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length.   The gate voltage has gone past the end of the Miller plateau and started charging past that point. The Miller plateau is also visible on the discharge as the nFET turns off.

ATtiny output (green) and gate voltage (yellow) at 2V/division and 2µs/division for the shortest pulse length. The gate voltage has gone past the end of the Miller plateau and started charging past that point. The Miller plateau is also visible on the discharge as the nFET turns off.

ATtiny output (green) and drain voltage (yellow) at 2V/division and 2µs/division for the  second shortest pulse length.  The BitScope BS-10 oscilloscope clips the voltage to 5.5V—it actually goes to 9V.  The longer pulses allow the nFET to turn on fully.

ATtiny output (green) and drain voltage (yellow) at 2V/division and 2µs/division for the second shortest pulse length. The BitScope BS-10 oscilloscope clips the voltage to 5.5V—it actually goes to 9V.
The longer pulses allow the nFET to turn on fully.

The conversion from the linear 10-bit analog-to-digital reading (0–1023) to pulse lengths is done by the following method:

expon = ADC>>7
frac = 0x80 + (ADC & 0x7f)
pulse_len = ADC < 0x20? 0:  ADC < 0x40? 1: 1+ (frac>> (7-expon))

The stepwise nature of the brightness at low levels is apparent in a plot of the conversion function:

The steps in brightness are quite visible at the low end, but after the first 10 steps, the differences are small enough not to be easily noticed.

The steps in brightness are quite visible at the low end, but after the first 10 steps, the differences are small enough not to be easily noticed.

Overall, I’m pleased with the rework of the dimmer code. I’ll probably have to solder up another of the dimmer boards this summer, since I’ll want one for the light fixture that I haven’t started building yet and one for the Halloween stroboscope.

Next Page »