ADCInput Issues #1791
Replies: 3 comments 4 replies
-
Without an MCVE there's not much to go on here Some general things to check are if any of your other libraries are using hard coded interrupts out DMA channels, effectively breaking the ADC lib. Also, if the disable interrupts for a very long time you could end up overflowing and having the DMA ping pong die. Of course, pin conflicts may also be in play if you're using a pin that's connected to the SPI port those libraries use. |
Beta Was this translation helpful? Give feedback.
-
Did you mean it doesn't respond at all, or just that it's laggy? delay(1000); gives a one second update period, which will seem very unresponsive. Radio control for models typically uses a 50Hz update rate, which is 20 milliseconds, so that would be delay(20); in your loop, not allowing for how long the other code takes to execute. That's a good rate to aim for, to make it feel interactive. A little slower would seem okay, but one second is too much. FWIW, the RP2040 ADC inputs are quite noisy and non-linear. You might find you need to add some code to smooth out the response a bit, or maybe consider an external ADC chip or module. There are some good analyses of how they behave, and the Raspberry Pi organisation acknowledged that there's a problem. In theory they can give about 9 bits of resolution, correcting for noise and errors. Maybe there's some library code available to do that, by now. |
Beta Was this translation helpful? Give feedback.
-
Somewhere along the way I picked up the nototion that analogRead didn't work and I needed to use the ADCInput library. That worked fine for my application, no buffer needed. |
Beta Was this translation helpful? Give feedback.
-
I'm working on a physical device to keep track of the moons of Krynn for a Dungeons and Dragons game. I ran the example ADCInput (mike test) code, and it worked fine with my potentiometer. When I attempted to add it into my main code, it was giving a value but wasn't responding to changes to the potentiometer. My first thought was some sort of SPI conflict, but after reading the doc, I think I have a buffer/frequency problem. I doubt I need to be reading at 8000hz for a potentiometer, but I'm not sure how to move forward.
Beta Was this translation helpful? Give feedback.
All reactions