# Pulse Width Modulated LED Torch

22,181

36

15

## Introduction: Pulse Width Modulated LED Torch

Pulse width modulation (PWM) can be used to vary the power, speed or brightness of many devices. With LEDs, PWM can be used to dim them, or make them brighter. I will use them make a small hand torch.

An LED can be dimmed by quickly turning it on and off, several times a second. By varying the mark space ratio, the brightness is varied.
A simple implementation of a PWM system would be a clock feeding an LED and protective resistor to the ground.

The clock should ideally oscillate at a frequency of 50Hz to ensure that you will not see the oscillation. To test this, you can either use a signal generator to provide a square wave, as below, or create a circuit to do it for you.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Relaxation Oscillator

This circuit will produce a square wave with a duty cycle of 50%. Two 10K resistors connected to the +input of the op-amp provide a reference voltage, and R1 and C1, connected to the -input, create a time constant which controls the frequency, f = 1/{2ln(3)RC}.

The capacitor C1 charges and discharges through the resistor R1, and the time taken for this cycle to occur is the period of the waveform.

## Step 2: Relaxation Oscillator

By defining the frequency in step 1, R1 can be replaced with a potentiometer, RP, with a value of 2R1, and two diodes. This alteration will allow the duty cycle to vary, whilst maintaining a constant frequency.

For the purposes of general PWM of LEDs, there is no need for absolute precision with the frequency. If there is a requirement for precision, then the potentiometer chosen should be as close to, but no more than 2R1, and a compensation resistor equal to R1-RP/2.

An alternate solution is to use two resistors in series with the two diodes, to give a fixed, and pre-defined duty cycle.

## Step 3: Relaxation Oscillator Output

The clock signal can either be connected directly to a single LED, but this will not allow the LED to be controlled by an external logic source. It can instead be easier to feed this output to the base of a transistor, and then use the transistor to switch the LED on and off.

The potential divider on the input of the transistor is to reduce the output of the relaxation oscillator, since in it's off state, it will still output 2v. This needs to be reduced to below 0.7v in order to not to switch on the transistor, otherwise the LED will remain on constantly and cook.

## Step 4: Increasing the Brightness

The other useful application of PWM with an LED is that the LED can have a larger than normal current passed through it making it brighter. Normally this current would destroy the LED, but since the LED is only on for a fraction of the time, the average power put through the LED is within tolerance.

The limit of this current is defined on the manufacturer's data sheet for the LED, identified as the forward pulse current. There are also often details regarding the minimum pulse width and duty cycles. Using a white LED as an example, the following specifications are given as:

Forward Current = 30mA
Pulse Forward Current = 150mA
Pulse Width =< 10ms
Duty Cycle =< 1:10

Using the pulse width and duty cycle information, the relaxation oscillator can be recalculated with T=2ln(2)RC

Assuming a 10nF capacitor is used, and wanting TON = 10ms, and TOFF = 1ms, the following calculations can be made, and then the circuit diagram drawn.

## Step 5: Power Increase

The other requirement to increase the brightness is to increase the current flowing through the LED. This is relatively straight forward. Assuming a 5v logic supply to the LED, and from the data sheet the standard voltage of the LED is 3.6v. The protection resistor can be calculated by subtracting the LED voltage from the supply voltage, and then dividing this by the current.

R = (VS - VLED) / (iMAX)
R = (5 - 3.6) / 0.15
R = 1.4 / 0.15
R = 9.3 = 10R

It is however likely that the LED supply source may not be able to provide a sufficient current of 100mA, even if it is for a very short time. It may be necessary to power the LED through the transistor, possibly controlled by another transistor in series also capable of carrying the current.

In this circuit, the supply voltage of the op-amp should be used, as the 5v logic supply will be too small. There is a 0.7v drop over both transistors, and 3.6v over the LED, totalling 5v, and leaving nothing for a protection resistor. However, for the torch, the control can be placed over the power supply for the circuit.

VR = 9 - (3.6 + 0.7)
VR = 4.7v

R = 4.7 / 0.15
R = 31 = 33R

## Step 6: Final Circuit

Below is the final circuit diagram. When implemented, a switch will be placed onto the power supply, and another five LED-resistor pairs will be placed in parallel with the existing pair.

## Step 7: Test Circuit

This is a single LED version of the circuit. Not especially tidy, but it is a prototype, and follows the circuit diagram from step 7.

You can also see from the power supply that only 24mA is being drawn, compared with the 30mA if the LED was connected normally.

From the third image containing two LEDs, it appears that both LEDs are of the same brightness. However very quickly, the direct driven LED becomes warm quickly giving good reason to PWM.

## Step 8: Finished Torch

Transferring the circuit to veroboard is challenging, especially condensing the relaxation oscillator so it will fit into the case. The main thing to check is that no wires are crossed, or are loose enough to cross. Adding another 5 LEDs, a switch in series with a battery connector and then placing these into a case is more straight-forward.

Connecting the power supply to the battery connector to test the circuit, the average current reading was approximately 85mA. This is significantly smaller than 180mA (6*30mA) that a direct drive system would require.

I have not gone into great detail with transferring the circuit from the breadboard, onto veroboard as I have aimed to concentrate on the theory behind this project, rather than specifically it's production. However as a general guide, you should test the circuit and get it to work on the breadboard, then transfer the components to the veroboard, starting with the smaller components. If you are competent and quick at soldering, you may be able to safely solder a chip directly to board, otherwise you should use a chip holder.

## 15 Discussions

Thank you very much for replying me, as you can see from my detail, I am a newbie to electronics and just join recently, I have a question about powering up 12  LED, would you mind to have a look of the following link and give me some technological advise please?