Question about noise problems sampling potentiometers with ADC using 18F4550 - Page 1
Forum section: electronics / projects

author: cocus
author_rank: Newbie
timestamp: September 20, 2014, 10:37:07 pm
content: Hello all! This is my first post in the forum.Well, a few years back I've designed a "DJ" controller, which only reads the value of some potentiometers (10k LIN) and scans a matrix keyboard.I was using the 18F4550 for the main processing and interface, and 3 logic gates to demux the entire keyboard when scanning.Since this is powered only by USB, everything is connected to the 5V rails. (filtered by a 220uF cap, and each IC has an 1nF cap near its power pins)The keyboard scanning was an easy task, and it worked out in the first try!But, sampling the pots was a pain in the backside!It worked out nice, but there was a "huge" amount of noise. It wasn't the matrix keyboard demux hard (since I've disabled it to try finding the noise source).As usual, I've discarded some bits out of the ADC value, but the problem is still there. The last thing that I've done in that project was using an average value (using 20 samples per channel).Doing the calculations of the Datasheet of this PIC, gives me 2.87uS of Tacq (aquisition time). Working at 48MHz, and selecting the biggest Tad value, I'm way out of that time (1.33uS, and should be greater than 2.87uS), which can be a problem.I didn't tried out selecting the internal RC clock (which offers a Tacq of 2.5uS), but I will in the meantime.PS: The potentiometers aren't meant to change its value quicky (maybe 40 or even 60 Hz in "rage mode").Right now, the cables aren't shielded, but they used to be, and the problem was still there. The potentiometers are connected directly to the 5V rails (all of them).The main reason about this post is that I'll desing a new PCB for this beast, and I'll like to know what I should take care to accomodate the signals (and thus, remove a little bit of noise).I know the timing MAY be the only issue, but at least designing a good quality PCB will reduce the ammount of problems later!I'll appreciate any feedback.Thanks!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 20, 2014, 10:42:52 pm
content: Did you try RC filtering the pots?

author: cocus
author_rank: Newbie
timestamp: September 20, 2014, 10:46:51 pm
content: Quote from: T3sl4co1l on September 20, 2014, 10:42:52 pmYes, I was using a 10K + 1uF. (Almost 100Hz low-pass filter)In fact, I couldn't plot the "values" that were being readed in the MCU, since I should develop a MIDI receiver (or maybe get one of those "midi monitors") and then plot it. So I really don't know if the noise is 50Hz (line frequency here). Maybe I'll try to get some data from it and I'll put in here.Thanks!

author: dannyf
author_rank: Super Contributor
timestamp: September 20, 2014, 10:53:41 pm
content: It could be your code, it could be your circuit, and it could be a gazillion different things.What I would try is to ground the adc input pin and see if you still get crazy adc results.If you don't, put a small capacitor, like 1n - 100n, on the adc input pin and go home.

author: kxenos
author_rank: Frequent Contributor
timestamp: September 20, 2014, 10:56:52 pm
content: You will ahve to locate the source of the noise and for this I'm afraid you will need an oscilloscope. You will have to find out if the problem is the 5V supply to the uC that I think is used as the voltage reference for the ADCs or the actual inputs to the ADCs. If you have a linear bench PSU you can try to power your board from it and see if it makes things any better.

author: bobcat
author_rank: Regular Contributor
timestamp: September 20, 2014, 11:47:46 pm
content: How much noise do you consider to be "huge?" Actually most pots are noisy, tens of millivolts for cheap ones. Start by getting good low noise pots.Most ADC's have a low impedance input. If you are sampling directly from the wiper of the pots, that is a fairly high impedance source. Maybe try adding a low output impedance op-amp in follower mode to help drive the adc.

author: mikerj
author_rank: Super Contributor
timestamp: September 21, 2014, 09:54:49 am
content: Quote from: cocus on September 20, 2014, 10:46:51 pmYou mention that the pots are referenced to the 5v rail, presumably your ADC reference is also derived from this rail? If that is the case, then putting a low pass filter on the pot will make the results worse if you have any noise on the 5v rail.With no filter the ADC reference and the pot voltage are ratiometric, the same noise will appear on both and cancel out (to some extent at least). With a low pass filter in place on the pot you lose this advantage.1) You must use the RC derived ADC clock for high Fosc values in the PIC. Insufficient acquisition time will result in errors that depend on the value of the previous channel sampled, i.e. one input can affect the others.2) Check the noise level on your 5v rail, do you have sufficient and effective decoupling?3) If a low noise 5v rail is not possible, consider using a well decoupled external reference for the ADC and potentiometers. Beware the maximum reference output current if you do this.

author: diyaudio
author_rank: Frequent Contributor
timestamp: September 21, 2014, 10:02:22 am
content: Quote from: cocus on September 20, 2014, 10:37:07 pmWhat type of potentiometers are you using ? DJ equipment normally uses Alps Potentiometers which is regarded as good quality. analogue signal integrity can be realised using an oscilloscope.See the attachment for a typical case interfacing analogue pots with a 11 channel 10-Bit ADC, note the RC filtering on each node.

author: mikerj
author_rank: Super Contributor
timestamp: September 21, 2014, 01:30:00 pm
content: Quote from: diyaudio on September 21, 2014, 10:02:22 amAlso note the filtering for the ADC reference voltage.

author: cocus
author_rank: Newbie
timestamp: September 21, 2014, 06:17:24 pm
content: First of all, thanks for all your replies!I've added an L-C-L filter (from junk scrap), and it lowered the 5V rail noise (which comes from the USB host).My pots are the standard "cheap" ones. I know I need better quality ones, but in my country it's REALLY hard to get good components (some nonsense prohibitions from buying things outside the country).I've added some 100nF caps in each ADC line and the result are a little bit better.Besides that, I'm not using an external Vref (since I've ran out of pins!).Now the problem is related to the PIC generating high frequency "spikes" (about 2MHz). I think it might be the switching time between inputs (i.e. the sampling cap is still charged, and when switched, all of his charge must flow thru the pot).Next thing I'm going to do is switch to the RC OSC since what says mikerj actually happens! (and might even remove those awful spikes)Sad thing is the project was built with MPLAB 8 and C18, and now I have XC8 (hours of fun upgrading code!)PS1: the RC filtering was done in the output of each pot, not in the rail of those.PS2: thanks diyaudio for the schematic. I might consider switching to those serial ADCs instead of the internal PIC has; so I can leave the ADC in a small module in the PCB (with his filtering for the Vref and each channel).Thanks!

author: David Hess
author_rank: Super Contributor
timestamp: September 27, 2014, 02:02:54 pm
content: The RC filter needs to be close to the ADC for best results and should include a series resistor, again near the ADC, in series with the potentiometer signal.In this sort of application you actually do not want to use a dedicated reference for the ADC unless that reference also supplies the potentiometers. By using the same reference for the potentiometers and the ADC even if it is noisy, the measurements are ratiometric which cancels out reference drift and noise.The above however suggests a problem. If the supply voltage to the potentiometers does not come from the same spot as the ADC reference, then noise between them will show up in the conversion. This is the same thing that happens with a ground loop but on the power side. The solution for this is to make sure that the potentiometer ground and power connections come directly from the ADC ground and reference connections which in this case are at the microcontroller.