Using switches on microcontrollers – obvious, but…

Switches and buttons are common way of user interaction to embedded system. Normally we are used to connect pull-up (or pull-down) resistor for a switch and then check for its value. There is nothing wrong with such circuit, but speaking of power efficiency, this design can cause some problems. Since resistor is constantly connected to VCC while switch is closed, it constantly draws significant current. What if there are tens of switches – circuit starts drawing lots of current. For battery circuits this is in-acceptable. One simple way would be to select higher pull-up resistor values. In many cases it might work well, but there is always a limit how much you can rise its value. First of all microcontroller input have its threshold current to work reliably. But most importantly due high resistor values and small currents noise signals can start triggering the inputs. Also keep in mind, that switches also require some minimal current ratings. So you should select pull-up resistor with common sense. Other option is to use smarter circuit. If microcontroller have enough pins, you can… Continue reading

Programming Arduino more efficiently

Arduino boards are great – they use standardized layout and are compatible with lots of custom shields. Arduinos also come with pretty good programming IDE and bootloader. All these features make them attractive for most of hobbyists…until your needs grow up. If you program Arduino by using standard Arduino libraries you notice how easy it is to implement most of tasks. This is because simplicity is a trade off efficiency. If you want your programs to run more faster or want to squeeze bigger programs to fit in to MCU you will have a dilemma – use bigger/faster Arduino, write you own programs and libraries in C or C++ or use different library that is more efficient. Guys from have decided to write their own c++ library for Arduino boards. They focused more on efficiency of programs than easy of use. Anyway this is a great kick for developers that still want use c++ libraries and use near Arduino coding style. You can view differences between Arduino core library and MHVlib in these slides. MVHlib already has lots of… Continue reading