⬆️ ⬇️

ATtiny13a: Controller of the STOP signal and the parking lights of the car

Hello!



He drove home from work, thinking about the beautiful, meditating on life, to unobtrusive music. I thought how good it would be to have dinner, to pour hot tea, watching how this wet and sticky snow was spinning outside the window, which the road services in my city either refuse to clean or cannot.



And so on you! Cork ... And go still and go. The path is not close, taking into account traffic jams - this is at least 3 hours from home.

Well, respectively: I encourage myself that, they say, at home dinner, tea, snow outside the window. And it seems that the mood of returning begins, as suddenly from the right-hand side of the Toyota Prius (well, you know this is all battery-powered), turns on the left turn and climbs right in front of my car ... “Okay, buddy! You go, you still have to stand together for 3 hours. ”Built in, drove two meters and got up. As it should be on the road in traffic, locked the brake.



I saw different cars, I saw different implementations of STOP signals, but what happened at that moment was with me only once. When I bought ultra-bright LEDs for the first time, I came home and decided to “test” right away. The pain pierced my eyes right up to the head, when I connected this thing to the battery. This for a long time pushed me away from the desire to engage in such devices.

')

So this time, in a traffic jam, I again experienced this feeling. I do not know whether his STOP signals were tuned to such a brightness, or whether this wet glass had the effect of a lens. In general, as I did not try and did not try, but I had to go after him all 3 hours - either to the right or to the left, or even right behind this “hell”.



Everything that happened to me would not have affected me so much, if right in those days I had not thought about the realization of my idea of ​​replacing regular lamps in STOP with LED assemblies. I seriously thought about their brightness and how much damage they could have to drivers behind (by the way, about the implementation - it was completed by 50%, but due to new circumstances it had to be postponed).



At that moment I was confronted with the subject of microcontrollers, one of which (ATtiny13a) and it was decided to apply to eliminate the described effect, and at the same time simplify the implementation of my task, at the same time allowing the use of economy and aesthetic execution.



The essence of the development is as follows:



1. Eliminate dependence on separate light sources in the STOP signal;

2. Limit the brightness to the two upper limits - separately for position lights and for the STOP signal;

3. Implement muting the brightness of the STOP signal, if the brake pedal is pressed for a long time, and at the same time allow us to distinguish the resulting brightness level from the side lights;

4. The implementation should be performed using the standard scheme of the car, without significant changes, and the brightness levels should correspond to the standard levels of the corresponding lights;

5. And the last thing: to realize our plans in the form of modules that can be used independently in each lamp, replaced, and also be able to be removed at the right time for flashing or rewriting.



The result is the following algorithm:



1. We form hardware PWM with output to (PB0) (the frequency must exceed 100 Hz to eliminate flicker);

2. Initialize the ADC input (PB4) in continuous mode;

3. Read the value of the ADC (to which two signals come - one from the side lights, the second from the brake pedal with different corresponding levels);

4. We form flags: 1 - the brake is pressed, 2 - dimensions are included;

5. If the brake pedal flag is set, set the PWM duty cycle equal to the upper limit of the STOP signal, and start the touch duration counter;

6. If the brake pedal has been released, then stop the counter and restore the upper brightness threshold for the STOP signal, if the dimensions are included, then smoothly change the brightness level to the upper brightness limit of the dimensions;

7. If the brake pedal is still pressed, then every second we take away from the upper limit of the STOP signal - 1, until we reach the lower threshold of brightness for the STOP signal. When the lower brightness threshold for the STOP signal is reached, stop the counter;

8. If the dimensions flag is set and the brake pedal is not pressed, then smoothly changing the PWM duty cycle to the upper brightness limit for the dimensions;

9. Change the value of the register of hardware PWM and go to step 3.



The firmware was created in Atmel Studio, and its performance was tested in Proteus 8.1.



The PWM frequency is 300Hz, the size of the firmware code is 250 bytes, RAM and EEPROM are not used.



The program text was very short, but this is not the final version (after the prototype tests, adjustments will be made that will affect the changes in this article):







Test project in Proteus:







It is decided to take the power of the controller directly from the power coming to the lamps, they are the signals for the ADC.

The scheme does not indicate stabilizers, they will be used in the implementation.



Honestly, I'm still a beginner, and I don't even have controllers yet, so I create everything virtually.

How the circuit and firmware will behave in real conditions - I can not say, I have not checked it yet.

Therefore, I really expect constructive suggestions and comments to the scheme from you.

I would be very grateful. Maybe I did not take into account any features.

Nevertheless, I want to finish the job and finish the job successfully.



PS: Regarding savings:

Machine - Mark II, incandescent STOP-signal - 4 * 25 W, dimensions 4 * 5 W - a total of 120 W (dimensions and STOP are included together in the dark).

Instead of them, I plan to install diode assemblies (read as “powerful LEDs”) of a red glow of 10 watts each, which means that with a maximum brightness of 40 watts.

~ 800 lumens each build, with the use of my development I get dimensions - ~ 1000 lumens and a STOP signal> 2000 in total. So with an average consumption of 10-30 W is 4-8 times more economical.

Let me remind you that in cars that do not have DRLs, according to the rules of the traffic police, it is necessary to drive with the headlights on, respectively, the dimensions work day and night. And this, with long-term calculations is reflected in the pocket.



Under the link you can find the firmware, the project for Proteus 8.1 and the source code.



Used materials and regulatory documents:

GOST 8769-75:

Devices external light cars, buses, trolley buses, tractors, trailers and semi-trailers. Number, location, color, viewing angles

GOST R 41.48-2004:

Uniform regulations concerning the certification of vehicles with regard to the installation of lighting and light-signaling devices



Use in commercial projects, resale of the source code and use for profit is prohibited.



Source texts are distributed free of charge, in case of use on other sites or in other sources, the indication of the author and notification of placement is mandatory.

Source: https://habr.com/ru/post/247799/



All Articles