0

AD issues Grand Central
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AD issues Grand Central

by Harrie on Wed Sep 09, 2020 9:59 am

I use the Arduino IDE and C with a Metro M4 Grand Central. I was testing this board to see what it can do compared to an Arduino Due.

Everything works fine except the AD conversion. If I set the resolution of the AD to 12 bits, the maximum read is as expected 4095, but if I drop the voltage I only get even numbers. When I change the resolution to 10 bits it does work correctly. Any higher resolution settings only multiply the 10 bit number. The resolution of the DAC seems OK to at 12 bit, although at first I didn't realize the DACs were at Analog 0 and 1.

The (test) code is extremely simple and works fine on a Due.

Any suggestions?


Code: Select all | TOGGLE FULL SIZE

#include <LiquidCrystal.h>        //LCD bieb


// initialisering display pennekes
LiquidCrystal lcdC(53, 51, 47, 45, 43, 41); //(rs, enable, d4, d5, d6, d7)(LCD pen 5 naar massa)


void setup() {

analogReadResolution(12);
   
}//Einde setup


void loop()
{
lcdC.setCursor(0, 0);
lcdC.print(analogRead(A7));lcdC.print("   ");
delay(300);
}

Harrie
 
Posts: 5
Joined: Wed Sep 09, 2020 9:46 am

Re: AD issues Grand Central

by dastels on Wed Sep 09, 2020 10:25 am

Everything looks reasonable, I even looked at the analogRead code. Stupid question, but you're changing the board selection appropriately? I ask because there's some conditional compilation in the analogRead code around the board having a SAMD51 MCU.

Dave

dastels
 
Posts: 6907
Joined: Tue Oct 20, 2015 3:22 pm

Re: AD issues Grand Central

by Harrie on Thu Sep 10, 2020 2:22 am

Thanks for your reply Dave,

Yes, I installed the Adafruit files and selected Adafruit Grand Central M4 (SAMD51).
I also played around a bit with the optimize settings to check if that made any difference, but to no avail.

The readings go up in steps of 2, so only even numbers like 2, 4, 6, 8 and so on, except for the highest voltage where I get 4095.

Harrie
 
Posts: 5
Joined: Wed Sep 09, 2020 9:46 am

Re: AD issues Grand Central

by dastels on Thu Sep 10, 2020 11:12 am

It looks like it's scaling the reading. If you ask for more resolution that the ADC can handle it shifts the reading left which would result in even numbers. The 4095 at the top is a bit perplexing at the moment. Let me dig around a bit more.

Dave

dastels
 
Posts: 6907
Joined: Tue Oct 20, 2015 3:22 pm

Re: AD issues Grand Central

by dastels on Thu Sep 10, 2020 11:22 am

Out of curiosity, how are you generating the voltages you're reading?

Dave

dastels
 
Posts: 6907
Joined: Tue Oct 20, 2015 3:22 pm

Re: AD issues Grand Central

by Harrie on Fri Sep 11, 2020 1:48 am

I use a pot between 3.3V and gnd of the board's own supply.

I have checked all resolutions; the converter seems to get stuck at a true resolution of 11 bits:
bit max step
8 255 1
10 1023 1
12 4095 2
14 16380 8
16 65520 32

But the AD converters are specced for 12 bit so they should be able to handle that, right?

Harrie
 
Posts: 5
Joined: Wed Sep 09, 2020 9:46 am

Re: AD issues Grand Central

by dastels on Fri Sep 11, 2020 9:45 am

Yes, they can do 8, 10, and 12 bit according to the code. Do you have another SAMD51 based board to compare against?

dastels
 
Posts: 6907
Joined: Tue Oct 20, 2015 3:22 pm

Re: AD issues Grand Central

by Harrie on Mon Sep 14, 2020 4:38 am

I tried a itsybitsy M4 with a SAMD51 and get exactly the same results: up to 11 bit resolution, above that just a multiplied number that clips in 12 bit resolution at 4095. This leads me to suspect the Adafruit library for Arduino IDE?

Harrie
 
Posts: 5
Joined: Wed Sep 09, 2020 9:46 am

Re: AD issues Grand Central

by dastels on Mon Sep 14, 2020 10:22 am

I've asked ee support for input.

dastels
 
Posts: 6907
Joined: Tue Oct 20, 2015 3:22 pm

Re: AD issues Grand Central

by adafruit2 on Mon Sep 14, 2020 10:38 am

harrie, you can open an issue at the SAMD repo, there's no ETA when we could look at it - please try to use it with 11 bits of data!
https://github.com/adafruit/ArduinoCore-samd

adafruit2
Site Admin
 
Posts: 20112
Joined: Fri Mar 11, 2005 7:36 pm

Re: AD issues Grand Central

by Harrie on Tue Sep 15, 2020 1:59 am

I didn't buy it to use at 11 bit resolution and they are specified at 12. Also the AD conversion is slower than a Due.
It's a pity as it had some nice advantages (faster, better DAC handling) compared to an Arduino Due. I know I could use external AD converters but that makes a design more complicated again.
So these boards are from now on not interesting to me and I will keep using the Due.

Harrie
 
Posts: 5
Joined: Wed Sep 09, 2020 9:46 am

Please be positive and constructive with your questions and comments.


cron