Hi,
After I heard you at the CircuitPython podcast talking about this library, and it got me thinking about a little project of mine. I'm tinkering with an old Wheel controller from the 90s—just a couple of potentiometers and a bunch of buttons. When I first tackled the project, I scaled the potentiometer values between -127 and 127 based on their min and max readings. But, just like you mentioned in the podcast, the potentiometer noise started messing with my values.
I've been playing around with the library for a few days now. To get a handle on things, I collected data on registered values for 50 reads without touching the potentiometer. Check out the results below:
slice
: Value of the slice
argument.
hyst
: Value of the hyst
argument
avg_slicer
: Average value returned by the range_slicer
method.
avg_scaled
: Average value resulted of directly scaling the potentiometer value
avg_slicer_diff
: Average absolute difference between two consecutive values returned by the range_slicer
method
avg_scaled_diff
: Average absolute difference between two consecutive scaled values
|
slice |
hyst |
avg_slicer |
avg_scaled |
avg_slicer_diff |
avg_scaled_diff |
0 |
1 |
0.15 |
13.6 |
12.88 |
0.76 |
1.24 |
1 |
1 |
0.25 |
13.5 |
12.88 |
0.84 |
1.34 |
2 |
1 |
0.5 |
13.38 |
13.08 |
0.78 |
1.2 |
3 |
1 |
1 |
13.7 |
13.02 |
0.8 |
1.12 |
4 |
1 |
2 |
14.7 |
12.88 |
0.7 |
1.2 |
5 |
1 |
4 |
16.6 |
13 |
0.92 |
1.28 |
6 |
1 |
8 |
20.54 |
13.06 |
0.96 |
1 |
7 |
2 |
0.15 |
14 |
12.86 |
1.1 |
0.98 |
8 |
2 |
0.25 |
13.12 |
12.82 |
0.58 |
1.08 |
9 |
2 |
0.5 |
12.8 |
12.88 |
0.54 |
1.12 |
10 |
2 |
1 |
14.08 |
12.94 |
1.34 |
1.02 |
11 |
2 |
2 |
16 |
12.86 |
1.18 |
1.18 |
12 |
2 |
4 |
20.04 |
12.9 |
1.38 |
1.14 |
13 |
2 |
8 |
27.68 |
12.9 |
1.58 |
1.08 |
14 |
4 |
0.15 |
13 |
12.74 |
0.26 |
1.1 |
15 |
4 |
0.25 |
13 |
12.82 |
0.26 |
1.22 |
16 |
4 |
0.5 |
12.68 |
12.8 |
0.74 |
1.22 |
17 |
4 |
1 |
13 |
12.8 |
0.26 |
1.28 |
18 |
4 |
2 |
17 |
12.96 |
0.34 |
1.12 |
19 |
4 |
4 |
25 |
12.98 |
0.5 |
1 |
20 |
4 |
8 |
41 |
12.78 |
0.82 |
1.32 |
21 |
8 |
0.15 |
11.72 |
12.88 |
3.54 |
1.14 |
22 |
8 |
0.25 |
9 |
13 |
0.18 |
1.32 |
23 |
8 |
0.5 |
9 |
12.84 |
0.18 |
1.08 |
24 |
8 |
1 |
17 |
12.84 |
0.34 |
1.28 |
25 |
8 |
2 |
24.84 |
12.96 |
0.66 |
1.32 |
26 |
8 |
4 |
40.52 |
12.78 |
1.62 |
1.08 |
27 |
8 |
8 |
72.68 |
13.2 |
2.1 |
0.78 |
Looking to the data, I get the following conclusions:
- The value of
slice
changes the output value scale without an impact in the noise.
- The hyst value plays a bigger role in the sliced value. Values below 1 get me results closer to a regular scale.
RangeSlicer
produces less noise.
- There is not direct relation between values of
slice
and hyst
, and the noise produced.
When do you think it's smarter to go with RangeSlicer instead of the usual scaling method or a filter? Would you have some tips for selecting a good slice
and hyst
?
data.csv
Best,
Manuel