Show by Label

Tuesday, August 11, 2015

_HowTo: Controlling a temperature driven Fan with PWM

Because I need a fan for my power supply project, I started a little project to do that.
I don't like noise or hum, so I wanted to use a fan that would be off when not needed.

Typically, by using Pulse Width Modulation (PWM), rather than a voltage, you can precisely control the speed of the fan, and ramp it up when needed.

I was able to find some clever methods to implement this, and pieced together this design:

The building blocks are relatively simple. I use a DC-DC convertor, not a linear one, to bring the 24V DC to 5V, because a linear LM7805 would get too warm burning off the excess voltage.
I use a comparator with hysteresis to determine the starting point of the fan, based on the temperature reading (in ohms) of a thermistor that is mounted on the heat sink. I don't have the datasheet for the thermistor, but found that it gets from 10K at room temperature to about 5K when the heat sink is getting really hot.

I need 5V for the fan, because I have one that is only 10mm thick, and that is what I have room for.

The clever trick of this circuit lies in the fact that the Control Voltage (CV) input from a 555 timer is used to control the PWM.

The 555 is producing pulses, and the pulse width, and also a bit of the frequency is varied by applying a voltage to the CV input. The output of the 555 goes to a FET that drives the fan.

The whole thing works very well, although the low pulse frequency can be heard from the fan, so I needed to use C4 and C5 to remove that chirping sound.

There are two disadvantages of this design.
One is that you cannot regulate the full 100% of the pulse width. The minimum is OK at about 30%, it let's the fan spin very slowly, but the maximum is only about 70%.
The other disadvantage is that you cannot increase the frequency of the pulses above the hearing frequency of 20KHz, because then the effect of the thermistor on the PWM range is greatly reduced. 

In my application, that is not good enough, I need to be able to get to the maximum fan speed in order to keep things cool.

There are special fan/motor controllers that allow you to do that, so I have a couple of TC648VPA chips on order. Stay tuned.

The chips arrived and I made two different circuits. One for a 12V DC Fan I also ordered, and one for the 5V DC fan.  I used an Excel spreadsheet that is available on the MicroChip website to calculate the resistors (R1 and R2) to get the best starting and maximum fan speeds.




The TC648 works really well, and is a nice addition to my toolbox. Next step is to put the circuits on vero board and install them in the power supplies.

After playing and experimenting, I decided to make a few changes to the circuit. First, I implemented the VAS  pin. The explanation says to set the Auto-shutdown threshold with this pin, but it also sets the turn-on threshold. The nice thing is that the fan will be driven to full speed for a short period, making sure it turns on right away. This was a problem I noticed with the earlier circuit.

Second, I deleted the resistor that was in parallel to the NTC. I felt that with a 10K NTC, it didn't do much. I also experimented with C7, which sets the frequency to see if I could remove the audible noises at lower speeds. That only worked with a 10nF cap, but then the PWM spread is limited and therefore also the speed control. So I resorted to using the 1uF value.

BTW, after a lengthy search, I found the information about the NTC I was using, because I wanted to know the temperature curves. Unfortunately, the shop I got them from didn't mention the type or manufacturer. I have the TDK B57045K0103K000.

I also found a much more elaborate data sheet for the device here: http://ww1.microchip.com/downloads/en/DeviceDoc/21755c.pdf

And here is the latest version of the schematic:


If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw


_HowTo: RPi Start-stop button with shutdown and power-off features

I recently finished a design, based on an idea from sparkyPi, a raspberry Pi forum member, where he was using a rather special purpose chip to add start-stop functionality. He needed a special Device Tree feature to create a signal that the Pi sends out when the shutdown sequence has finished, and even got help from the designers to complete that. His attempts led me to find yet another method to do the same, but without some side effects that the other method introduces.

In the meantime, I ordered some of the chips (LTC2951-1 : Start-Stop Push Button Controller) he used, and I was able to built a working circuit that does not even need Device Tree features. Here is the link to the post: https://www.raspberrypi.org/forums/viewtopic.php?f=41&t=117863

In this post you'll also find the links to the other ones.

Enjoy!

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw


Tuesday, August 4, 2015

Building a Dynamic DC Power Load (updated)



I finally got around to building my own DC Power Load.

My noise problems with the DC Power Supply, as described in another post, forced me to build this tool so I could measure the results.

There are many designs on the web if you care to take a look, but very few had a dynamic load feature, which is what I wanted.

I finally settled on one particular design and modified that through some trial and errors. Here is my starting point that I got from the work of Peter Oakes:

Here is my version:


Let’s go over the basic building blocks.

In order to have a stable setting of the load, independent of supply voltage changes, I decided to use a voltage reference chip. The voltage output of the chip was selected based on the maximum current I wanted to sink which is 5 Amps. By using a shunt of 0.1Ohm, 5 Amps translates into 500mV.
So I selected an LM 358 with 1.25V output. By using a resistor divider together with the current setting pot meter, I created a 500mV level, so the pot meter could supply 0..500mV, or 0..5Amps.
By just changing just one resistor, I can later change the load current to a maximum level of 12.5A.

The voltage over the shunt is fed to the negative input of U1, which will try to keep this input equal to the positive input that gets the desired reference voltage, by varying the output. The output of the Op Amp is connected to a MOSFET that can handle plenty of Volts, Amps and Watts.

To set the current sink, or the load, I used the output of the current setting pot meter and used a toggle switch to feed that to the Voltmeter of my display. The voltage from the pot meter in milli Volts corresponds directly to the current in Amps. (I first used a 10x op amp to convert the current to volts 1:1, but that’s overkill of you can multiply by 10 yourself)

As I learned with my power supply project, these Volt/Amp displays inject a lot of noise into the supply, so I used a series resistor, Zener and two capacitors to stop that from entering the rest of the circuit.

If S3 is in the Direct setting, the reference voltage of the pot meter is fed into the op amp. In the Dynamic setting I use a separate input coming from a function generator or equivalent, in order to pulse the load at certain frequencies. This allows you to measure the rise and fall times or other responses of the supply under test.

To eliminate possible oscillations and to add stability, C7, C3, C2 were added. I also created a possibility to add a capacitor parallel to R4, to better drive the MOSFET, but did not need it at the moment. A Sobel filter circuit was added at the output terminals for the same reason.
Unfortunately, the Volt/Amp display unit I have does not allow floating measurements, which is why I had to put the shunt into the ground loop. This will add a rather small (25mOhm shunt) current error.

I have another V/A display on order  that can be modified to make the current measurement floating, which also allows high-side current shunts, which are better anyway. Again Peter Oakes is the one that figured this out. https://www.youtube.com/watch?v=A6VQhDioz_Q
In any case that current shunt of the modified meter can be placed between the Drain of Q1 and the 0.1 Ohm shunt.

The Gate of the MOSFET is “clamped” to ground by a small resistor, just to make sure a problem does not create an unexpected short to the output. This resistor should be soldered right on the pins of the MOSFET and the shunt, to take care of bad or broken wiring.
By using the dynamic load, I was able to measure a rise and fall time of less than 50uSec, more than adequate for my applications.

One word of caution. 
The MOSFET is capable of 55V, 110A and 200W. With 30V and a couple of Amps, it does not even get warm on my rather small heat sink. The on resistance is only 8 milli Ohm, although we will never get that low because we don’t saturate the device. However, dealing with higher voltages and or higher currents increases the number of Watts rapidly. Remember that the two multiply!


Update : Aug 29, 2015

Over the last couple of weeks, several things have changed after the initial build. I received my new Volt/Amp meter, and modified that per the instructions by Peter Oakes. It now has a floating differential current sense circuit so I have put it in between the MOSFET's and the current sense shunt. I'm also very impressed with the accuracy of both meters. No more adjusting, and the decimal point and number of digits change like a "real" DMM, what it really is. On top of that, it has exactly the same accuracy as my DMM. Highly recommended!


I also installed a temperature controlled fan, it uses a nifty fan controller chip to do all that. Look at a separate post for details.

To get a better handle on the temperature at higher loads, I decided to use two MOSFET's in parallel. I was a little careless testing all this, thinking that this plus the fan would solve my heat problems. I was eager to start my tests of the two PSU's, which is why I built this tool in the first place. Well, I lost a MOSFET due to runaway thermal issues. Bummer!

Despite my search for information on how to put two power MOSFET's in parallel, all I could find (at the time), was the use of seperate gate resistors, to balance the two MOSFET's. Well, that didn't work very well. Due to the differences in the VGS for both devices, one took all the heat.

After swapping out the broken one, I was a little bit more careful, and noticed right away that there was a large difference in the thermal balance between the two. One was getting slightly warm, but the other too hot to touch. Apparently, the only real solution to the RDS(on) and therefore thermal balance issue is to build two circuits with separate op amps and sense resistors. I did not want to do that right away, and tried to see if I could get close enough. First I increased the value of the gate resistors, and also matched them to within 1 Ohm. That did not do anything to get a better balance. I then started to increase the value of the one one that got hot, but that did not produce the result I was after. In the end I used a 10K trimpot to set the VGS to a reduced level, and used my temperature probe to balance the two. I got to within a few degrees C after running the unit with a 1A load, such that the temperature was about 50 degrees C. It's not ideal, because I don't think the VGS delta has a linear relationship, but for now I'm happy.

Here is revision 3:

This design will most likely be further tuned while I'm going through the paces of testing and specifying my two power supplies, so stay tuned.

Update : August 30, 2015
Well, it didn't take too long for another refinement.

I kept mulling about the thermal balance challenge, and was not too happy about the comment I made earlier in the post above. While surfing for ideas for the parallel use of the power MOSFET's, I came across a comment that I took for face value, assuming the guy knew what he was talking about. I simply repeated his comment in the previous post that the "real" solution is to make two separate circuits. So to duplicate the op amp, FET and current sense resistor.

I kept thinking about that statement, and decided that it is misleading or even incorrect. Yes, you will get two circuits that together will share the load, but it does absolutely nothing to get a better load balance, or a better thermal balance. So, back to the drawing board.

Initially, I wanted to use two thermistors (or NTC's), thermally connected to each FET, and then use a comparator to decide if one was getting hotter than the other. The challenge was that I could not find an easy way to mount them on top of the MOSTFET's. Sure, I could have mounted them on the heatsink, but I would have lost some temperature sensitivity, with the heatsink acting as a dampener.

I then switched to using the junction temperature of transistors, but again could not find a good thermal connection to the FET's. I then went through my power transistor stack for ideas and found two excellent specimens. I happen to have quite some (very old, as in late 1970's) D40C5 darlington power transistors, that have a very flimsy heatsink. This turned out to be a perfect way to mount them with the same screw that also mounts the MOSFET, provided you also isolate the transistor tab, because it is the collector. I happen to have all the bits and bobs required, so I could continue.


BTW, the fact that I use darlington transistors, is only because I had them. You can use any TO22X kind of package, as long is you can thermally connect them to the MOSFET's.

In any case, whipping-up a small circuit to measure the delta temperature difference and drive a FET to drop the VGS on the gate of the FET that get's too hot was quite simple. By selecting a feedback resistor to create a small threshold, I managed to keep the temperatures within about 1 degree C. So whenever the temperature of Q2 id one degree C higher than that of Q1, the gate of Q2 is clamped and as soon as the temperatures are equal again, the gate is released again. Perfect!

Here is Revision 4:

Resistor R21 in the drain of the BS170 MOSFET is there to reduce the gate voltage, not to yank it to ground. With the resistor combination of R9, R14 and R21, the gate voltage drops from about 300mV,  just reducing the load and therefore temperature of Q2, while not affecting Q1, and therefore the output.

Just in case you are interested to use this idea in other applications, you need to be aware of two constraints. With this particular application, I'm not concerned about the self-heating of T1 and T2. I'm interested in the delta temperature difference, not the absolute difference. Also, the fact that the load will move from both MOSFET's to mostly one for shorter periods is of little concern for me. Both MOSFET's are individually capable of handling the full load.

Enjoy!

After having used the DC load for about a year, I was a little annoyed about the fact that I could not obtain a zero load at the output, despite the trimmer on IC1 and using a small negative voltage for it. Although the potmeter (R6) was getting down to zero Volt, the output of IC1 remained at 3V3, resulting in a 0.0059 Volt over the shunt (R12).

I finally figured out a way to adjust the potmeter range at the lowest position to have an output of zero load. The trick was to apply a very small negative voltage at the lower part of R6, instead of connecting that to ground. I used a tap on the two diodes that created a small negative voltage for IC1, in an earlier attempt to obtain a zero Volt output, and fed that -0.7V to an added 10K trimmer. With R6 in the lowest position, the new trimmer is now adjusted such that the output is showing no load.

Here is the new schematic with that change:

June 13 2017
While going through the design of a new power supply (a new post will be coming), I was not satisfied with the dynamic switching of the load. The pulse that is coming in from the BNC input actually switches the load hard on and off, so the maximum load is used, and there is no way to limit that.

I also didn't really need a fully variable input to the load, a simple pulse would suffice. During the power supply design, I actually put a 555 based timer on a breadboard and fed that to the DC load external input. I also added a few parts to make the output variable. I liked the results, so I put everything on a little prototype board and added it to the internals of the DC load.

Here is the schematic of the Pulse Generator addition:


Those that follow my posts will notice that I no longer use Eagle. A few months ago, I switched to Diptrace. I finally ended up frustrated by the difficulty in Eagle of adding custom parts, so I started to look around. I dismissed all the free ones, including K-Cad. That is just too cumbersome, and at this moment only for experts I think. An electronic pen-pal advised me to try Diptrace, and I have been using that ever since. My new power supply, discussed in another post has been designed that way, and I also made my very first pcb layout with it.

Anyway, I made Diptrace resemble the Eagle schematics a bit, because those still look visually pleasing.

OK, back to the Pulse Generator. I used a 555 based circuit that produces a pulse train with approx. 180mSec on, and approx. 70 mSec off periods. By just changing C3, you can change the frequency. At first, I used the 12V supply to power this circuit, but later changed my mind about that. I didn't want pulses with a 12Vp-p output roaring through my box, when I do sensitive measurements.

I changed the single throw switch that selected between static and dynamic inputs, to a double throw switch. The other side now switches the pulses off, by shorting the charging cap C3 to ground, such that the 555 pulses are off when the static mode is selected. It keeps things more quiet in the box. At first I switched the power to the 555, but turning it on produced an unwanted output glitch causing a high load on the output until the 555 settles.

The DC load will be switched on during the on-pulse, and fully off during the off-pulse. Because of the 5V supply, the output of the 555 timer is about 5V p-p. That signal is used for a trigger out signal. That signal now goes to the same BNC that was previously used as a pulse input. This signal typically goes to a scope to trigger it. This trigger output is an important feature because if you test a power supply, as an example, you want to see the effects of the load regulation while you switch dynamic loads on the power supply output. If the load regulation is any good, it will be very hard to see any effects on the output of the supply, so knowing where to look, based on the trigger signal, really helps a lot.

A second divider (R5 and the potmeter R6) attenuate the signal, so at the wiper of the potmeter, I will have 500mVp-p at maximum, and 0Vp-p at the minimum.  A voltage level of 500mVp-p will turn the DC load fully on, which is the same as the static load adjustment potmeter does. I happened to have a special dual 10K potmeter, with separate controls (outer and inner) for each section. If you use other resistor values, you have to recalculate the dividers. Make sure that the maximum output on the wiper of the output setting (R6) potmeter is slightly above 500mV to be able to drive the load to the maximum.

The wiper of the output setting potmeter goes to the switch that selects the static or dynamic behavior of the DC load.

To create a minimum offset for the DC load in the pulsed mode, used to test Transient Response and Recovery Time Measurements for power supplies, the other half of the dual 10K potmeter is used to add a 0..100mV offset. This should be enough to create a "bias" current of up to 1Amp for the supply, and then drive it higher with the pulse. This allows you to see the "sagging" and negative pulse excursions of the supply output voltage better than letting the supply go to ground, or 0V when you don't add the offset.

If you now turn on the dynamic input, the pulsed output level (with or without out offset) can be set, and the Amp level will be displayed on the Amp panel meter display.

Because I had this special dual potmeter, all I had to drill was a single new hole in the front panel, and that just sits just above the static output level potmeter. The circuit is build on a small prototype board that is mounted on an extended post already mounting the main PCB.

Everything works really well, this simple DC Load is getting better and better, I'm happy.

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw


Tuesday, May 19, 2015

Building a Simple 1KHz Distortion Analysis Tool (upgraded)

For my audio projects, I wanted to have a method of simply measuring distortion without buying (too costly) or building a (too complex) full-blown analyzer.

I started out with a very low distortion 1KHz sine wave generator and a Twin-T filter, and put them in the same enclosure.

This is the resulting instrument.



The low distortion sine wave generator is to feed the DUT, and at the output, use a filter to supress the sine wave again. What is left should be the distortion created by the DUT and some additional noise.

The components

As it turns out, designing a very low distortion since wave generator is not that easy. Luckily I found a unit that is excellent for a reasonable price. It is called the Mickevich (the designer) Ultra Low Distortion  (<0.00001%) 1 KHz Sine Wave Generator.

What was left was to design a precise filter, the required power supply and the box to put it all in to.

In addition, I needed an external sound card interface that is used as a digitizing front-end for the PC-based FFT analyzer.

I described this project on a diyaudio forum where much more information can be found about the oscillator, and the filter I used : http://www.diyaudio.com/forums/equipment-tools/252751-simpel-1-2-diy-1khz-distortion-analysis-tool.html 

When I picked-up my electronics hobby again after I retired (early), this was one of the very first projects. I wanted this tool because at the time, I was designing and building headphone amplifiers to be used in a plane. 

In 2022, I decided to describe the unit here in more detail, so I'm not depending on the diyaudio Forum. I also decided it was toime to design a PCB and use better components for the filter, as they were recommended on the Forum.


The Ultra Low Distortion Oscillator

In order to make good measurments you need to have a very low distortion sine wave oscillator. I found the Victor Mickevics design and purchased one for 1 KHz.


Victor uses a novel FET-based AGC design with a rather simple circuit to get astounding results.

The results for this little board are stunningly good. Here it is measured with non-professional equipment and that shows only 0.0003% THD and 0.0024% THD+N. The actual specifications are even better with second harmonic at -136 dB (0.15 ppm) and third harmonics so low it cannot be measured (< -140 dB).




Unfortunately, it seems Victor is no longer active and selling them.

The Twin-T Notch Filter


The Twin-T notch filter is based on a simplified design from Dick Moore (richiem) here are the details
I tailored his design for just a single 1 KHz operation.

Here are the schematics that I put together for the combined instrument:

The power supply

The sine wave oscillator needs about 35VDC or a little higher, to create a +/- 15V.
The Twin-T also needs +/- 15V, but I didn't want to use the supply already on the oscillator. I did not want to disturb it.


This supply feeds the 1KHz oscillator with about 34VDC and the Twin-T notch filter with a balanced +/- 15V supply.

As I typically do, I use a separate AC transformer outside of the box, to avoid mains hum etc. WHen I was winter birding in Texas, I used a Rainbird 24VAC transformer, alas that was only for 115V.

Back in Europe, I use a 12-0-12VAC transformer for several projects, so I used the 24VAC to feed the power supply.

Because Victor's oscillator needs 35VDC, I could use a full bridge rectifier and an LM317 and keep things cool, rather than using a doubler and deal with 70VDC as input to the LM317. They will get hot, causing temperature related drifts. I also did not want to "steal" the +/- 15V coming from Victor's oscillator to feed the notch filter, so I added it's own supply. To create just enough headroom for the first LM317, I adjusted the output going to the oscillator to 34V, instead of 35V.

The second LM317 is used to supply 30VDC, that is split into +/- 15V.


Twin-T Notch filter


Here is the original filter circuit:


I used two (cheap) 1K 10-T pots for the filter, and shunted them with 1K. This will still leave them linear enough. Even with this shunt, the adjustment is still a little too coarse for my liking. 
I use R11 and R15 (rather than 10T trim pots) to set the filter notch about in the middle of the 10T filter pots.

To get the filter as accurate as possible, I purchased 8 good 10nF caps, and sorted them by value to get the optimum balance of the filter. The measured values are in the schematic. At the time I used a cheap Arduino based capacitance meter, which turned out to be less precise. 


Enclosure:

Because I also wanted a nice enclosure, and not very expensive, I used a plastic one that only set me back $27.  I needed to shield the inside and did that the easy way by using copper foil (look for guitar hum materials) and made two boxes out of some circuit board material. So far this seems to be adequate.

Pictures of the instrument








After I was done and started to test things, I added an additional toggle switch to the instrument with an input attenuator.

Improvements

Based on inputs on the Audio Forum, I learned that I can improve the notch filter some more by using better filter capacitors, the special audio film kind, and by using a better Opamp for IC1 (an AD797 or an LME49990).  I now have the capacitors and the AD797 in stock.

Since then, I also purchased a higher precision capacitance meter, the Juntex LC-200A. A very good meter for the price. I can do a much better job matching the values. I should update the filter with the better tuned filter capacitors, and change the OpAmp.

UPDATE:

So in 2022, I decided to pick-up where I left and upgrade the Twin-T Notch filter. Now that I'm a lot more experienced with PCB design, I created a new schematic and a layout. 

Here is the updated schematic:



Basically the same circuit, just some different resistor values and the Opamp changes.

I used the Eagle to KiCad import system, but what a mess that creates when you want to make changes and add layouts/components etc. I may end up redoing the schematic from scratch to get it clean, but for now, I have a layout. Because I'm starting with better capacitors for the filter, I re-calculated the resistor values accordingly. They now follow the theoretical values. 


The Opamps will go in gold plated DIL-8 sockets so I can easily replace them.





Here is the completed unit after the upgrade.



Note that there is no more room for the PCB-made box.

After powering it on and letting it warm up, I had to tweak some resistor values (R4, R5, R8, R9 and maybe R13) again to get the trimmer and the two potmeters roughly in the middle of the range to have an even spread either way of the sweet spot. The values are in the schematic above. With these new values, the trimmer has a good range, and the two pots are tuned to be in the middle of the range. 
Adjusting them with these changes works great, I'm happy.

The PCB can be ordered from your favourite supplier. 
The Gerbers are on the Github :  https://github.com/paulvee/Twin-T


Enjoy!
paulv

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw

_HowTo: Triple function button to reboot/halt/reset/restart RPi

When I got started with my Raspberry Pi, I quickly ran into situations where I needed to reset, restart or halt the Pi. I designed the following circuit and added some code to let me do that. It is quite simple but effective. Since then, other methods have been presented by others, but maybe this will be helpfull as well.

Here is the post on the raspberrypi.org forum : https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=48455&p=412858#p412858

Enjoy!
Paulv

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw

Monday, May 18, 2015

_HowTo: Failsafe(r) use of GPIO pin for critical applications

In an effort to avoid run-away issues with my HVAC system, located on another continend, I wanted to make sure that a crash of the Raspberry Pi that I used as a controller, did not cause a desaster. Also, I needed to prevent Python crashes from keeping the furnace or the air conditioning system running unchecked.

Here is a link to the post that went through the discovery process and with the help of some smart contributors, eventually led to a failsafe design in hardware and software. This resulting hardware and code has been running for about 18 months to my satisfaction.

The post was published on the raspberrypi.org forum : https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=46889&p=432578#p432578

Enjoy!
Paulv

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw

_HowTo: Simple UPS for RPi

Quite some time ago I designed this simple but effective battery operated emergency supply. It is used to prevent short brown-outs and also allows the Pi to shutdown without corrupting the SD card.

here is the form post from raspberrypi.org : https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=52860&p=500147#p500147

Enjoy!
Paulv

If you like what you see, please support me by buying me a coffee: https://www.buymeacoffee.com/M9ouLVXBdw