This action might not be possible to undo. Are you sure you want to continue?
To Control the Brightness of LED using PWM technique
To control the brightness of an LED you can vary the power which is sent to the LED, for example using a potentiometer (variable resistor), the more power the LED receives the brighter it is, the less power it receives the dimmer it is. Microcontrollers are digital, meaning they only have two ‘power’ states, on and off. Although it is possible to supply a varying power from a microcontroller (using a Digital to Analogue Converter (DAC)) this usually requires an additional chip. PWM provides the ability to ‘simulate’ varying levels of power by oscillating the output from the microcontroller. If, over a short duration of time, we turn the LED on for 50% and off for 50%, the LED will appear half as bright since the total light output over the time duration is only half as much as 100% on. This is illustrated by PWM waveform shown in figure 7.1. By varying (or ‘modulating’) the pulsing width we can effectively control the light output from the LED, hence the term PWM or Pulse Width Modulation. Minimum Speed of LED Oscillation When using PWM it’s important to consider how slowly we can ‘flash’ the LED so that the viewer does not perceive the oscillation. The eye’s inability to see rapid oscillations of light is caused by our ‘persistence of vision’ which means, in very simple terms, we see the light as on even after it has turned off. This technique is how televisions display a seemingly Figure 7.1: PWM Wave with 50% duty-cycle moving picture which is actually made up of a number of different still frames displayed one after the other very rapidly. The minimum speed of an LED oscillating which can be seen by the human eye varies from person to person. Duty-Cycle and PWM Resolution Duty-cycle refers to the percentage of on-time with respect to the total period of the PWM cycle. The greater the PWM, the greater is the average voltage and consequently a brighter LED results. The accuracy with which we can control the duty-cycle is known as the ‘PWM resolution’. The higher our PWM resolution is, the more levels of ‘brightness’ we can display. The faster the microcontroller, the smaller durations it can time. Thus, the higher the resolution, the more timing accuracy and processing overhead is required. Advantages and Disadvantages of PWM Led Control The obvious advantages are no power dissipation in controlling, eliminates the need of DAC chips, very accurate and flexible, inexpensive method. However, PWM can be a source of radio frequency interference (RFI) on the global circuit, because PWM is a periodic signal.
Ali Asad (1936)
Safdar Abbasi (1926)
if R3 not equal to R0 . Outer-Loop Count variable .#100 OUTER: MOV R2.0 MAIN: MOV 60H.#10 .#1 .60H ADD A.CHK_LESS SJMP ON CHK_LESS: JC ON GRT: CLR LED SJMP NEXT ON: SETB LED NEXT: DJNZ R3. if count is greater than duty-cycle .Embedded Systems – IE403 Lab Work Lab #7 Source Code LOC 0000 0090 0000 0000 756001 initilized to 1 => 10% 0003 0003 7964 0005 0005 7A64 0007 0007 7B0A 0009 0009 EB 000A B56002 000D 8006 cycle 000F 4004 cycle 0011 0011 C290 0013 8002 0015 0015 D290 0017 0017 DBF0 0019 DAEC 001B D9E8 cycles 001D 001F 0021 0023 0026 back 0029 E560 2401 F560 B40BDD 756001 to 10% 020003 OBJ LINE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 SOURCE ORG 0000H LED BIT P1. if count is less than duty- .A CJNE A. Repeat forever 44 45 END Code 7.60H. Increase duty-cycle by 10% MOV 60H. Loop corresponding to 1-cycle of PWM Wave LOOP: MOV A.REPEAT MOV 60H.#100 . RAM Location contains duty-cycle . if duty-cycle exceeds 100% reset it 43 LJMP REPEAT . Continue check until 100% count .1: ASM program listing for LED brightness control Group Members: Ali Asad (1936) Safdar Abbasi (1926) .CYCLE DJNZ R1. else Clear LED .#1 . Inner-Loop Count variable CYCLE: MOV R3. if count is equal to duty. End of checks .#1 REPEAT: MOV R1. Set LED .LOOP DJNZ R2.OUTER .R3 CJNE A. Generate R1 x R2 Number of such MOV A.#11.
2: PWM Wave with 10% duty-cycle 50% Duty-Cycle: Figure 7.4: PWM Wave with 80% duty-cycle Group Members: Ali Asad (1936) Safdar Abbasi (1926) .Embedded Systems – IE403 Lab Work Lab #7 Simulations 20% Duty-Cycle: Figure 7.3: PWM Wave with 50% duty-cycle 80% Duty-Cycle: Figure 7.