Analog Readings Unstable On MIDI Projects

Status
Not open for further replies.

kadams58

New member
I am fairly new to the world of Teensy. I have discovered something very interesting regarding analog readings of the Teensy compared to those of Arduino UNO, Pro Micro and MEGA. I will use the very same code to read 4 different pots on the UNO, Pro Micro and MEGA and the readings on my MIDI output monitor is constantly changing. I upload that same code onto the Teensy 2.0 and the 3.2 and the readings are as stable as a rock. I have spent days and days trying to get the same solid, stable analog read results from the UNO, Pro Micro and MEGA. I eventually throw my hands up and just go back to the Teensy and then, problem solved - solid, stable results. Has anyone else observed the same thing? I am perplexed by what I'm seeing.
By the way, I am using the following library: #include <ResponsiveAnalogRead.h>
And here is the code for reading the pots:

void getAnalogData() {
for (int i = 0; i < A_PINS; i++) {
// update the ResponsiveAnalogRead object every loop
analog.update();
// if the repsonsive value has change, print out 'changed'
if (analog.hasChanged()) {
data = analog.getValue() >> 3;
if (data != dataLag) {
dataLag = data;
usbMIDI.sendControlChange(CCID, data, channel);
 
I know that the ATmega processors have rock steady ADCs, I have data acquisition boards using the ATmega328P
that are battery powered that show sub-LSB stability (for instance slowly changing voltages produce a clear even
staircase when plotted over time, with short periods of jitter between neighbouring counts at the boundaries, and
fixed output for most of the time, which is the best you can expect of an ADC in the real world)

There are gotchas to avoid - the supply voltage should be clean, avoid driving varying/PWM high current loads
from the same supply as those will modulate the supply voltage. Also the source you are measuring needs to
be low-impedance, 10k or less. I suspect the difference between the setups is leading to the difference you
see.

I also note the T2.0 uses the same family of chips as the Arduinos, so will have the same ADC performance
AFAICT.

I'd suggest writing a test sketch to log raw analog values so you can see what the actual variation is
 
Any chance your code is pointing at a floating pin on the other boards? Get one pin number wrong and you will read garbage on every pass.

The nature of the MIDI you consider 'wrong' should tell you something about the cause. Is it all four pots? Is it adjacent values or wild chatter? Is it a deluge or occasional flicker?
 
Status
Not open for further replies.
Back
Top