I'm using a 12 bit ADC (MAX1270), SRAM (23LC1024) and PIC18f4550 to measure temperature transient at the output of an RTD. The communication protocol is SPI. The voltage is sampled and sent to PIC, and is saved in SRAM. At the end of the experiment, the data is read back from SRAM, sent to desktop PC via UART and received using HyperTerminal.

The issue: The data read has periodic fluctuations- at an interval of around 2.5 sec. If I probe the ADC input pin with a Digital Storage Oscilloscope in High Resolution mode, the voltage variation is smooth without any fluctuation. Any idea what the problem could be?

x- axis: Interval is 50 ms. The fluctuation occurs roughly every 50 counts (50 * 50ms = 2.5 sec).

y- axis: Voltage


Edit 1: Sample and average technique is used to obtain ADC data: 16 consecutive samples are taken, sorted in ascending order and the extreme four values are discarded. The middle 8 samples are then averaged to get the final value. This process repeats itself every 50 ms (a timer interrupt is configured such that the sampling takes place every 50 ms in the main routine).

Edit 2: A 40mHz sinewave (+10V to -8V) was applied to the input of the Opamp buffer feeding the ADC. Please refer the attached image. https://i.stack.imgur.com/f1cm5.png The waveform is OK except for the first 4 seconds, in that it shows some fluctuation. The ADC is directly connected to the opamp buffer without a RC network. How big a problem can it cause? https://i.stack.imgur.com/LiUAE.png

Edit 3: I probed the RTD transient with the DSO in normal mode, without post-sampling processing (one ADC sample every 50 ms, no sample and averaging). The DSO output is in blue and ADC in red. There is an offset between the two. What could be the reason? The fluctuation seems to have gone, but I need to verify it by testing with another RTD. REF pin of the ADC is at 4.085V as against 4.096 given in datasheet. REFADJ pin is at 2.492V. The ADC is used in internal reference mode. enter image description here enter image description here

Please Note: I won't have access to the test setup for the next 5 days. I'll get back with the results of your suggestions as soon as I get access.

  • \$\begingroup\$ Have you tried sampling at different intervals? \$\endgroup\$ Sep 28, 2014 at 15:58
  • \$\begingroup\$ Not yet. How could that cause the problem? \$\endgroup\$
    – Limpy
    Sep 28, 2014 at 16:03
  • 1
    \$\begingroup\$ You could be seeing induced voltages from another device with periodic emissions. Changing the sampling interval will allow you to prove this either way. \$\endgroup\$ Sep 28, 2014 at 16:05
  • 2
    \$\begingroup\$ It could be a mains interference beating with sampling interval. \$\endgroup\$
    – venny
    Sep 28, 2014 at 19:05
  • 1
    \$\begingroup\$ Heh, does the data look the same when the oscilloscope is connected? And if you see 'no fluctuations' on the 'scope you're not looking hard enough-there will be some noise at least. \$\endgroup\$ Sep 29, 2014 at 12:45

2 Answers 2


Your signal chain is quite complex, and you can have problems at every step, or even multiple problems. You have analog circuitry, into external ADC, through a PIC, into SRAM, back through the PIC, at some point employing a highly nonlinear filter, out through UART and into hyperterminal. Debugging this involves baby steps, which pretty much means you need to eliminate all the shortcuts you took getting to this point.

Where I would start would be to verify everything one step at a time. Start by sampling a CONSTANT voltage, then a sine wave out of a function generator, and make sure you understand what you see.

Once that makes sense to you, LOOK at your analog input with an oscilloscope, and make sure you understand what you see with that. There is no substitute for this. There are reasons why we use bench instrumentation, and this is one of them.

Next, find a way to get rid of all your post-sampling processing, and look at the data in as raw a state as you can. You are doing highly nonlinear processing. When you do this sort of stuff, when it doesn't work you go back and look at the whole process with a microscope.

I suspect you might have an extremely noisy signal, you're aliasing it down by not sampling fast enough, and the non-linear processing is confusing the issue.

  • \$\begingroup\$ Please go through Edit 2 of the first post. The obtained waveform involves post-sampling processing. \$\endgroup\$
    – Limpy
    Sep 30, 2014 at 16:05
  • 1
    \$\begingroup\$ @Limpy You need to look at things on an oscilloscope with a time scale that allows you to see noise clearly. Also, you don't necessarily want post-sampling processing as you try to debug this. It complicates things. \$\endgroup\$ Sep 30, 2014 at 16:13

Are your power rails clean? The periodic distortion on the signal suggests some load might be disturbing the power rails, causing a "ground bounce" on either your ADC input or reference.

  • \$\begingroup\$ Power rails are clean, as measured by a probe. The ADC uses internal reference. Also, as pointed out before, the ADC input pin is clean, as measured by the probe. \$\endgroup\$
    – Limpy
    Sep 28, 2014 at 16:12
  • \$\begingroup\$ Try the different sampling rate as Ignacio suggests. If you get the same time period you need to look for something that is switching at the frequency. \$\endgroup\$
    – kabZX
    Sep 28, 2014 at 16:16
  • \$\begingroup\$ I was thinking of something along these lines: electronics.stackexchange.com/questions/112625/… \$\endgroup\$
    – Limpy
    Sep 28, 2014 at 16:23
  • \$\begingroup\$ Yes thats another possible explanation. You should check your SPI first. Although, if your SPI is not set up correctly you should not be able to communicate with the ADC at all, right? \$\endgroup\$
    – kabZX
    Sep 28, 2014 at 16:25
  • \$\begingroup\$ @kabZX Did you find the problem? Was the SPI connection? \$\endgroup\$
    – bardulia
    Aug 28 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.