Erratic analog readings on SAM D21

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

i created a custom pcb whit sam D21 mcu. I connected the Aref pin to GND via the 0,1uF capacitor and the VDD_ANA(analog VCC) via a ferrite bead (100 Ohm) to VCC, whit 2x capacitor(0.1uF, 10 uF) to GND for bypass. I use internal 1V reference in 12bit mode. But the analog readings are  jumping from 157.4mV to 162.1 mV and all in between. I also made sure that there is big ground plane under all analog pins and connections on the PCB.

 

At same time i am checking values whit oscilloscope and the value is sitting steady at 162.8mV(+/-0.1mV).

 

I use op amp in buffer configuration at analog entrance to prevent my pcb effecting the value that i measure. I also measured whit scope the analog output of op amp, and also the analog input on mcu and all voltages are steady, so i assume something goes wrong inside the MCU.

 

Any idea what could be the cause of fluctuation in analog reading? 

 

P.S. I also tried addind input capacitor on analog input side to stabilize reading but it had no effect on it, so now im 99% sure it is the problem in MCU.

 

P.S.2. So far i did improve whole thing by averaging 200 analog readings so now the value is fluctuating from 162.1 mV to 162.8 mV. So it is better and the averaging process takes only few milliseconds so it is not a big problem. But if anyone has idea on how to stabilize reading even further, i am open for suggestion :D

This topic has a solution.

Last Edited: Thu. Jun 28, 2018 - 12:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Should I move this to a Cortex M forum - while this is "General Electronics" it's within the "AVR" section of the website so you may not get many "Cortex eyeballs" here

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I put it here because there is no General electronics section in ARM forum. But yea, put it whenever you think it should be :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, you say you assume that it's an MCU problem.  So the appropriate MCU forum - viz, Cortex-M - would be the place to go ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Klemko wrote:

At same time i am checking values whit oscilloscope and the value is sitting steady at 162.8mV(+/-0.1mV).

 

No scope can measure with that accuracy.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What about the rest of the decoupling capacitors?

 

And what performance do you expect?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It was for your benefit - presumably it's Cortex readers you want to see it? Maybe they do read here but if you go to the "ARM community" and look at the names of the regular posters there and then look at the regular posters in this Electronics forum I don't think you will see a lot of overlap. So it's very likely a different audience.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try using Vdd_ana as the reference.  The resolution will be 3.3x worse, but it will show whether the internal reference is the issue.  I don't know D21, but D51 has an errata about references.

 

If that has no effect, cut the trace from the op amp and make a simple resistive divider off Vdd_ana using it as the reference.  If that is unstable, then you need to look at your board.

jeff

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks i did this and the values were good then. I fixed it by rounding reading to half a decimal (.5), an only using floats, without any integers in calculations. Now i average 100 readings and the values is sitting tight to 2 decimals and there is 0 fluctuation. Thanks all :D