97. Bearing Witness

“Bearing Witness” 2: Constant current

The basic plan was to follow the previous project, using:

  • An Arduino to control the effects
  • 3 Watt LEDs to create the candle effect
  • An ultrasonic distance finder to trigger the flash
  • A 10 Watt LED to create the flash effect

High powered Light Emitting Diodes (LEDs)

High power LEDs are easy to use if you don’t run them at full power. As you get closer to their maximum rating, more care has to be taken to prevent them from exceeding either their maximum temperature or current.

This post is about controlling the current. The problem is that the resistance of these LEDs gets lower as they heat up. This means that they will take more current as they get hotter (as described in a previous post; see also this excellent article in LEDs magazine). If they are already running at their maximum current then this would be a problem.

Here’s a little experiment: I took a 3 Watt LED (the circular one in the photo – the square one is 10 Watts), attached it to a heatsink and gave it a fixed 9.56 Volts. I then measured the  current as it heated up (note that the heatsink was 50 x 20mm – only big enough for short-term testing):

      Temperature (C)    Current (mA)
            22              260
            35              275
            50              290
            60              300

As you can see, a fixed voltage is not ideal because you have to use a voltage that limits the maximum current when the LED is hot, but this reduces the current (and therefore the brightness) when it’s cold. I chose 9.56 Volts because it gave a nice round 260 mA at room temperature, but actually it’s too high, because if you extrapolate the table it would predict 325mA at 85 degrees C, which is beyond the maximum rating of 300mA.

About LEDs
It should be mentioned that the “maximum rating” for LEDs is not the point above which they will stop working, or be destroyed. As the current (and therefore heat) increases, the lifespan of the LED decreases (lifespan is usually the number of hours before the LED degrades so much that it’s only putting out 70% of the light that it put out when it was new). Typically, the maximum current is that which allows the LED to last about 50,000 hours when run at 85 degrees Centigrade. At 100 degrees it can drop to 10,000 hours; at 45 degrees it could be 500,000 hours. Also, the light output decreases as the temperature rises (for the same current) – for example, increasing the temperature from 20 to 80 degrees can lose 20% of the light output, as described here.

Plan A: 12 Volts with Constant current
A good alternative is to use a constant current source that continually adjusts the voltage to keep the LEDs operating at their optimal brightness (their maximum current) regardless of temperature. This has the advantage that the current is properly controlled under all conditions; however, it’s more complex to implement. For the previous project, I built a constant current source using a linear voltage regulator. However, the voltage regulator acts as a resistor which is inefficient, with significant heat being created in the regulator which needs a suitable heatsink to dissipate the heat.

IMG_20160401_224135So I investigated an alternative. These little switching regulators (99p each from China on eBay) are designed to run LEDs. They turn the power on and off very quickly and smooth the output so as to reduce the voltage without wasting the whole difference in heat. The one on the left should provide a constant 900mA, while the other two are 300mA regulators.

Interesting facts about buying from China
I want to use five 3 Watt LEDs for this project, so would need five regulators. To make sure they didn’t get lost in the post (my experience of ordering from China is that about 10% don’t turn up for a very long time), I placed two orders of five each with different suppliers. They arrived the same day, suggesting that mail arrives in batches at irregular times.

IMG_20160222_104454-editedParts from China just arrive in a padded envelope. There’s no document with them to say what they are, and the envelope may say “Electronic Parts” or something generic like “LED Lights”. That’s fine if you order one thing, but I had two orders of five 300mA regulators, plus one order of five 900mA regulators. They all look pretty similar. So when these two orders arrived I knew that I either had ten 300mA regulators, or five 300mA and five 900mA. As it turned out, I was able to figure it out by looking carefully at the eBay pictures and using very small differences. Of course, in this case they are (or should be) constant current regulators so I could have connected them up and measured their output, but it could be a problem with other components.

IMG_20160331_225217So, I have 10 x 300mA constant current regulators and 5 x 900mA ones. I thought maybe I should test them first. It was at this point that I treated myself to a Bench Power Supply. Well, it was that or more chocolate, although you can get a lot of chocolate for £40…

I started with the 300mA regulators (in two batches of 5). They need a fixed input of 12 Volts. I measured the output voltage from the regulator when connected to a 31 Ohm resistor (the 3 Watt LED, running at 9.8 Volts, when cold), as well as a simulated hot LED (reducing the resistance to 25 Ohms by putting a 150 Ohm resistor in parallel). If the regulators are working properly, they should adjust the voltage so that 300 mA flows in both cases.

   Batch        Test    Current (mA)   Voltage (V)
     A          Cold          260         9.5
     A         Sim Hot        280         8.9
     B          Cold          320         9.8
     B         Sim Hot        360         9.7

Well, really, that’s not very good. To start with, batch B is running well over the maximum rating of 300 mA, and depending on the LED’s heatsink could lead to very early failure. So, Batch B is not really suitable for the 3 Watt LEDs long-term. (They could be used with the 10 Watt LEDs, (tests show the same current, but of course only running them at about 3.5 Watts.)

Then there’s the current. It’s not exactly constant. The voltage does reduce as the current increases, but not enough to keep it constant. (By contrast, the constant current supply I built from scratch for the last project only drifts by one or two milliamps.) Nonetheless, batch A is probably ok to use. Unfortunately, I managed to destroy one of them by accidentally shorting something while poking it with a meter probe, (!) so I only have four…

Now for the 900 mA regulator. I swapped the resistors for a 10 Watt LED. First, I tried connecting it straight to the power supply and adjusting the voltage until I got nice round values for the current, then recording the voltage required when the LED was cold and when it was at 80 degrees Centigrade:

      Current (mA)   Voltage (V)-Cold   Voltage (V)-Hot
           100            8.4              8.2
           200            8.9              8.7
           300            9.3              9.1
           400            9.7              9.4
           500           10.0              9.7
           600           10.3             10.1
           700           10.6             10.3
           800           10.8             10.6
           900           11.1             10.9
          1000           11.2             11.1

So, I would expect the 900mA constant current regulator to produce 11.1 Volts to begin with, dropping to 10.9 Volts as the LED heats up. To confuse matters slightly, the regulator is specified to work with input voltages in the range of 9-24 Volts.

Switching Voltage regulators
There are two types of switching voltage regulators, “buck” and “boost”. A buck regulator switches the power on and off rapidly to reduce the voltage. That’s all it does. So it can’t output more volts than it has coming in (in fact, it can’t even output that since a volt or two is lost in the process). A boost regulator, on the other hand, contains a transformer, and is able to produce an output voltage higher or lower than the input voltage. For example, the one described later can output 12 Volts from a 5 Volt input, or output 5 Volts from a 12 Volt input, or any combination.

These 900mA constant current regulators are buck regulators, so they can’t produce 11.1 Volts on an input of anything less than about 13 Volts. To check that they adjusted the output voltage to create a constant 900mA, I adjusted the input voltage from 13.0 Volts to 16.3 Volts, placing a fan by the LED and pausing between measurements so all the readings are “cold” readings. The results are, well, odd:


Remember, we’re expecting a straight horizontal line. In fact, the output voltage increases as the input voltage increases, up to 13.8 Volts, then takes a dive! (The “dive point” drops as the LED heats up and its resistance decreases.) After that, the output slowly drops as the input increases (this was not due to the LED heating up.) It’s the same for all five of them. (If you’re really keen, the actual readings are in an appendix at the end.)

In actual fact, it’s not as bad as it looks. The graph is just the top part of a much taller graph; the peak equates to 850 mA through the LED, and once it settles down, from 14.2-16.3V, the current is within 10mA of 820. The bench power supply only goes up to 16.3 Volts, but I’m going to assume that it remains reasonably stable up to 24 Volts.

Let’s assume we’re not changing the input voltage. The next question is, do they give a constant current under different loads? Let’s call these “Batch C”, and test them using 15V input:

   Batch        Test    Current (mA)   Voltage (V)
     C          Cold          820         10.80
     C           Hot          800         10.55

Not perfect, but usable.

What we have – a summary
1) 4 x 12V 280 mA max regulators suitable for 3 or 10 Watt LEDs
2) 5 x 12V 350 mA max regulators, suitable for 10 Watt LEDs / usable for 3 Watt LEDs
3) 5 x 14.2-24V 820 mA max regulators, suitable for 10 Watt LEDs

Well, they are useable, but I rather expected them to be more accurate. However, there are a couple of potential problems with these regulators.

Potential problem #1

2016-4-3 16-20-21                     2016-4-3 16-23-17

The regulators uses pulse-width modulation (PWM)  to reduce the voltage. It works by rapidly switching the power on and off thousands of times a second so that the average output voltage is the one required. If the output voltage is too low then each time it switches the power on, it leaves it on for slightly longer; if the voltage is too high then it extends the “off” time. There’s a capacitor (left-hand picture, the tiny oblong shape with a light brown centre to the right of the white wire) and inductor (right-hand picture, circular object in the centre, black with copper wound round its middle) to smooth the output to a constant voltage. This system may have inertia, i.e. may not be able to react instantaneously.

Well, I need to turn the LED on and off myself to adjust its brightness (in the previous project it was 200 times a second, but if I use the PWM built in to the Arduino it could be up to 800 times a second). This is also PWM again – the same principle as the voltage regulator. I can’t turn the regulator on and off this fast because there’s a big smoothing capacitor on the input, so I’ll have to switch the LED on and off (i.e. break the circuit to the regulator). The question is, will switching the LED on and off this fast affect the voltage regulator? When the LED is off, and no current is flowing, what does the regulator do? Does it jump to the full input voltage, or drop to zero, and more importantly, how quickly can it recover when the LED turns back on? Will there be a voltage surge each time the LED is switched on? Does it matter?

The best way to find out is to connect up an oscilloscope in order to see exactly what is happening. Of course, I don’t own an oscilloscope. So I dropped in to my local maker group – Hackspace Leicester. They have a whole pile of oscilloscopes – literally! Not only that, but the people there are making all sorts of weird and fascination things, some using arduinos, Raspberry Pis and suchlike.


Here’s what the oscilloscope showed. The X-axis is time, the Y-axis is voltage across the LED. When the LED of off (the bottom lines) there’s 7.2 volts across it (I think there’s a problem with the MOSFET switch, it should be zero!). When the LED is on there’s 9.4 Volts.

As you can see, when the arduino first turns on the LED (the lines at the top) the voltage is slightly too high, but it quickly drops until it’s slightly too low, and then jumps to the correct voltage where it remains until the LED is turned off (the lines at the bottom). So, the voltage starts at 10 Volts, drops to 9 Volts, and then stabilises at 9.4 Volts. At room temperature, 9.4 Volts is fine (equating to about 250 mA), but 10 Volts across the 3 Watt LED equates to currents of well over 320 mA (I estimate 365 mA). They are only transients, but I suspect it would shorten the life of the LED.

So, the 300 mA regulators do work, and could be used, but they would be a compromise.

Potential problem #2
There needs to be a common ground (negative) between the input and output (because the arduino ground connects to both the input side of the voltage regulator (to supply the arduino’s power) and the output side, via the LED (to control the MOSFET). However, that’s not how the regulators are wired.

Buck circuit
Here’s a specimen circuit from a typical data sheet (I don’t know exactly which IC these regulators use). As you can see, the positive from the LED (on the right, next to the arrow) is connected to the inductor (L1), which is fine, but the negative does not connect directly to ground. There is a resistor in the circuit (Rsns) (on the earlier left-hand picture, one of the three small oblong shapes top-right), which is a current sensing resistor, used to tell the IC how much current is flowing so that it can adjust it accordingly. If I connect the MOSFET switch between that resistor and the LED then grounding the gate (i.e. 0 Volts, to turn it off) will actually be zero minus however many volts are across the resistor. Since it’s a very small resistor (physically) it’s going to be very small in value and voltage drop (otherwise it would overheat).

In addition, there are those four larger oblongs at the bottom of the earlier left-hand picture. These are almost certainly a bridge rectifier that allows the input to be connected either way around. (Presumably, the regulator is intended to be run directly from a mains transformer.) So that’s another 0.6 Volts away from zero.

The maximum Gate-Source voltage for these MOSFETs is +-20 Volts, and the gate is (almost) electrically isolated, so probably that would be ok. This would need further testing if I do want to use them (probably just connect one up and see what happens – I think it would be ok).

Plan B: 9 Volts with Boost regulator
If you look at the third table (above) you can see that if you connect the 10 Watt LEDs to 9 Volts then they light up using just over 2 Watts. This is about right, since the 3 Watt ones are too bright to represent a candle anyway and would have to be run at less than maximum (using PWM). So, if I use a 9 Volt power supply and 10 Watt LEDs then I can just connect them directly to the power supply (nice!)

IMG_20160402_215723The problem then is, how to run one LED at the full 10 Watts. To address this, I decided to try out a boost regulator. It’s a constant voltage regulator though, not constant current, so I would have to be careful to limit the current.

There’s an adjustable resistor on the board (the blue oblong, bottom-right) that you turn until you get the voltage you want. That voltage should remain fixed regardless of the supply voltage or the current you take from it, even if the supply drops a lot below the output you want. Let’s see…

I connected it to 9 Volts from the bench power supply and connected a volt meter to the output. Fortunately I didn’t connect the LED, as the board arrived set to 24 volts! I turned the adjustment screw until the output was 11 Volts (which should drive the LED at just under 900mA) and connected the LED. The voltage dropped to 10.2 Volts. (Why does nothing work properly?)

Now, at 10.2 Volts the LED should have been using around 560mA, but the regulator was taking 720 mA. The difference is (mostly) being used to create the missing voltage. Or more specifically, 10.2V x 560mA = 5.7 Watts; 9V x 720mA = 6.5 Watts, which is the 5.7 Watts output to the LED plus 0.8 Watts lost as heat in the regulator.

In fact, this boost regulator is quite good. With a fixed load, its output only varied between 10.1 and 10.2 Volts over a wide range of input voltages.

I haven’t yet decided whether to simply turn the flash on at full power for a short time and then turn it off, or do some fancy fading. If I want to create a fade effect using PWM then it may suffer from Potential Problem 1, since the open circuit voltage is 11 Volts compared to 10.2 Volts under load. If I set the working voltage to 11.1 Volts (to run the 10 Watt LED at its maximum of 1 Amp) then when the arduino switches the LED off the regulator output will probably  jump to somewhere around 11.8 Volts which, as with the test with the 300mA regulators, means there would be a (brief) current surge through the LED that greatly exceeded its maximum current. I could put a capacitor across the LED, but then it wouldn’t switch on/off cleanly, which is essential for accurate dimming. I could put a capacitor across the output of the regulator, but it would just charge to the higher voltage, possibly making the current surge last longer.

One way around using this regulator would be to run the LED at 600-700mA (i.e. 10.3 Volts) so that the higher voltage stays within a safe level. I would need to check it on an oscilloscope to be sure. Of course, it wouldn’t be as bright as if I run it at its maximum of one Amp.

There is another way. Place a fixed resistor in parallel with the LED and use two switches such that either the LED or the resistor is on at any given moment. This would provide a constant load and eliminate switching spikes from the regulator. There is the slight possibility that it wouldn’t resolve the issue completely because the arduino takes a finite time to switch (0.75 microsecond, compared with up to 25 microseconds that the LED may be off at present), but that would be a big improvement. In addition, that 0.75 microsecond could be spent with both LED and resistor switched on, so as to have a voltage dip instead of a spike. This is a potential workaround for all the regulators, although it would use more energy and dissipate more heat.

The good news is that it probably won’t suffer from Potential Problem 2. All the circuits I’ve looked at for boost regulators have a common ground, and there’s no bridge rectifier.

Plan C: 12 Volts with Resistors
Finally, the simplest option. Use a 12 Volt regulated power supply and simply place a resistor in series to limit the current so that the maximum acceptable current flows at the maximum temperature.

So, we want to run the 10 Watt LED at 1 Amp when hot, which needs 11.1 Volts, so we need to lose 0.9 Volts. Therefore, (using R=V/i), we need a 0.9/1 or 0.9 ohm resistor. It will dissipate (W=Vi) 0.9 x 1, so a 1 Watt resistor will be sufficient.

For the 3 Watt LEDs, we want 300mA, which we found would flow at 9.56 Volts when the LED was at 60 degrees. Therefore, we need a (12-9.56)/0.3 = 2.44/0.3 = 8.2 ohms, 9.56 x 0.3 = 2.8 Watts.

Of course, these are theoretical values. The power supply will undoubtably not be exactly 12 Volts (it’s usually more), and the resistor will be the nearest “preferred value”. So maybe:

“Flash”: 1 Ohm, 1 Watt series resistor
“Candles”: 10 Ohms, 3 Watt series resistor

It means not running the LEDs at full power, and wasting some power as heat, but it’s a simple solution.

The Decision
I decided to go for the simpler option of a 12 Volt power supply and some resistors. The main reason is that there’s less to go wrong, and I’m aiming for a professional product that will last.

Having decided on how to power the LEDs, the next post looks at how to keep them cool.


—————————- Appendix  —————————-
900 mA regulator test readings (note that the current is to the nearest 10 mA, “5” is where the meter changed repeatedly from one reading to the next):

      Input Voltage(V)  Output Voltage(V)  Current(mA)
            13.0             10.64             740
            13.1             10.67             770
            13.2             10.71             780
            13.3             10.77             790
            13.4             10.81             800
            13.5             10.83             800
            13.6             10.86             810
            13.7             10.93             850
            13.8             10.87             830
            13.9             10.84             830
            14.0             10.84             830
            14.1             10.82             825
            14.2             10.82             820
            14.3             10.81             820
            14.4             10.81             820
            14.5             10.82             820
            14.6             10.82             820
            14.7             10.82             820
            14.8             10.81             820
            14.9             10.81             820
            15.0             10.80             820
            15.1             10.80             820
            15.2             10.78             820
            15.3             10.78             820
            15.4             10.77             820
            15.5             10.77             820
            15.6             10.76             820
            15.7             10.76             820
            15.8             10.76             820
            15.9             10.75             820
            16.0             10.75             820
            16.1             10.75             820
            16.2             10.74             820
            16.3             10.74             820


3 thoughts on ““Bearing Witness” 2: Constant current

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s