• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

FEATURED Building PWM Controller for 4 wires PWM fan

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.


Quick question bob.

I have an analog pot to digital application I was working on and I ran into an issue. It's for making digital manipulation of a potentiometer curve for audio signals.

Anyway, my question is how you dealt with the instability of the adc readouts from your potentiometer. I changed to sampling the channel 10 times 1024 bit resolution then averaging them out, but that still occasionally led to unnecessary changes to my adc voltage when the potentiometer was not being touched.
 
There are three things I do, in no special order:

1) Sample ten times at 1ms intervals. The delay between samples makes a big difference on AVRs, or at least the Attiny85 and Atmega328/328P I've tested on. Both in stability, and in the value read.

2) I put a 0.1µF cap between the ADC pin and ground, as close to the pin as possible (I aim for less than 2mm between the solder blob for the pin and the solder blob for the cap, and a small package cap to reduce ESR/reactance/etc. in the leg/body of said cap.

3) I don't care that much if it bounces a couple notches. If the PWM value fluctuates a percent randomly it doesn't make much of a difference. That said, there isn't any fluctuation I can see on my scope. Obviously if your application is more sensitive, your mileage will vary.

If you do have a very sensitive application, I would do the above as well as adding 10µF and 100µF capacitors to the signal pin, and making sure that whatever the voltage source is for the ADC unit (on the 328/328P it has it's own VCC pin, the attiny it does not) is clean. A π filter (cap, inductor, cap) on said voltage source will help. The Atmega328 datasheet suggests having one for whatever that is worth.
If you're feeling expansive, making sure the voltage source for the pot is clean will help too.

How much is yours bouncing?
If it's only bouncing one count or so (say from 412 to 413) back and forth, you could play software schmidt trigger games with it. Something like having a "last" value and a "now" value and an "output" value, and only update the "output" value if the "now" value is more than a given amount larger/smaller than the "last" value. The "last" value being the previous "now" value.
I haven't actually done that, it just comes to mind.

What I've also done in the past is used the average of the last three (or two, or ten) read cycles for what I'm doing. Say every 90ms you spend 10ms reading every 1ms. The ten values read every 90ms get combined into an intermediate value, then the last ten intermediate values are combined into a final value.
It results in fairly slow reactions to the pot actually moving, but will definitely reduce bounce.

A last piece of advice, if you have the time (in your code) sampling fairly often for 1/60th of a second (~17ms) will cancel out the house AC EMI for the most part, as you'll be getting values at most points of the induced waveform.
If you're feeling really adventurous you could even use a floating pin to detect the zero crossing point of the AC EMI and start your read cycle there. That might be a touch excessive.

For my basic fan controller I only did #2 (well, and 3), I thought I'd done more, but nope! Still don't see any bounce in the PWM output though.

For the voltage to PWM converter, because it's a buck regulated voltage being read (and therefor noisy), I did 1 and 2 (and three..). The code is very simple, I don't have anything else I need the MCU to do while it's reading the values, so I can use delay() and not worry about the outside world while I read the incoming voltage. The PWM output of course is hardware and unaffected by delay().
Code:
inputValue = 0;
  for (byte x = 0; x < 10; x++){
    inputValue = inputValue + analogRead(A1);
    delay(1);
  }
  inputValue = inputValue / 10;
That's in Arduino of course, but translating it to PIC should be easy enough, though I expect you already knew exactly what I meant by this point in my post :p
 

Well, it's a bit of an issue. I'm blazing in at around 20mhz on that device. I got it fairly stable, but I had make it so that it would only register a change if it was more than 4 ticks of the 1024 resolution. That worked fine because I only had 256 positions on my digital pot. I think adding more filtering like you said would probably help a lot!!

Do you know anyone who might be able to put together a smd adapter board for me in a few months? The parts are incredibly small, too small for me to work on, it's for a zipper noise circuit. Once I have that circuit the testing of the project should be complete.

It's this circuit, with a small change that could be discussed later:

http://electronicdesign.com/site-fi...tronicdesign.com/files/29/12376/figure_02.gif
 
Put together like assemble or put together like design?
Either way I probably can. Haven't really worked with analog stuff like that much, but that's not an issue for soldering things :D
 
Put together like assemble or put together like design?
Either way I probably can. Haven't really worked with analog stuff like that much, but that's not an issue for soldering things :D

It's the soldering I can't do. I can solder through hole components, but due to a nerve injury can't handle smd. I could easily make the pcb in eagle and have it fabbed at oshpark, or just include it in the cost of having you do it. I was unable to source those specific parts in a reasonable size... when they arrived they were like machine assembly sized. Could have cried lol
 
lol, yeah. Some of that stuff is amazingly tiny. Dropping the only one you have of something is soul crushing.

I'm happy to assemble stuff for you if need be. I'd need to charge a little bit to cover time / solder / etc, but not much.

Such a deal would need to be arranged via the classies or AIM or something of course. Can't be breaking OCF rules :D
 
lol, yeah. Some of that stuff is amazingly tiny. Dropping the only one you have of something is soul crushing.

I'm happy to assemble stuff for you if need be. I'd need to charge a little bit to cover time / solder / etc, but not much.

Such a deal would need to be arranged via the classies or AIM or something of course. Can't be breaking OCF rules :D

Roger that. Pop me an email some time [email protected]

I won't need it done for a few months, but when it will need to be done I'll need two or three of them made.

Mind you, two of the parts are sc70-5, we're talking populating one of these adapter boards lol : http://www.ebay.com/itm/5-SMD-to-DI...184?pt=LH_DefaultDomain_0&hash=item43c789cec8

That's the easiest way I know to get it done. Just populate cheap adapter boards from ebay so I can breadboard everything as DIP.
 
Those are tiny!
I've built a couple designs with SOT-23-5 chips recently, it's doable, just touchy. The SOT-23 (also known as SC-74) is 0.95mm between pin centers, looks like the SC-70 is 0.65mm.
Shouldn't be a problem, though I expect I'll have to change tips and lay off the coffee that morning :D

Using adapters to breadboard them for prototyping makes excellent sense to me.
 
Those are tiny!
I've built a couple designs with SOT-23-5 chips recently, it's doable, just touchy. The SOT-23 (also known as SC-74) is 0.95mm between pin centers, looks like the SC-70 is 0.65mm.
Shouldn't be a problem, though I expect I'll have to change tips and lay off the coffee that morning :D

Using adapters to breadboard them for prototyping makes excellent sense to me.

Indeed, they were so small I almost cried in frustration when they arrived. I was at the end of prototyping for a product I was developing with my father and the last thing we needed to make it work was the zipper noise reduction circuit. Without that, the project was utterly worthless. I already use a dedicated soic to dip adapter for the digital pot. Nice little thing it is, you can just open it up and drop a new chip in if you make a mistake. No soldering required.

Have you considered making a reflow setup and using solder paste? Might work better if you're going to be doing larger quantities of smd. I think you could put one together, and make the adjustments to the timer clock, from a cheap toaster oven. IIRC there are instructable son the internet.
 
Yeah I've given it serious consideration, if the fan controllers and such take off I'll probably make one, it'd totally be worth it then.
 
For the prototype buck converter that, if it works, will be the heart of the high power three pin fan controller. So sort of :D
 
Nice PCB's! :thup:
Spiffy! :D
So I must ask, building a 3 pin PWM controller is more complex than a 4 Pin right?

Because you need to control (IIRC) the voltage for 3 pins whereas 4 pin PWM just needs a PWM signal?
 
Nice PCB's! :thup:
Spiffy! :D
So I must ask, building a 3 pin PWM controller is more complex than a 4 Pin right?

Because you need to control (IIRC) the voltage for 3 pins whereas 4 pin PWM just needs a PWM signal?

No, its actually easier.
You only need a potentiometer to change the voltage drop across the +12V into the fan's first pin.

The second pin is ground and the third pin (if it has one) is RPM monitoring.
 
Here's the buck regulator and its output at ~3.4 amps of draw.


View attachment 142885
View attachment 142886
(There were issues involved in the soldering. It did not go smoothly)
R4 is intentionally left blank, that's the resistor that sets the current limit and I haven't figured out how it works yet. It'll need to exist before I sell any of these.
In case you're wondering, if you're looking for 5V, ebay is far cheaper than this.
View attachment 142887

Not strictly a fan controller, but now I know that I can build something that'll run a non-PWM Delta.
I'll voltmod it (hot glue+trimmer FTW) later and try it out later today or tomorrow or something. Got a cold from my older kid and feel like death warmed over, refrozen, warmed over, and finally baked at 350°f for three hours.
 
Last edited:
Back