Author Topic: Custom Arduino Zero board ADC Problems  (Read 4106 times)

0 Members and 1 Guest are viewing this topic.

Offline HappyBananaTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Custom Arduino Zero board ADC Problems
« on: March 18, 2017, 07:19:59 pm »
Hello,
I created a custom arduino zero pcb that uses a few analog pins.The micro controller functions perfectly, but the ADC pins are never able to read a 0. When an analog pin is pulled low, the ADC always reads a value of 3 or 4 and sometimes 5. Does anyone have any guesses on why this would happen? The pins are definitely not floating, when pulled high I get 1023 and when pulled low I get 3 or 4. Attached is a image of the board, probably useless but worth a shot.
Thanks,
Tyler
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #1 on: March 18, 2017, 07:40:05 pm »
Pulled low or actually connected directly to ground? What do you get if you connect the input to a ground pin?
 

Offline HappyBananaTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #2 on: March 18, 2017, 07:42:11 pm »
No matter how I get it to 0V it always reads 3,4, or 5. Directly to gnd, through a 10K resistor, or connected to a digital pin pulled low all achieve the same result.
 

Offline Lovely_Santa

  • Contributor
  • Posts: 42
  • Country: be
Re: Custom Arduino Zero board ADC Problems
« Reply #3 on: March 18, 2017, 09:19:36 pm »
Hello,
I created a custom arduino zero pcb that uses a few analog pins.The micro controller functions perfectly, but the ADC pins are never able to read a 0. When an analog pin is pulled low, the ADC always reads a value of 3 or 4 and sometimes 5. Does anyone have any guesses on why this would happen? The pins are definitely not floating, when pulled high I get 1023 and when pulled low I get 3 or 4. Attached is a image of the board, probably useless but worth a shot.
Thanks,
Tyler
I'm not familiar with arduino zero... but does it use an internal ADC or an do you use a seperate chip? It would help if I had a datasheet at hand...

No matter how I get it to 0V it always reads 3,4, or 5. Directly to gnd, through a 10K resistor, or connected to a digital pin pulled low all achieve the same result.
Without the datasheet I came up with some things:
  • Some (read as: most of the affortable ADC's) have an offset on the lower line, so it won't show an absolute 0 read, or at the upper line, so not showing the max value (on your case 1023, it depends on number of bits, 10 in your case)
  • Wat is your voltage reference versus the max voltage reference that you may apply? If you aren't using the full reference, or a prefered reference, you can't just apply the datasheet, but you will have to interpolate the values (mostly just linear between your and the datasheet value's)
  • Did you short the pin directly near the ICs package to ground? Sometimes the noise in the air and nearby pads on a PCB, and the natural capasity of your PCB is enough to have a small static voltage on your input of your ADC
  • I know you said you shorted the pin directly, but just keep in mind, when you connect an IC (directly or indirectly by a wire), this value will even rise more, becose ICs are noisy on there own.

I always calculate this effect by measuring different analoge voltages on my final design, so I convert the readed input voltage to a digital number, and then I apply a correction factor... Just in software, easy fix, and when your designs get bigger, it's easy to correct by just recallibrating your correction factor

Hope this helps a bit,
Lovely Santa
English is only my 3th language, so don't tell me my english is bad, becose I know that, I try to do what I can...
 

Offline HappyBananaTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #4 on: March 18, 2017, 10:10:47 pm »
The chip is the ATSAMD21 (http://ww1.microchip.com/downloads/en/DeviceDoc/40001882A.pdf)

It uses an internal ADC. I am using the logic voltage as my reference so AREF is not set, making that 3.3v, or more precisely, 3.27v. The pins directly next to the analog pins I am using are also used for other purposes, so they are not always connected to ground. Hopefully the values are consistent and I can compensate in software.
Thanks,
Tyler
 

Offline senso

  • Frequent Contributor
  • **
  • Posts: 951
  • Country: pt
    • My AVR tutorials
Re: Custom Arduino Zero board ADC Problems
« Reply #5 on: March 19, 2017, 01:36:20 am »
Make sure the inputs are turned into well, inputs, and that pull-up resistors are off.
And if they share ISP/JTAG functionality, and IF you are using a bootloader, try disabling those features.
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Custom Arduino Zero board ADC Problems
« Reply #6 on: March 19, 2017, 06:27:16 am »
I am using the logic voltage as my reference so AREF is not set, making that 3.3v, or more precisely, 3.27v.

Is AREF connected to anything? I seem to remember that is always a good idea...

What is the voltage you measure on the chip leads itself? If that is 0V then its an internal problem. If not, you're picking something up along the way...

[2c]
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2603
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #7 on: March 20, 2017, 01:21:20 pm »
It may be helpful to show your schematic. 

The SAM D series ADCs have a calibration register that should be loaded with values from production testing which are stored in the NVM--I would hope that the arduino libs do this for you when initializing the ADC, but worth checking.

They also have gain and offset correction registers which can be used to further improve ADC accuracy.  It's up to the user to provide the correct values for these registers, which may be used to a certain extent to calibrate for external hardware as well as variation between different MCUs.

The SAM D ADC is inherently differential, and when used with single-ended signals you must still select the appropriate negative input mux connection via the MUXNEG field in the INPUTCTRL register.  Selecting internal gnd or IO gnd might give different results.  (The DIFFMODE bit in CTRLB actually only controls whether the result is singed or unsigned; the datasheet does not make this clear.)

 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Custom Arduino Zero board ADC Problems
« Reply #8 on: March 20, 2017, 02:22:52 pm »
Actually the results you are getting seem quite good, based on specs.
The 15 LSB error shown in table.

     Right click, open image in new tab, to see image.


Regards, Dana.
« Last Edit: March 20, 2017, 02:24:28 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Lovely_Santa

  • Contributor
  • Posts: 42
  • Country: be
Re: Custom Arduino Zero board ADC Problems
« Reply #9 on: March 21, 2017, 09:56:30 pm »
The chip is the ATSAMD21 (http://ww1.microchip.com/downloads/en/DeviceDoc/40001882A.pdf)

It uses an internal ADC. I am using the logic voltage as my reference so AREF is not set, making that 3.3v, or more precisely, 3.27v. The pins directly next to the analog pins I am using are also used for other purposes, so they are not always connected to ground. Hopefully the values are consistent and I can compensate in software.
Thanks,
Tyler

How do you connect your logic voltage (3.3V nominal) to your Vref? I would recommend to use a zener diode or linear voltage regulator. Those are stable, meaning low noise on the reference voltage. When you don't have a higher voltage (to use a zener or regulator), connect it directly to the VCC pin of your controller, and put a 100nF decoupling capacitor withing a close range of the Vref pin.

They also have gain and offset correction registers which can be used to further improve ADC accuracy.  It's up to the user to provide the correct values for these registers, which may be used to a certain extent to calibrate for external hardware as well as variation between different MCUs.
If you are a beginner or don't like to program, I would recommend to use the libraries for that, but I find that these libraries have a decent amount of overhead. Not that the library isn't good, it is very efficient, but it will never be as good as writing your own code, specific for your uses. So when you have big programs, running almost to the maximum space inside your microcontroller, I would recommend to write it yourself.

It may be helpful to show your schematic.
If you have specific questions on how to implement it, a schematic would be helpfull... I can only provide as much info as you are telling me ;) Or your code can help too... But I think you can do it, (I believe that)

Greets,
Lovely Santa
English is only my 3th language, so don't tell me my english is bad, becose I know that, I try to do what I can...
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #10 on: March 29, 2017, 09:35:59 pm »
"How do you connect your logic voltage (3.3V nominal) to your Vref?"

Just for reference for others, that can be very dangerous to program as it may directly connect to 5V if that is used for the micro power.
 

Offline HappyBananaTopic starter

  • Newbie
  • Posts: 6
  • Country: us
Re: Custom Arduino Zero board ADC Problems
« Reply #11 on: April 20, 2017, 11:41:19 pm »
Hello,
After quite a bit of testing I am still unable to get the proper ADC readings. The code works perfectly on a Arduino UNO, it is literally just reading the ADC so I doubt that is the problem. I am fairly new to pcb design so its probably something I did. I published a schematic, gerber files and kicad files on github if anyone wants to take a look. https://github.com/spadgenske/rbt-board
Thank you!
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: Custom Arduino Zero board ADC Problems
« Reply #12 on: April 21, 2017, 12:27:16 am »
Well the UNO uses a different device - namely an atmega328. You're using the SAMD21, so apples.. oranges.. If you're getting different readings on an Arduino Zero (which uses the same device) then I would say it is indeed layout or power-supply filtering.

Look at the variables:

Device - including revision.
PCB layout.
External parts.
Power supply.

Any/all of those can cause an ADC reading to jump about, or have a large offset.  The most obvious being the first - ADC's in microcontrollers can have a fixed offset which is usually calibrated out (that is why manufacturers can include a calibration word on NVM).

ADC's in micros do not always read 0 when the input pin is tied directly to ground, for several reasons, most of which have already been covered in the thread.  There is also internal interference - which is why to reduce 'noise' in readings app notes sometimes recommend disabling other peripherals or slowing down the clock during ADC reading.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf