I have tired Arduino smoothing example but mine analog value are not staying constant even when I don't rotate the potentiometer. I am mapping the values from 0 -> 1024 to 0-> 100. I have tried exponential filter also but the result is same.
Values change 2 to 3 point mostly. Any idea how can I make the readings much more smooth.
-
Welcome to Arduino:SE. You might find this post on our Meta site helpful: How to ask a good question for Arduino Stack Exchange.sempaiscuba– sempaiscuba2022年07月13日 10:17:43 +00:00Commented Jul 13, 2022 at 10:17
-
1please include a diagram of the circuit ... include the pot valuejsotola– jsotola2022年07月13日 14:13:21 +00:00Commented Jul 13, 2022 at 14:13
-
Dividing a normal (270 degree linear) potentiometer into 100 sectors is pushing to the limit. You can add hysteresis so it does not wander between adjacent values. Better is to use a rotary encoder.6v6gt– 6v6gt2022年07月13日 14:39:34 +00:00Commented Jul 13, 2022 at 14:39
-
1Without seeing your filtering code we cannot say why they didn't smooth the values enough. Please share your code. It also depends on the noise your circuit is receiving (and its frequencies)chrisl– chrisl2022年07月13日 15:43:34 +00:00Commented Jul 13, 2022 at 15:43
-
@6v6gt can you guide me or share the link how Can I add the hysteresis?Arslan– Arslan2022年07月14日 08:10:23 +00:00Commented Jul 14, 2022 at 8:10
1 Answer 1
There will always be noise in the output an Analog to Digital Converter (ADC).
An ADC converts a continuous-time and continuous-amplitude analog signal to a discrete-time and discrete-amplitude digital signal. The conversion involves quantization of the input, so it necessarily introduces a small amount of error or noise.
All one can do is mitigate the noise. Consider cleaning up your power supply. Make sure your voltage reference is well filtered. Inspect these power rails with an oscilloscope if one is available. Also consider keeping all wiring as short as possible and avoid using Bread Boards as they tend to introduce noise in sensitive circuits.
When using exponential averaging consider the equation / code can be modified easily to accommodate very noisy signals at the sacrifice of responsiveness. If the application can tolerate the delay, the decay of historical samples can be lowered such that what most consider noise can be filtered out. One can do this by picking very small values for alpha in the following equation found on wikipedia.org: