CH340G – cheap USB to serial alternative

In many microcontroller projects you might want to add an USB interface which is based on USB to serial converter. There are many chips available that does this job well. Most popular is FT232R or similar which is quite expensive and in some projects it can be too pricy. If you look around, you will find that there are tons of alternatives that cost cents. Ian suggests to take a look at CH340G chip which costs as little as 40 cents. Of course it comes from China market. He purchases several of these and built eagle part so everyone could easily include in project. Since datasheet of this chip is scarce, he’s done the hard work by finding pin-outs and drawing typical schematics for 5V and 3.3V circuits. Continue reading

Building microphone preamp for microcontroller analog input

Microphone is another analog signal sensor which converts sound wave energy into electrical signal. Some microphones does this directly (dynamic microphones), some need additional electrical source like electret. Electret microphone is simply a capacitor which one moving diaphragm which by moving changes capacitance. It can be captured with simple RC circuit. But the signal is very low and barely detectable with microcontroller ADC. This is why normally there are microphone preamp used that gains microphone signal, filters it and gives a DC offset so it would fir perfectly to full rail of ADC input. David actually have made two iterations of microphone preamp circuits. Previous was NPN transistor based which performed pretty good, but this time he wanted to bet even better signal and so he used operational amplifier. He selected TLC272 opamp which can work from single rail and down to 3V which makes it ideal choice for 5V and 3.3V microcontroller circuits. He found that this circuit performs pretty good even on low sound and produces lower noise than NPN version. Bellow you can see how he tested… Continue reading

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

How to build self resetting load switch in embedded circuits

In many microcontroller projects we need to control loads such as relays, bulbs or motors. From microcontroller side we simply send signal that turns device on or off. Microcontroller normally don’t care whats going on further – is load switched on or is it failing. Of course we can build feedback and read voltage from sense resistor and then switch load off in case it draws too much of current. But sometimes relying on microcontroller to work reliable when it can hung due to overload conditions is not accepted. We need to use passive methods of protection. Few additional discrete components can make a big difference. Anthony suggests transistor based overload protection circuit which in normal conditions doesn’t doesn’t do anything. But once current exceed the limit, it shuts off switching MOSFET transistor immediately and thus probably saving the rest of circuit from frying. One simple solution is to use NPN transistor which base is connected to load current sense resistor. It value is selected so that voltage drop on load threshold current would open transistor and thus tie main… Continue reading

Using three pins to drive three LEDs and read three buttons

Sometimes in more complex projects it is a waste to dedicate a line for every LED or button. If you thinking of selecting bigger microcontroller because you need additional pin to drive LED, think of smart way out. Francois AUGER & Philippe Fretaud have shared their technique of interfacing three LEDs and three buttons with three I/O pins. They used special Charlieplexing method of connecting all together and then wrote code piece to drive LEDs and read buttons. Three additional diodes allow reading buttons without affecting other components. Using three additional diodes is way more efficient than expanding number of pins. See video bellow of live action. Continue reading

Aren’t those programming headers too big?

Microcontroller boards are getting smaller and especially in smaller ones those programming headers become annoying. Think of 6-pin AVR ISP header – even on Arduino board it can be in your way. If you need to program MCU, you cannot get rid of it. So many of hobbyists probably start making custom solutions in order to save space. Danny suggests to take a look at so called tag-connect solution, where connection can be made with spring loaded pogo-pins that are normally used for testing PCBs during manufacturing. It seems that they can serve programming and debugging purposes on small boards pretty well. You can make easily make ISP to tag-connect adapter cable pretty easily and next time design PCB with much smaller ISP footprint. Using tag-connect you are not only saving on board space, but also you need less drill holes and don’t need pin header anymore. Continue reading