dmadison / Sim-Racing-Arduino

A library to connect sim racing peripherals to Arduino development boards
GNU Lesser General Public License v3.0
66 stars 7 forks source link

Pedal flickering #7

Closed AyrtonRicardo closed 1 year ago

AyrtonRicardo commented 1 year ago

Have you experienced pedal flickering with this code?

I've really liked what you've done here, and I would love to keep using your code for this, however the code is too sensitive to potentiometer changes, even when my pedals are at its maximum, the code keeps flickering the values back and forth as if it has noisy.

dmadison commented 1 year ago

Hello, glad you like the library.

For responsiveness, the library performs no smoothing on the ADC inputs whatsoever. If the output is "flickering" then indeed there must be noise on the line. Anything more than a small jitter is indicative of a connection problem, either from the Arduino to the pedal unit or internally with the potentiometer wiper itself.

If you run through the serial calibration you can apply deadzones to the start and end of the pedal travel. That will reduce the resolution somewhat, but it will stop any oscillation at the limits.

If you'd prefer to use the full pedal travel, reducing the resolution of the output (use smaller 'map' values) will reduce the effect of noise but will also make the pedal less precise. You could also add your own smoothing filter to the output which will keep the full resolution but increase latency.

Hope that helps.

AyrtonRicardo commented 1 year ago

Hello, glad you like the library.

For responsiveness, the library performs no smoothing on the ADC inputs whatsoever. If the output is "flickering" then indeed there must be noise on the line. Anything more than a small jitter is indicative of a connection problem, either from the Arduino to the pedal unit or internally with the potentiometer wiper itself.

If you run through the serial calibration you can apply deadzones to the start and end of the pedal travel. That will reduce the resolution somewhat, but it will stop any oscillation at the limits.

If you'd prefer to use the full pedal travel, reducing the resolution of the output (use smaller 'map' values) will reduce the effect of noise but will also make the pedal less precise. You could also add your own smoothing filter to the output which will keep the full resolution but increase latency.

Hope that helps.

That's exactly what I've done. but the "max" no matter how small I add, it flickers, feels like a problem translating the analogic signal to digital.

I will try some tests and get back here some time later and provide more meaningful feedback to you.

AyrtonRicardo commented 1 year ago

@dmadison thanks for your message, just made some tests and I could not reproduce the issue, the pedals seems to be very stable and doesn't seems to flicker as much. Probably the reason is mainly myself, which I might have used another library while coding the arduino.

Sorry for wasting your time, thanks for the lib.