Pfad: Home => AVR overview => Applications => Led line
LED line

Led line intensity control with an ATtiny13



Features and Functions

The device regulates the intensity of two LED lines in 256 steps with two regulated resistors. For that the processor ATtiny13 measures the position of the resistors and controls the intensity by the pulse width on two output ports. The output ports drive two transistors that can switch up to 1.5 A LED current. The programming of the processor is possible via a 6-pin ISP interface.

The scheme

Schematic The device is supplied from a 12V wall power supply. A regulator 78L05 and two Tantal condensators of 0,1 µF provide the operating voltage for the ATtiny13.

The microprocessor measure the analogue voltage on PB3 and PB4 of the linear potentiometers. On the outputs PB0 (OCR0A) and PB1 (OCR0B) the pulsewidth modulated signal is available.

The output signals drive two transistors BD137 that switch the LEDs of the two lines on and off and determine their intensity via the pulsewidth.

The ISP6 plug can program the device in the system.



To top of page

Mounting the device

The device is mounted on a breadbord and build into a small plastic box.

Internal mounting

The two LED lines are connected through plugs, so one can attach those line in a flexible manner.

LED Line plugs

The two regulators control the intensity of the two lines.

Regulator

In our case two LED lines with one meter length each are driven.

Lamps

The lines can separated into parts at sequences with every three LEDs, because every three LEDs are assembled in line with a current limiting resistor.

To top of page

Software

The commented software is written in assembler. The two PWM channels use the 8-bit-timer/counter in fast PWM mode and without any software overhead. With the prescaler of 64 and 8 bits resolution the PWM frequency is

f(PWM) = 1.200.000 / 64 / 256 = 73,2 Hz

The two ADC channels work with a prescaler of 128, are measured 64 times and the results are added. This requires (per channel)

t(ADC) = 128 * 13 * 64 / 1.200.000 = 88,7 ms

The MSB of the summed 16-bit result is written to the OCR value of the respective channel and is taken over on the end of the respective PWM sequence.

AD conversion is programmed in interrupt mode, no code outside the ADC interrupt service routine is necessary.

The source code in Assembler-/Text-Format is available here, in HTML-Format here.

The ATtiny13 runs with the default fuse settings, with the internal 9.6MHz-RC-generator and the prescaler of 8. Fuse programming is not necessary.

To top of page

©2012 by http://www.avr-asm-tutorial.net