I have managed to duplicate what you see:
And here is a zoomed-in view with the current range shown:
For the test, I used a bench supply set to 3V with one of my custom loads boards. The custom load takes a signal generator output and converts it to current by controlling a MOSFET. The resulting current was a 1 kHz sine wave with a low/high range of approximately 0.5 mA to 27 mA.
I have a few observations:
Instead of replacing samples with the mean, the algorithm should linearly interpolate. The resulting average value will be unchanged, but the curve will look much better.
This particular example starts at the 18 mA range, ranges to the 2A range before quickly going to the 10A range. It then downranges to the 2A range and finally settles on the correct 180 mA range. The result is right, but it took more ranging changes than I would expect. The current slope here appears pretty gentle, so I am not sure why the hardware decided to jump step from 18 mA to 2A in the first place. I will investigate.
As you have seen, raw_processor.pxi has a long history and can likely be simplified. It’s not something I want to change without lots of testing. I will schedule some time after I get this upcoming release out.
Thanks again for your time and for bringing this to my attention!