C++ support on avr with gcc

Avrgcc compiler supports C++, but it lacks standard library and C++ ABI realization. ABI is a set of service functions, calls to which are inserted by a compiler. As a result people tend to implement missing parts in a fast but improper way. For example there is plenty of recipes how to shoot your foot by defining empty realization for __cxa_pure_virtual(void) {} or install rakes with __cxa_guard_acquire, __cxa_guard_release and __cxa_guard_abort stubs. This article is an attempt to understand what is needed for happiness, where it can be taken or how it can be written.
I know, that some developers think, that C++ is not a good choice for microcontrollers. I ask these people to read at least the last section of the article before writing comments.

Realtime quirks

At least I've managed to catch sneaky bug in light control firmware. When brightness was set to low bulb periodically flushed. I has been hunting it for last two weeks. Actually, there were several bugs, that's because I'm not used to writing hard realtime applications. For example only yesterday I've understood that main loop shouldn't work as fast as it can, it should work as evenly as it can and it's start must be synchronized with alternation of current in power network. And today I've found out that zero cross detector triggers at different moment of time and additional software averaging is needed. If I was better at electronics I would probably made a better one and I wouldn't need complex zero cross prediction code. A week ago I've understood that instead of synchronizing two timers I can stop using built in arduino functions and use one timer.
But I'm quite glad at overall. Microcontroller programming is fun.
update: Some time after I've found timer interrupts and had to rewrite firmware in proper way.

Dimmers: myths and truth

Recently I've started creating my own lighting control system and I had to read through a lot of papers about dimmers. Unfortunately it occurred that information form advertising text from shop sited does not match information from electronics engineers forums and articles written by specialists. As far as amount of adverts is much greater it is not easy to find out the truth.

Yesterdays show

I've calculated statistics of road accidents for yesterday. Because of morning snow number of accidents was much higher, than at previous Fridays. On graph you can see number of accidents in Moscow area after moderators have cleaned them. Morning peak is two times bigger than usual. Today situation is normal again. May be roads have been cleaned, may be drivers became more accurate.

Stress test

It can be said, that road accident module has passed stress test. Car crashes all over the Moscow. I should count them.

Master of bulbs

Sunday's evening an idea to control bulbs via computer visited me. It occurs that it is not an extra hard problem. About two days of reading datasheets and forums and main concepts have became clear. Some more time was spent to build prototype... And hour ago a bulb have obeyed me and started to switch on and off by commands from a keyboard.
Now I need a microcontroller so as to control brightness...

Severe skiers from Rameskoe

Лыжня It is November today but still no snow. Skiers start having withdrawal pains. I think that these pains are hard or skiers are very severe. There are many things you can find on a beach of a lake but I really didn't expect to find ski track.


I need to measure distances on screen quite often. And I use kruler for this. But sometimes I need to measure angles. Unfortunately I couldn't find screen protractor so I've written it myself.

Ramenskoe great canyon

Труба The biggest lake in Ramenskoye is fed by a small stream. But sometimes it becomes quite rapid and erodes it's soft banks. As a result it's riverbed lies in a ravine several meters deep.
Syndicate content