I recently had to verify a colleague's design and honestly failed miserably. Things that I consider basic in terms of electronics I didn't see and couldn't quickly do.
To that end let us start from a simple area and attempt to cover as many aspects as possible...at least that way I will hopefully improve in my skills and prevent others from making similar mistakes.
I'm going to show a simple circuit that I was presented with...I'll be honest I struggle to visualise circuit operation from a schematic...it's probably why I struggle with the task of assessing designs.
Simple LED Circuit |
Lets try to analyze the circuit and explain how it works. The circuit's function is to indicate which position the switch SW1 is in to the operator. We have two different light emitting diodes (LEDS) connected via (SW1) a double pole single throw switch to a 5 Vdc supply with two 4k7 Ohm resistors and a 10 k Ohm Resistor.
When the switch (SW1) is in the position shown above LED D2 is supposed to be illuminated and a signal (at 5 Vdc) is also passed back to a microcontroller GPIO configured as an input (not shown here) via the node labelled SW1. When the switch is in the alternative position the LED D1 is supposed to be illuminated and at the same time a signal or rather lack of signal (0 Vdc) is passed back to the microcontroller GPIO configured as an input.
This method of connecting LEDS is known as reverse parallel - I'd actually not heard the term before...I had seen it before but not had it described that way...
So why is this circuit not particularly well designed? There are a couple of reasons...which I'll be honest I did not pick up on during my assessment. I made assumptions that the designer had performed calculations and checks to ensure the values selected were correct.
The first reason is with respect to current. In order to cause an LED to go into illumination normally at least 16 mA of current is required. How much current is flowing in the circuit with respect to D2?
Well the forward volt drop of the LED D2 is not stated so we don't actually know...lets fix that by supplying the datasheet:
C503B-BCS-CV0Z0461 Blue Light emitting diode datasheet
D2 is a 5 mm through hole LED with a wavelength of 470 nm. It has a typical forward voltage (VF) of 3.2 Vdc when the forward current is at 20 mA.
We can now perform a simple calculation:
(Supply voltage - Diode forward voltage) / Resistor (R2) = Current flowing in LED D2 part of the circuit
(5 Volts - 3.2 Volts) / 4700 Ohms = 0.00038297872 A or 383 µA (micro-Amperes)
In order to get an LED to illuminate at normal brightness there should be milli-Amperes - I normally aim for 16 mA. So in the circuit shown above with the switch in this position the LED D2 will not be illuminating brightly...I suspect it won't even be visible to the human eye.
The same issue is present with LED D1, here is the datasheet:
L-53SYD Yellow Light Emitting Diode Datasheet
D1 is a 5 mm through hole LED with a wavelength of 590 nm. It has a typical forward voltage (VF) of 2 Vdc when the forward current is at 20 mA.
(Supply voltage - Diode forward voltage) / Resistor (R1) = Current flowing in LED D1 part of the circuit
(5 Volts - 2 Volts) / 4700 Ohms = 0.00063829787 A or 638 µA (micro-Amperes)
If again the aim was to illuminate the LED D1 (16 mA) then when the switch (SW1) is in the alternative positon the LED D1 will not be illuminated brightly at all...
So how do we resolve this issue? We could try changing the resistor values (R1 and R2) for a lower value...
The standard formula for calculating the current limiting resistor for an LED is:
Current Limiting Resistor (Rlimit) (Ohms) = [Supply Voltage (VS) - Diode Forward Voltage (VF)] / Diode Forward Current (IF)
Supply Voltage (VS) = 5 Vdc
Diode Forward Voltage (VF) = 3.2 Vdc (Blue LED)
Diode Forward Current (IF) = 16 * 10^-3 Amps or 16 mA
Therefore:
Current Limiting Resistor (Rlimit) (Ohms) in this case R2 = (5 Volts - 3.2 Volts) / 16 *10^-3 Amps
Current Limiting Resistor (Rlimit) (Ohms) = 112.5 Ohms for the Blue LED current limiting resistor.
For the current limiting resistor for D1 we have:
Current Limiting Resistor (Rlimit) (Ohms) in this case R1 = (5 Volts - 2 Volts) / 16 *10^-3 Amps
Current Limiting Resistor (Rlimit) (Ohms) = 187.5 Ohms for the Yellow LED current limiting resistor.
As 112.5 Ohms and 187.5 Ohms are not standard values for resistors one would probably use a 100 Ohm resistor and a 180 Ohm resistor.
The other calculation that should be made when designing circuits with resistors present is to ensure that the resistor power rating is suitable for the amount of power that will be present in the circuit. Resistor life-time is reduced and unnecessary heat is generated when too much power is conducted through resistors.
The formula for calculating the power in a component is an application of Ohms Law:
Power (Watts) = Voltage (V) * Current (I) or
Power (Watts) = (Current * Current) * Resistance or
Power (Watts) = (Voltage * Voltage) / Resistance
We can apply any version of Ohms law to calculate the information required. I have decided to use
Power (Watts) = (Current * Current) * Resistance
Power (Watts) in R1 = (16*10^-3 * 16*10^-3) * 180 Ohms
Power (Watts) in R1 = 0.04608 Watts or 46.08 mW
Power (Watts) in R2 = (16*10^-3 * 16*10^-3) * 100 Ohms
Power (Watts) in R2 = 0.0256 Watts or 25.6 mW
So to ensure that the power rating for the resistors is correct we should use 100 mW or quarter watt (250 mW) rated resistors.
There are still issues with the circuit as shown above however; The circuit is kind of wasteful...When the switch is in the position shown above there will always be current flowing in resistor R1 even though LED D1 is not illuminated. With the switch in the opposite position the resistor R2 will still have current flowing through it even though LED D2 will not be illuminated. Why have current flowing in a resistor for no purpose...It would be better to redraw the circuit in a different way but still achieve the same circuit function.
It would also (in my opinion) be better to redraw the circuit and do away with the reverse parallel LED connections...mostly because I find it hard to visualise the circuit...
Here is the circuit which was redesigned by my colleague having had some feedback (not from me):
Improved Circuit Design |
The circuit's function is still to indicate which position the switch SW1 is in to the operator. We have a 5 Vdc supply connected to a blue LED (D2) which in turn is connected to a 120 Ohm resistor (R1) and via (SW1) a double pole single throw switch, to ground completing the circuit. With the switch SW1 in the alternative position we have the 5 Vdc supply connected to a yellow LED (D1) which is in turn connected to resistor (R2) and via switch SW1, to ground completing the circuit.
A signal is also passed back to a microcontroller GPIO configured as an input (not shown here) via the node labelled Controller SW1. When the switch is in the first position the LED D2 is illuminated and at the same time a signal (5 Vdc) through resistors R3 (10 k Ohms) and R58 (1 k Ohms) is passed back to the microcontroller GPIO input.
When the switch (SW1) is in the second position LED D1 is illuminated and the signal passed back to the microcontroller is 0 Vdc as the R3 (10 k Ohms) and R58 (1 k Ohms) are now connected to ground as well as the microcontroller GPIO input as the input impedance of a GPIO on a microcontroller is normally 100 k Ohms. It is a standard method of reading the state of a switch position with a microcontroller.
The current limit on each of the LEDS can be calculated for completeness:
Current limit in LED D1 (Yellow LED) = (Supply voltage - Diode forward voltage) / Resistor (R2)
(5 Volts - 2 Volts) / 560 Ohms = 0.00535714286 A or 5.357 mA (milli-Amperes)
Current limit in LED D2 (Blue LED) = (Supply voltage - Diode forward voltage) / Resistor (R1)
(5 Volts - 3.2 Volts) / 120 Ohms = 0.015 A or 15 mA (milli-Amperes)
It seems a little odd to me that the value of R2 was chosen to be 560 Ohms...that seems a little high and will cause the yellow LED to be less visible when in operation...
The power rating for the resistors can also be recalculated:
Power (Watts) in R2 = (5.357*10^-3 * 5.357*10^-3) * 560 Ohms
Power (Watts) in R2 = 0.01607057144 Watts or 16 mW (milli-Watts)
Power (Watts) in R1 = (15*10^-3 * 15*10^-3) * 120 Ohms
Power (Watts) in R1 = 0.027 Watts or 27 mW (milli-Watts)
Therefore a 100 mW rated or 250 mW rated resistor would be ok to use in either position...
As the circuit has been redesigned there are no conditions where unnecessary current is flowing in any of the resistors and we still have the circuit function needed...When the circuit is constructed it should work perfectly.
When designing LED circuits from now on I will always try and do the following:
1. Obtain the datasheets for any and all components to be used. For LEDS pay particular attention the electrical characteristics: Forward Voltage (VF), Forward Current (IF), maximum voltage (VMAX) and maximum power.
2. Calculate current limiting resistor needed for the appropriate brightness by reading the datasheet and obtaining a figure for the current at the appropriate brightness...it may be shown in a graph. Use the formula:
Current Limiting Resistor (Rlimit) (Ohms) = [Supply Voltage (VS) - Diode Forward Voltage (VF)] / Diode Forward Current (IF)
3. Calculate the power flowing through the current limiting resistor and select a suitably rated component.
4. Choose a suitable resistor tolerance...in this case a 5% resistor will probably be fine.
4. Get a friend or colleague to check your circuits <slight smile>.
5. It often helps to simulate circuits but only when the correct information is provided. It is possibly better to perform the calculations on paper as it will enforce research into the requirements.
6. Make sure the circuit meets the requirements...If the requirements aren't known then set them before attempting to perform the design...
In writing and researching this blog post I looked at the following website for inspiration:
https://www.ngineering.com/led_circuits.htm
Apologies for the long post - hope this was helpful - Langster!
A signal is also passed back to a microcontroller GPIO configured as an input (not shown here) via the node labelled Controller SW1. When the switch is in the first position the LED D2 is illuminated and at the same time a signal (5 Vdc) through resistors R3 (10 k Ohms) and R58 (1 k Ohms) is passed back to the microcontroller GPIO input.
When the switch (SW1) is in the second position LED D1 is illuminated and the signal passed back to the microcontroller is 0 Vdc as the R3 (10 k Ohms) and R58 (1 k Ohms) are now connected to ground as well as the microcontroller GPIO input as the input impedance of a GPIO on a microcontroller is normally 100 k Ohms. It is a standard method of reading the state of a switch position with a microcontroller.
The current limit on each of the LEDS can be calculated for completeness:
Current limit in LED D1 (Yellow LED) = (Supply voltage - Diode forward voltage) / Resistor (R2)
(5 Volts - 2 Volts) / 560 Ohms = 0.00535714286 A or 5.357 mA (milli-Amperes)
Current limit in LED D2 (Blue LED) = (Supply voltage - Diode forward voltage) / Resistor (R1)
(5 Volts - 3.2 Volts) / 120 Ohms = 0.015 A or 15 mA (milli-Amperes)
It seems a little odd to me that the value of R2 was chosen to be 560 Ohms...that seems a little high and will cause the yellow LED to be less visible when in operation...
The power rating for the resistors can also be recalculated:
Power (Watts) in R2 = (5.357*10^-3 * 5.357*10^-3) * 560 Ohms
Power (Watts) in R2 = 0.01607057144 Watts or 16 mW (milli-Watts)
Power (Watts) in R1 = (15*10^-3 * 15*10^-3) * 120 Ohms
Power (Watts) in R1 = 0.027 Watts or 27 mW (milli-Watts)
Therefore a 100 mW rated or 250 mW rated resistor would be ok to use in either position...
As the circuit has been redesigned there are no conditions where unnecessary current is flowing in any of the resistors and we still have the circuit function needed...When the circuit is constructed it should work perfectly.
When designing LED circuits from now on I will always try and do the following:
1. Obtain the datasheets for any and all components to be used. For LEDS pay particular attention the electrical characteristics: Forward Voltage (VF), Forward Current (IF), maximum voltage (VMAX) and maximum power.
2. Calculate current limiting resistor needed for the appropriate brightness by reading the datasheet and obtaining a figure for the current at the appropriate brightness...it may be shown in a graph. Use the formula:
Current Limiting Resistor (Rlimit) (Ohms) = [Supply Voltage (VS) - Diode Forward Voltage (VF)] / Diode Forward Current (IF)
3. Calculate the power flowing through the current limiting resistor and select a suitably rated component.
4. Choose a suitable resistor tolerance...in this case a 5% resistor will probably be fine.
4. Get a friend or colleague to check your circuits <slight smile>.
5. It often helps to simulate circuits but only when the correct information is provided. It is possibly better to perform the calculations on paper as it will enforce research into the requirements.
6. Make sure the circuit meets the requirements...If the requirements aren't known then set them before attempting to perform the design...
In writing and researching this blog post I looked at the following website for inspiration:
https://www.ngineering.com/led_circuits.htm
Apologies for the long post - hope this was helpful - Langster!
No comments:
Post a Comment