Monday, July 28, 2014

Automotive LED Indicator Lamp Analysis

I've been helping put together a small solar set-up for my father, and he wanted a light connected to the regulator to give a bit of light at night outside.  I thought the best thing for the job would be a white indicator LED that's used on a car or truck, that way it's already waterproof.  So I ordered a cheap one off ebay and it was fine.  It did the job perfectly and gave off plenty of light, but I was curious as to how it worked.  The specs claim it operates from 12 or 24 volts and I wanted to know how it went about doing this.

LED Light
12/24 Volt 2 LED White Indicator Light
The module contains 2 white LEDs, and from previous experience I know that white LEDs operate somewhere around 3 volts and if they are in series it means you have to supply about 6 volts.  When the module is powered from 12 or 24 volts there are two ways to go about supplying the power, the first is some sort of switch mode power supply, and the second is basic linear regulation.  Due to how cheap the lamp was, it was most likely going to be linear regulation

LED Light
4 terminal LEDs under the diffuser
Even though the PCB was encapsulated to protect the circuit from water, it was done with a clear resin, so although we can't probe the board directly it can at least be mapped out.  At first glance it was obvious that it was going to use linear regulation.  There's only a handful of components on the board, a 39 ohm resistor, capacitor, diode, and T0-92 package that was only partly encapsulated in the resin which isn't ideal, but I think it's for a reason that I'll come to later.  There aren't any components you'd expect to see in a switched power supply.

PCB
Encapsulated PCB
 The schematic was easy enough to draw after visual inspection of the board.

Circuit Schematic
Reverse Engineered Schematic
With the circuit in a more familiar topology it reminded me of an LM317 current limiter circuit, with the LEDs as the load.  As I couldn't read the part number on the T0-92 package I'm going to assume it's an LM317 or an equivalent with similar properties, take a few measurements and see if they match my theory.  Luckily the 39 Ohm designator of the resistor is still visible as this allows the current limit to be calculated.  The diagram below shows a reference of 1.2 volts, but according to the LM317 data sheet it can range from 1.2 to 1.3 volts. Setting R1 to 39 gives a current range of 30.8 to 33.3 mA.  The current flowing into the adjustment pin is in the order of 0.1 mA, so it can be ignored in this analysis.

Circuit Schematic
LM317 Precision Current Limiter Circuit
To test if the circuit used this configuration, I measured the current at several operating points.  It became obvious that the current is limited to around 33 mA starting at about 10.25 Volts.  This agrees with what was calculated earlier assuming that the circuit uses a LM317 or something similar.  At this operating point the LM317 has just started to regulate the current so the voltage across it will be close to its drop-out voltage of 1.7 Volts.

Vin = V(diode) + 2*V(LED) + I*R + V(LM317)
10.25 = 0.7 + 2*V(LED) + 0.033*39 + 1.7
V(LED) = 3.3 Volts

An LED forward voltage of 3.3 Volts agrees with my experience with white LEDs.  As the supply voltage changes in the regulated region, the current remains constant, as does the voltage across the diode, LEDs, and resistor.  This voltage is equal to:

V(diode) + 2*V(LED) + I*R  = 0.7 +2*3.3 + 0.033*39 = 8.6 Volts

Therefore the voltage across the LM317 is the supply voltage less 8.6 Volts.  This means that the waste power dissipated in the regulator as heat in Watts is equal to:

(V(supply) - 8.6) * 0.033

Graph
Current Consumption of an LED Automotive Indicator Light
Now that's all well and good, but it's a little wasteful.  If the supply voltage is 12 volts it's not too bad, the power dissipation is equal to (12-8.6)*0.033 = 112 mW, but if the supply voltage is 24 volts the power dissipation is equal to (24-8.6)*0.033 = 508 mW.  That's getting a little high, particularly when you consider the thermal constraints on the design.

The thermal resistance, junction to ambient of a T0-92 LM317 is 160 degrees Celsius per Watt.  At 24 Volts the device dissipates 508 mW of heat, this means the junction is 0.508 * 160 = 81 degrees Celsius above ambient temperature.  In Australia a device like this might be operating on a hot day mounted to a material that is hotter than the air temperature.   This means that ambient temperature might be around 50 degrees Celsius, and the junction would be at 131 degrees Celsius, which is above the junction operating temperature of some versions of the LM317.  It's borderline, but when you then go ahead and encapsulate everything in resin this could make things worse depending upon the thermal conductivity of the potting compound.  I think that's why they left half of the LM317 package protruding from the resin.

It's fine for the 12 Volt supply I'm using, but I wouldn't expect it to have a long life at 24 Volts.  It would have been nice to see something more efficient used, but for a cheap low power device you can't expect much.

Thursday, July 17, 2014

Hacking Together a Replacement Switch for an LED Lantern

My sister recently asked me to have a look at an LED lantern she uses around the house, mainly to lock up her chickens at night.  It had been dropped and the switch mechanism damaged.  She wanted to see if anything could be done without spending too much.

Lantern
Arlec CL100 Lantern
The switch is a rotary type and is on the top.  It's designed to be removed to replace the light.

Switch
Lantern Switch
Removing the switch is done by unscrewing the top.  This is where the damaged occurred.  The light was dropped on this corner, causing a large piece of the plastic thread to break off.  I considered glueing it back together, but after playing around with for a bit I got the impression that if I didn't get it exactly right it would easily break again.  So I decided to replace the top entirely.

Switch
Switch Damage
So how do I go about doing that?  Let's take a look inside.  The first thing to notice is the four terminals on the white plate.  The inner two are connected to the LEDs, while the outer two are threaded rods that are used to hold the light together and at the same time connect the LED's to the battery in the bottom of the lantern.

Contacts
Battery and LED Light Contacts
Normally the switch on top electrically connects these terminals to operate the light.  The functionality of this is what needs to replicated.

Contacts
Switch Contacts
I had an idea of how to replace the top, but I needed to remove the metal cowling on the top to make more room.  It seems to only be held on by a rubber retention ring.  I don't actually know the purpose of it.  It seems to be decorative.

Cowling and retention ring
The outer thread can be seen, and now that the cowling has been removed there is more room to work.

Outer Thread
Outer Thread
While we're at this point I'll take a minute to show the light bulb.  It's made of 4 PCBs soldered together to make a rectangular tube.  These boards hold the LEDs and current limiting resistors.  If you remove it, pay attention to polarity, like most LEDs it'll only work one way.

LEDs
LED assembly
The light is passed through a diffuser to create a more even spread of light.

Lantern Diffuser
Diffuser
Anyway, back to fixing the light.  I simply added an old switch I had in series with the battery and LED terminals.  I added as much insulation as I could in case a wire came loose, but everything seems fairly firm.

Wiring
New Wiring
That's all well and good, but you can't have the switch and wires hanging loose.  They need to be held rigidly to prevent damage.  After thinking about it for a bit I came up with the perfect replacement.  An end cap for PVC storm water pipe.  It's just the right size and is made of a relatively strong plastic.  The end cap was attached to the lantern by drilling some holes around the perimeter and threading cable ties through them.  I could have riveted it on, but it would have made it hard to fix anything if it breaks in the future, besides that, it could have cracked the plastic.  I could have also used self tapping screws, but after you insert and remove them a couple of times the thread in the plastic would be damaged.

Switch
PVC End Cap Cable Tied In Place
It's not the most elegant of repairs, but it was cheap and quick.  This is one of those occasions that having a 3D printer would have been handy, but it would have taken longer to design and print the part than my quick fix took.  All up, this cost about 3 bucks and about three hours of time while watching TV, so we'll say an hour of actual work.

Saturday, July 5, 2014

Reflection, Transmission, and Attenuation of a Propagating Electromagnetic Pulse

I've been toying around with some old code from uni that models a propagating electromagnetic field, and I thought I'd do some simulations to illustrate how fields propagate and interact with matter.  Usually I'd include the code I used to do the simulations, but as it was for an assignment I don't know if I should.  Do your own homework kids :-).  However if you need more info don't be afraid to ask.

Each simulation is of a gaussian pulse in free space propagating from the left impacting a lossy dielectric shown in green.  The simulations are in 1D making thing easy and are analogous to a signal propagating in a transmission line.

The relative permittivity of the material in all simulations is 7, so let's say it's rubber.  For the first simulation I've set the conductivity to 0 S/m, this means it's lossless.

The are several things to observe in the animation below.  The initial interaction with the material creates a transmitted and reflected wave.  The reflected portion is inverted, this happens when an electromagnetic wave crosses an interface from a low to high dielectric material.  It can also be seen that the speed of the wave decreases as it travels through the material.  Anyone familiar with transmission lines would be familiar with this and know it as velocity factor.   The velocity factor is equal to the inverse square root of the relative dielectric constant.  In this case that's equal to 37.8 percent.  The wave continues on and is transmitted and reflected again.  This time the reflection isn't inverted, this is because the wave is travelling from a high dielectric material to a low one. The transmitted portion of this wave increases at this point, which seems counter intuitive, but you have to remember we're looking at the electric field, not the power flow which is also related to the dielectric constant of the material.
pulse propagation animation
Electromagnetic wave impacting a lossless dielectric

The reflection diagram helps to visualise the propagation of the wave.  White indicates positive waves, while black indicates negative waves.  Time progresses as you go down the graph.  The change in velocity of the wave in the dielectric medium is evident here.
reflection diagram
Electromagnetic wave impacting a lossless dielectric

For this simulation I have set the conductivity to 10 S/m.  It's not a metal but it's conductive enough to demonstrate some things.  To give a point of comparison, sea water is 4.8 S/m.   Basically the wave is completely reflected.  A small portion of it is transmitted but it quickly dissipates.  It also gives me a chance to tell you how I remember how a wave is reflected from a conductor.  Electric field is analogous to voltage, and because a conductor effectively short circuits the wave, the electric field at the interface has to be zero.  If the material in the simulation was a perfect electric conductor this is the behaviour we would see.  For the electric field to be zero the reflected wave has to be the negative of the incident wave.  When these are added you end up with zero electric field at the boundary.  So the electric field of a wave reflected from a conductor is inverted.
pulse propagation animation
Electromagnetic wave impacting a high loss dielectric


reflection diagram
Electromagnetic wave impacting a high loss dielectric

For the final simulation I've set the conductivity to 0.15 S/m.  Lets say it's a conductive rubber of some sort.  The simulation allows us to see the how the wave is attenuated as it travels through the material.  Some does make it through, but it's reduced in magnitude.
pulse propagation animation
Electromagnetic wave impacting a lossy dielectric

reflection diagram
Electromagnetic wave impacting a lossy dielectric