Running lights. Running lights diagram LED running lights diagram

Among dozens of different LED flashers, a worthy place is occupied by a circuit of running lights on LEDs, assembled on an ATtiny2313 microcontroller. With its help, you can create various lighting effects: from a standard alternating glow to a colorful smooth increase and decrease of fire. Let's look at one of the options for how to make a running fire on LEDs controlled by the ATtiny2313 microcontroller with your own hands, using a specific example.

Heart of running lights

It is a well-known fact that Atmel AVR microcontrollers have high performance characteristics. Their versatility and ease of programming allow you to implement the most extraordinary electronic devices. But it’s better to start getting acquainted with microcontroller technology by assembling simple circuits in which the input/output ports have the same purpose.

One such scheme is running lights with program selection on the ATtiny2313. This microcontroller has everything you need to implement such projects. At the same time, it is not overloaded with additional functions for which you would have to overpay. ATtiny2313 is available in PDIP and SOIC packages and has the following technical characteristics:

  • 32 8-bit general purpose working registers;
  • 120 operations performed in 1 clock cycle;
  • 2 kB of in-system flash memory that can withstand 10 thousand write/erase cycles;
  • 128 bytes of in-system EEPROM that can withstand 100 thousand write/erase cycles;
  • 128 bytes of built-in RAM;
  • 8-bit and 16-bit counter/timer;
  • 4 PWM channels;
  • built-in generator;
  • universal serial interface and other useful functions.

Energy parameters depend on the modification:

  • ATtiny2313 – 2.7-5.5V and up to 300 µA in active mode at a frequency of 1 MHz;
  • ATtiny2313A (4313) – 1.8-5.5V and up to 190 µA in active mode at a frequency of 1 MHz.

In standby mode, power consumption is reduced by two orders of magnitude and does not exceed 1 µA. In addition, this family of microcontrollers has a number of special properties. A complete list of ATtiny2313 capabilities can be found on the manufacturer’s official website www.atmel.com.

Scheme and principle of its operation

In the center of the circuit diagram there is an ATtiny2313 microcontroller, with LEDs connected to its 13 pins. In particular, to control the glow, port B (PB0-PB7), 3 pins of port D (PD4-PD6), as well as PA0 and PA1, which remained free due to the internal generator used, are fully used. The first pin PA2 (Reset) does not actively participate in the circuit and is connected to the MK power circuit through resistor R1. The plus of the 5V power supply is supplied to the 20th pin (VCC), and the minus is supplied to the 10th pin (GND). To eliminate interference and malfunctions in the operation of the MK, a polar capacitor C1 is installed on the power supply.
Taking into account the small load capacity of each pin, LEDs rated for a rated current of no more than 20 mA should be connected. These can be either super-bright LEDs in a DIP package with a transparent lens, or smd3528. There are a total of 13 of them in this pattern of running lights. Resistors R6-R18 act as current limiters.

The numbering of the LEDs in the diagram is indicated in accordance with the firmware.

Through the digital inputs PD0-PD3, as well as using the SB1-SB3 buttons and the SA1 switch, the operation of the circuit is controlled. All of them are connected through resistors R2, R3, R6, R7. At the software level, there are 11 different variations of LED blinking, as well as sequential selection of all effects. The program selection is set by the SB3 button. Within each program, you can change the speed of its execution (LED blinking). To do this, switch SA1 is moved to the closed position (program speed) and the speed increase (SB1) and speed decrease (SB2) buttons are used to achieve the desired effect. If SA1 is open, then buttons SB1 and SB2 will adjust the brightness of the LEDs (from weak flickering to glowing at rated power).

Printed circuit board and assembly parts

Especially for beginner radio amateurs, we offer two options for assembling running lights: on a breadboard and on a printed circuit board. In both cases, it is recommended to use a chip in a PDIP package installed in a DIP-20 socket. All other parts are also in DIP packages. In the first case, a 50x50 mm breadboard with a pitch of 2.5 mm will be sufficient. In this case, the LEDs can be placed both on the board and on a separate line, connecting them to the breadboard with flexible wires.

If LED running lights are intended to be actively used in the future (for example, in a car, bicycle), then it is better to assemble a miniature printed circuit board. To do this, you will need a one-sided textolite measuring 55*55 mm, as well as radio elements.

Currently, there are a lot of schemes with running lights on the Internet. In our article we will look at the simplest circuit, assembled on two popular microcircuits: the 555 timer and the CD4017 counter.

We will assemble according to this diagram (click on it to enlarge):

The scheme is not very complicated as it seems at first glance. So, to assemble it, we need:

1) three resistors with a nominal value: 22 KiloOhm, 500 KiloOhm and 330 Ohm

2) NE555 chip

3) CD4017 chip

4) 1 microfarad capacitor

5) 10 Soviet or Chinese LEDs at 3 Volts

Pinout 555


Currently, most microcircuits are produced in the so-called DIP package. DIP from English – Dual In-line Package, which literally means “double-row assembly”. The pins of the microcircuits in the DIP package are located in opposite directions from each other. The pin spacing is generally 2.54mm, but there are also exceptions. Depending on how many pins the microcircuit has, the housing for this microcircuit is called. For example, the 555 chip has 8 pins, hence its package is called DIP-8.

I marked the so-called “keys” in red circles. These are special marks with which you can find out the beginning of the marking of the microcircuit pins


The first pin is located right next to the key. Counting goes counterclockwise


This means that on the NE555N chip the pins are numbered as follows:


The same applies to the CD4017 chip, which is manufactured in a DIP-16 package.


The pins are numbered from the lower left corner.

Assembling the device

We collect our running lights. On the breadboard they look something like this:


And here is the circuit in action:

The whole circuit works in this way: a rectangular pulse generator is assembled on a 555 timer. The pulse repetition rate depends on resistor R2 and capacitor C1. Next, these rectangular pulses are counted by the CD4017 counter chip and, depending on the number of rectangular pulses, outputs signals to its outputs. When the counter in the chip overflows, everything starts all over again. The LEDs blink in a circle as long as there is voltage on the circuit.

Keep in mind that there are a lot of analogues of the 555 and CD4017 microcircuits. There are even Soviet analogues. For the 555 timer it is KR1006VI1, and for the counter chip K561IE8.

Today we will improve our project a little, at the same time we will repeat the bit shifts, and not only repeat them, but also see their meaning in action. We will apply these shifts so that our LEDs located in the matrix blink one after another in turn, due to which our circuit will take on an even more vibrant appearance.

For this we need more than one LED. I have an LED strip or matrix for this purpose. I placed it in a solderless breadboard, connected the cathodes of all the LEDs together and connected them to a common wire, and connected each anode through a current-limiting resistor to the corresponding legs of port D. This is what it all looks like (click on the picture to enlarge the image)

Therefore, as usual, according to the good old tradition, we are launching Atmel Studio, create a project in it, selecting the same microcontroller Atmega8a, let's call the project Test03. In the same way, we will select simulator as the debugger, and also, to save our precious time, we will copy all the code from the main.c file of the last lesson.

Let's start writing code. First we are in the function main() let's create an integer short unsigned variable

intmain(void)

unsignedchari;

We also leave the port as an output, and immediately turn on the zero leg at 1 on this port

DDRD= 0xFF;

PORTD= 0b0000000 1 ;

And in an infinite loop we will create a different type of loop - type for. This cycle is already final and it works as follows

This cycle is a little more complicated and the condition in brackets here already consists of three parts, but I think we’ll figure it out. We will not deal with this later. Let's use this type of loop in our code:

while(1)

for (i=0;i<=7;i++)

{

Delay_ms(500);

}

In this cycle we will only have a delay for now; we will remove the rest of the code. That is, the body of our loop will be executed until the variable i we will not reach a value greater than or equal to 7 . That is, it will turn out that our body will be performed exactly 8 times, then we will exit this cycle and, thanks to the endless cycle, we will re-enter it and our eight-fold process will be repeated from the beginning.

Now comes the shift. Let's insert it before the delay

PORTD=(1<<i);

Delay_ms(500);

As we can see, we apply this shift to the register responsible for the port states D, and in it we will shift the unit to the left by the value of our variable i, and since this variable increases by 1 with each cycle (or is incremented), then, accordingly, our unit will gradually move to the left every half second, as well as the port legs, for which each bit of our register is responsible. And thus we get the effect of running fire.

Let's put our project together. And, just like in the last lesson, we’ll copy the proteus file from the last lesson and rename it to Test03. Let's open it and replace the firmware file in the controller properties.

We will also add 7 more LEDs and 7 resistors, as shown in the diagram. You can use the copy operation. How this is done is shown in the video tutorial.

Let's run the project in Proteus and see that our LEDs blink alternately, creating the impression of a running fire effect

Now let's flash the real controller and see the result in practice. This is, of course, much more interesting than in Proteus. You can see how it all looks in the video version of the lesson, the link to which is below and is available by clicking on the picture.

Post Views: 10,673

The first amateur radio version of the LED running lights circuit is built on the already proven ATtiny2313 microcontroller. The firmware contains twelve possible combinations of various lighting effects, such as smoothly changing lights, shimmering shadow, growing fire, etc. Below we consider designs without a microcontroller, but on a somewhat outdated element base.


This design is capable of controlling thirteen LEDs, which are connected through current-limiting resistors directly to the ports of the ATtiny2313 microcontroller.

Toggle switch SA3 can be used to switch between possible operating options. Using toggle switches SA1 and SA2, you can adjust the speed of movement of the lights or the blinking frequency of each LED separately. All this depends on the position of the SA4 toggle switch. In the upper position, it regulates the speed of the running lights, and in the lower position, the blinking frequency.

When installing LEDs in a line, you must follow the order shown in the figure from HL1 to HL11. The ATtiny2313 microcontroller is clocked from the existing internal oscillator with a frequency of 8 MHz.

In the proposed device, the sequence of lighting the garlands to create the effect is carried out using three electromagnetic relays by using different voltage values ​​supplied to the circuit of their windings


When supply voltage is supplied from the network, it is supplied to the primary winding of the network transformer T1, to the secondary winding of which a rectifier is connected, assembled according to a circuit with doubling the voltage on diodes VD1, VD2 and capacitors C2, SZ. The effective voltage of the secondary winding of the transformer is 13.5 B. Therefore, the rectified voltage as a result of doubling turns out to be about 32 V. In the initial state, transistor VT1, connected in a circuit with a common collector, is locked, since capacitor C1 is discharged. In this case, all relays are de-energized and the HL1 garland is on.

The charging of capacitor C1 begins. As the capacitor charges, the voltage across it and at the emitter of the transistor increases. When it reaches a value at which the current in the short-circuit relay winding exceeds the operation current, contacts K3.1 will switch, lamps HL1 will go out, and lamps HL2 will light up. A further increase in the voltage at the emitter of the transistor triggers relay K2, which, using contacts K2.1, turns off the lamps HL2 and turns on HL3. Finally, a continued increase in voltage causes relay K1 to operate, whose contacts K1.1 discharge capacitor C1.

As a result, the transistor is locked, all relays are de-energized, lamps HL1 are lit, and contacts K1.1 are opened. Then the capacitor begins to charge again and the process repeats. The speed of charging the capacitor and moving the running flame can be adjusted by variable resistor R2. The vertical scanning output transformer TVK-110LM from black-and-white TVs is used as a network transformer. Of the two secondary windings, the one whose resistance is 1 ohm is used. The author proposed using electromagnetic relays of the RES9 type.

However, not a single relay of this type is designed for switching 220 V alternating voltage (only 115). Therefore, we advise you to install the RES10 relay, passport RS4.524.302 (RS4.529.031-03 according to GOST 16121-86). Their response current is 22 mA, and the winding resistance is 630 Ohms. Thus, device K3 will operate at an emitter voltage of VT113.9 V. Thanks to the inclusion of resistors R4 and R5, the remaining two relays operate at a higher voltage at the emitter of the transistor. Relay K2 operates at a voltage of 20.5 V, and relay K1 - at a voltage of 23.3 V. The maximum permissible voltage on the winding of a relay of this type is 36 V. Its contacts allow switching alternating voltage with a frequency of 50 V and a voltage of up to 250 V at an active current loads up to 0.3 A. Hence, each garland can be assembled from 9 incandescent light bulbs of type MH26-0D2 connected in series, designed for a rated voltage of 26 V and a current of 0.12 A.

The design is a multivibrator consisting of three stages. The transistors are unlocked and the LEDs included in their circuits are ignited sequentially one after the other.

When assembling the device, it is advisable to select transistors with the highest possible current gain and capacitors with minimal leakage.

Scheme of running lights on K561LA7 and K561IE8 microcircuits

The circuit is quite simple and consists of two microcircuits and a dozen LEDs that light up one by one.

Potentiometer R2 is used to adjust the speed of the running lights.