Stabilizing a potentiometer

I've been building a digital clock using a standard 8x32 LED matrix and an RTC chip. I am looking at adding a potentiometer to the design to adjust LED intensity.

Basically the Arduino powers a breadboard power rail and the 3 components, LED, RTC, and potentiometer, are all connected to the rail in parallel.

The value read from the potentiometer varies constantly, which I guess is normal, especially since the current draw of the LED display is varying. (Current draw at the rail is typically around 140mA but often dips down signficantly.)

I can smooth this out in software, but I was wondering if there is a way to smooth it in the circuit itself. Specifically if the addition of a capacitor might do this, but I'm pretty vague on exactly how to use capacitors in a design.

Suggestions?

Sounds like you need a heftier power supply.
Try adding a 10uF cap across the pot's V+and Gnd connections.

Supply and ground of a pot should be wired directly to the Arduino, not shared by other (high-current) devices.
Maybe use smoothing code if the problem then still persists.

Post all the details according to the forum posting guidelines if you want more help.
Code, schematic, images.
Leo..

Pots with varying resistance usually indicate there is tooooo much current going through the tiny resistor.

Paul

peterkwa:
The value read from the potentiometer varies constantly, which I guess is normal

Shouldn't be, if designed correctly. Use screened cable to pot if its any distance from the board.
Star-grounding and star supply wiring is essential, none of the LED current should be going down
a wire that's going to a pot or any analog sensor. If you cannot avoid this use thick wire so the
IR voltages are down at the millivolt level (but be aware than connector resistances are often
the dominant ones, note that soldering and screw-terminals are far less lossy).

How (much) the potentiometer values vary? I cannot imagine they vary so widely that it makes a problem. If you want nice smooth output you may try to low pass filter the pot output (= add an electrolytic cap between the Arduino output sampling the pot and GND).

Hi,
Can you post a circuit diagram please and a picture of your project so we can see your component layout?

How much does the raw data vary from the pot wiper?

Thanks.. Tom... :slight_smile:

I think this covers the schematic. As I said, all are parallel on the 5v/GND rail.

Hi,
Thanks for the circuit diagram.
Try a cap as suggested by @CrossRoads.

How much do the raw data values of the analog input vary?

Have you added code to adjust the display brightness?
If not then try it before doing anything else and see if the brightness does change noticeably.

Thanks.. Tom... :slight_smile:

Why do you think the tiny 10uF cap on the power rails makes a difference? Arduino already have higher value caps onboard. I believe cap on the pot output may work better but of course OP should determine the source of the noise if possible. (It may also be a noisy power rails with stable pot output.)

I havent seen what is the value the pot resistance. If its very high you could be picking up intefference. Also high resistance pot tracks are inherently noisy.

If its very low it will draw excess current.

So about 5 - 10k would be right.

For a 10k pot at mid-range the source resistance will be 5k.

If you connect a 47uF cap between ground and A0 you will have a .25sec time constant which will smooth out any variations.

You may also oversample and average the readings - and always discard the first reading.

peterkwa:
I think this covers the schematic. As I said, all are parallel on the 5v/GND rail.

So not using star-grounding or star-supply wiring - there's the issue. Separate wires all the way from the 5V and
ground pins are needed. This probably requires something like this: http://www.mschoeffler.de/2017/12/26/diy-y-adapter-jumper-wire/,
certainly for the 5V pin.

However a separate external 5V regulator to power the LEDs is perhaps a better approach.

johnerrington:
If you connect a 47uF cap between ground and A0 you will have a .25sec time constant which will smooth out any variations.

Eliminate pot variations, and add supply variations.

Remember that in a ratiometric setup slow supply variations are cancelled out,
until you make input voltage or reference voltage fixed.
I would stick to a 100n cap from pin to ground only, to kill RF noise.

As MarkT points out, where you connect supply/ground for the pot is important.
Leo..

Hi,
What I would like to know is if the OP has tried to actually code in the dimming function to see if the analog variations really can be "seen".
In fact what the "variations" are!!

I'm not sure what library the OP is using, but if it is one I used a few years ago there were I think only 16 levels, I stand corrected, of brightness.
So 1024 mapped down to 16 is going to filter out any "variations".

Tom... :slight_smile:

TomGeorge:
So 1024 mapped down to 16 is going to filter out any "variations".

If there are only 16 levels of brightness it may cause trouble, not solve them: the step between brightness levels may be well visible and a naive map may cause a negligible 1LSB jitter in the analog result to propagate to well noticeable 1 brightness level jitter.

As Smajdalf said, plus:

I would think a linear pot would be a much better fit than a logarithmic type (part# not provided).
Also, I would take into consideration dimming and perception in your code (not provided).
I'm sure this would help considerably.

"Eliminate pot variations, and add supply variations."

Yes right Leo, good point. I had assumed the OP would be meauring with respect to the internal reference which
(despite its limitations) is pretty well regulated from supply variation.

So a cap from the arduino's ground pin to A0 should improve matters - assuming the pot is connected to the same ground pin.

Generally schematics dont give a good indication of supply connection layout.

This sketch gives a very stable output, even if the A/D value from the pot jumps a bit.
Leo…

const byte potPin = A0; // 10k lin (10kB)
const byte ledPin = 3;
int rawValue, prevValue;

void setup() {
}

void loop() {
  rawValue = analogRead(potPin); // read pot
  if (rawValue < (prevValue - 2) || rawValue > (prevValue + 2)) { // deadband
    prevValue = rawValue; // update
    analogWrite(ledPin, prevValue >> 2); // 10-bit to 8-bit (0-255)
  }
}
1 Like