ADC Issues, Pullup Fail?

Hi Everyone, I am new to this forum and I appreciate in advance any support you can provide.

I have a T4.1 and I have not been able to get the ADC to work. I am using the recommended input circuit, which measures fine (my input is a guitar pickup which, for the guitars I play, outputs between 0 and ~200mV. The signal is good from both the guitar and as measured on the suggested circuit (note I changed the 10k resister to 2.2k. as per the guidance on that site). After failing to measure the signal with several of the programs on the GitHub pedvide/ADC site (the peak detector and the mono pass through to a working test amp I have) I ran the hardware test. It wrote the following:

PULLUP TEST PASS
PULLDOWN TEST PASS
COMPARE TEST PASS
COMPARE RANGE TEST PASS
AVERAGE TEST PASS

But then all of the sample tests at various resolutions failed, and the output writes PULLUP FAILED after the sample speed details.

I apologize in advance for not pasting the complete output, I didn't save but can run again tomorrow if that would be helpful.

The input pin I have been using is A2 (pin 16). I can also build a regulated external power source as a reference, but again, I would like to see the internal reference work and learn why it doesn't seem to be working for me.

Note that I have never used an external power source and I have never fed the ADC an input greater than the one described above. I have a couple of arduinos and they work fine with the same input current for the purposes of ADC sampling (note I can certainly run the signal through a pre-amp before sending to the ADC for test purposes, but I would prefer not to due to the work I am doing, and I don't see any reason why the ADC on the NXP chip would not accept instrument level input like this). I plan to buy an external shield to minimize noise, etc. but they are not currently available and I would like to understand the chip ADC's before I do this.

Please know that I am a musician with a strong audio engineering background but aside from the arduino, I am quite new to working with microcontrollers. I admittedly may be doing something wrong (real newbie kinda wrong) but it would be good to understand why the HW test read as it did and I would greatly appreciate any other suggestions anyone has for me. Thank you in advance for your patience with all this.

Finally, one side question, is the purpose of the suggested ADC input circuit to provide an optimized impedance for the chip? I tried to read the data sheet to learn the expected impendence perimeters, but I couldn't find that specifically.

Thank you!
 
Follow up with some guitar specific learnings

I did not get any replies to my original post but I thought it might be helpful for other non-engineers like me who lack the secret handshake to share some things that seem to have helped.

On my board, I guess I have an issue with the default ADC input (A2, pin16). I still can't say I fully understand the dual ADC architecture and I don't yet know exactly why that pin is not giving me any love, but after messing around with the examples->readAllpins and readPin code (and restarting) I got the other analog pins to work.

By way of suggestions to other guitar players out there who want to use this board but would prefer to spend their time learning arpeggios vs. code, the first thing I would suggest is to just get an ADC shield. It's just way easier and from what I saw, most of the audio tutorials are written for these. It's also probably quieter from an S/N perspective, and overall, more flexible if you are integrating to a DAW. I'm guessing it will also make overall audio I/O way easier.

If you do decide to use the chip's ADC, one suggestion is maybe start with the examples I cite above as a shortcut to get familiar with it. Consider (like I ended up doing) borrowing the ADC set-up code the author kindly shared (you can use the audio GUI as well, but I think even with that, it will be a slog to use until you get your head around the basic perimeters/settings. I apologize in advance if I am violating a bunch of community decorum with a suggestion like this, but it was a helpful shortcut for me to understand and implement a lot of the ADC stuff on-line.

Serial.begin(9600);

///// ADC0 ////
adc->adc0->setAveraging(16); // set number of averages
adc->adc0->setResolution(16); // set bits of resolution
adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED); // change the conversion speed
adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED); // change the sampling speed

////// ADC1 /////
#ifdef ADC_DUAL_ADCS
adc->adc1->setAveraging(16); // set number of averages
adc->adc1->setResolution(16); // set bits of resolution
adc->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED); // change the conversion speed
adc->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED); // change the sampling speed
#endif

delay(500);
}

If you are used to Arduino's ADC, one thing to note is that although the specific numerical serial baud rate is ignored (I think - I believe it defaults to the I/O speed of your serial i/f), at least with my board/IDE, I need to put a number in there. That is to say, you can't just use Serial.begin() and leaving it out entirely didn't work.

Again, probably common knowledge but I figured I'd share.

Also, contrary to some things I've read on-line, you do not need a pre-amp to use this or Arduino with a guitar for a lot of stuff, and in fact, if you are looking for the most accurate sample of the sound of your guitar electronics and have good code, driving it through a pre-amp, however good the op-amp and parts are, is gonna color the sample somewhat (if ever so teensy, bad pun intended). If a high impedance input was good enough for Leo Fender's first amps, it's good enough for me. That is to say, a guitar wants/needs/bathes warmly in a high impedance input. Just make sure you scale the range of the output to reflect the possible voltage range of your guitar (I am a single-coil tele guy and even with two hot, over-wound pickups in one of my guitars and Ramon's-level strumming, I don't see much more than around 200mV total output. Humbuckers and active pups will be higher output, though, so keep that in mind).

My use-case is pretty arcane so I'm not sure if my code is right for others, but I'm happy to share. I am also going to mess around with an external reference voltage and when I get it as good as I can for guitar, I'll share the circuit and code. One pretty crude but somewhat useful hack (for me and for the purposes of quickly seeing that my guitar output found it's way through the chip) is to use a float instead of an int variable for value and just change the output Serial.print lines to use the range of the reference voltage of the board (3.3) vs. using the getMaxValue range (whatever that's called). In other words:

Change this (for both value1 and value2 lines):
Serial.println(value2*3.3/adc->adc0->getMaxValue(), DEC);

... to this:
Serial.println(value2*3.3, DEC);

Of course, this is not precision accuracy but it may be helpful as a starting point, since even 200mV is hard to see with the high end of the range set to MaxValue. I fully expect to get trashed for making suggestions like this, but whatever, it's a hack, it served it's purpose in my case.

Finally, you can, in principle. drive the ADC directly from the guitar without the suggested circuit. That is to say, you won't break anything if you don't use the suggested biasing/impedance circuit in the GUI, but I am guessing it will be a lot noisier. I used it both ways and I didn't get quite what I wanted either way and since I don't get my shields for a couple of days, I'm going to rig up some filtering capacitors to see if I can optimize for guitar and the chips ADC. There may be some guitar-specific circuits out there but I couldn't find one.

I hope this is helpful. If not, oh well.

Hi Everyone, I am new to this forum and I appreciate in advance any support you can provide.

I have a T4.1 and I have not been able to get the ADC to work. I am using the recommended input circuit, which measures fine (my input is a guitar pickup which, for the guitars I play, outputs between 0 and ~200mV. The signal is good from both the guitar and as measured on the suggested circuit (note I changed the 10k resister to 2.2k. as per the guidance on that site). After failing to measure the signal with several of the programs on the GitHub pedvide/ADC site (the peak detector and the mono pass through to a working test amp I have) I ran the hardware test. It wrote the following:

PULLUP TEST PASS
PULLDOWN TEST PASS
COMPARE TEST PASS
COMPARE RANGE TEST PASS
AVERAGE TEST PASS

But then all of the sample tests at various resolutions failed, and the output writes PULLUP FAILED after the sample speed details.

I apologize in advance for not pasting the complete output, I didn't save but can run again tomorrow if that would be helpful.

The input pin I have been using is A2 (pin 16). I can also build a regulated external power source as a reference, but again, I would like to see the internal reference work and learn why it doesn't seem to be working for me.

Note that I have never used an external power source and I have never fed the ADC an input greater than the one described above. I have a couple of arduinos and they work fine with the same input current for the purposes of ADC sampling (note I can certainly run the signal through a pre-amp before sending to the ADC for test purposes, but I would prefer not to due to the work I am doing, and I don't see any reason why the ADC on the NXP chip would not accept instrument level input like this). I plan to buy an external shield to minimize noise, etc. but they are not currently available and I would like to understand the chip ADC's before I do this.

Please know that I am a musician with a strong audio engineering background but aside from the arduino, I am quite new to working with microcontrollers. I admittedly may be doing something wrong (real newbie kinda wrong) but it would be good to understand why the HW test read as it did and I would greatly appreciate any other suggestions anyone has for me. Thank you in advance for your patience with all this.

Finally, one side question, is the purpose of the suggested ADC input circuit to provide an optimized impedance for the chip? I tried to read the data sheet to learn the expected impendence perimeters, but I couldn't find that specifically.

Thank you!
 
Last edited:
Back
Top