I guess this qualifies as something worth showing. I’m building an intelligent fan controller/watchdog for my home server machine (no, it’s not the one this blog is hosted on) and I wanted too see how they behave when using PWM control. The easy solution would be to wire an AVR in the same configuration as in the mentioned device, but I remembered this post on and had (almost) all the parts.

Since part 1 of that blog post is old and doesn’t contain much details I used this as a reference and produced the schematic below based on the parts I thought I have. Sorry for stealing the project and thanks for the general idea. :) I’ve even soldered this partially on perfboard before I realized I had no transistors and output limiting resistors able to handle that much current and dissipate enough power, so it’s that much for this weekend project. ;) I’ll finish this tomorrow when I get the parts. This is what I partially (without totem-pole transistor drivers and with some minor changes) breadboarded, soldered and tested from the parts I had:

TL494 PWM controller

Click for a bigger picture. Strangely looking polarized caps are the effect of KiCAD’s SVG export bug.

The circuit consists of three parts, power supply, TL494 itself and totem-pole MOSFET drivers. I had an old power brick labeled as 12 VAC 600 mA, but it’s RMS and probably a bit higher, it gives steady 16 VDC after rectification with 1 mF filtering capacitor and under about 200 mA load, I have yet to fully test it. Standard LM317T circuit (note wrong pinout in the KiCAD library symbol!) straight from the datasheet powers totem-pole drivers with the RV1 potentiometer adjusting it up to just under 14 V counting the dropout, which is more than enough to test most MOSFETs. Small LM78L05 (L indicates a TO-92, 100 mA version) powers TL494, this way changing the amplitude does not affect frequency and duty cycle. It’s under recommended 7 V for TL494 supply, but it works and I only had this regulator other than another beefy TO220 LM317 in my parts bin.

On the actual IC there’s nothing complicated. The combination of 680 pF cap and 1M RV3 pot gives (at 5 volts I tested it) output frequency from about 2.5 kHz up to unde 100 kHz. Switch controls channel behaviour, they can work in parallel (turning on and off at the same time) or alternating (when one channel is on then the other is off). RV2 pot adjusts duty cycle, you can adjust it from about 2-5% up to 100% (continuosly on). This chip also has error amplifiers and 5 V reference source, because it’s really a switchmode power supply controller, but they’re not used here.

On the output there are two channels with a totem-pole transistor configuration each. The additional NPNs are there so it doesn’t invert the input from TL494.

That’s it for now, I’ll try to build it later and do some test, maybe even put some pictures, but I’d need to get a camera for that. Feel free to comment and to point out bugs, problems and stupidities.

Dark side of the high level languages

By day I’m Java programmer. Recently I started coding some low level stuff in C for a microcontroller project I’m working on. I knew from the beginning it’s going to include a lot of C magic (a kind of project with plain simple hardware and software wizardry), so far I implemented a simple circular linked list. I’ve been through a formal education in computer science, so I just coded this from memory. Then I decided to run splint (never used it before) on my code… I feel sad and lonely now.

Java has garbage collection. C does not. Most of my university basic programming courses used Java or other very high level languages and splint made me realize I have no experience with manual memory management. It’s not a black magic for me, I know the rules and I can handle this, especially having splint as a help. There were also some other minor things, like bit shifting a negative value (consult your local C guru for why it’s not a good idea to use shift operators on negative values), memory management is just an example. Thankfully I run splint now instead of scratching my head over a ready project being perfectly sure the code is fine and not having hardware debugging probe for the AVR micro sitting in my device.

Anyone can share similar experiences? Anyone interested in a small guide to use splint in microcontroller projects?

Hello world!


Yes, this is just another blog. It’s here to share my thoughts, share things worth sharing and preserve everything worth preserving. Topics? Electronics, computers, technology in general, usual random things. Why English? So that the people from all around the world can not care about what I have to say. ;)

That’s all for now. Will be back soon with something worth showing.