0

Feather M0 Aref
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M0 Aref

by muscle75 on Wed May 16, 2018 1:48 pm

I am going to interface a Feather M0 to an external analog reference of 2.5V. I am going to experiment on how to make as precise and accurate measurements as possible with the Feather M0. I have a couple questions regarding this.

1. Provided the reference is stable (MPN: MCP1501-25E/SN). What is a typical improvement can I expect over the embedded reference in the SAMD21G?
2. I read somewhere that if I initiate an analog read with the reference pin connected, and do not properly configure the reference pin in the sketch, I might damage the SAMD21G. Is this correct?
3. Once I select the external reference in my sketch, how do I configure it for the 2.5V value? Is there a sketch I can reference on how to set-up the Feather M0 for an external reference?
4. Since the new reference is 2.5V, is the input voltage range now 0-2.5V?
5. If I adjust the resolution to 12bit, would I then need to divide 4096 by the voltage range? Is there an example sketch on how to adjust the analog input resolution?
6. If I decide that I need to calibrate the analog input, I see there are registers in the SAMd21G to do this. Also, I see there is a feature to adjust the gain presented to the ADC internally on the SAMD21G. Are there example sketches on how to manage these parameters?

Thank you in advance!

muscle75
 
Posts: 3
Joined: Wed May 16, 2018 12:26 pm

Re: Feather M0 Aref

by adafruit_support_mike on Thu May 17, 2018 3:26 am

muscle75 wrote:1. Provided the reference is stable (MPN: MCP1501-25E/SN). What is a typical improvement can I expect over the embedded reference in the SAMD21G?

There won't be any effect on most of the ADC's internal error sources (read through the list in the Electrical Characteristics section of the datasheet), but your confidence in the absolute accuracy of a reading will drop from +/-1% to about +/-0.1%.. about 1LSB at 10-bit resolution.

muscle75 wrote:2. I read somewhere that if I initiate an analog read with the reference pin connected, and do not properly configure the reference pin in the sketch, I might damage the SAMD21G. Is this correct?

I can't find any mention of that in the datasheet, but the reasoning is valid. The Aref pin does get connected to the ADC's configured reference, and you don't want two voltage sources fighting with each other.

muscle75 wrote:3. Once I select the external reference in my sketch, how do I configure it for the 2.5V value?

You don't.

The ADC's readings are ratiometric.. at 10-bit resolution, the output means "N/1024ths of Aref, whatever that is". You scale the ADC's output to a specific voltage in code, using the assumed value of Aref as a constant.

muscle75 wrote:4. Since the new reference is 2.5V, is the input voltage range now 0-2.5V

Yes.

muscle75 wrote:5. If I adjust the resolution to 12bit, would I then need to divide 4096 by the voltage range? Is there an example sketch on how to adjust the analog input resolution?

The functions you need are analogReference() and analogReadResolution():

https://www.arduino.cc/reference/en/lan ... reference/
https://www.arduino.cc/reference/en/lan ... esolution/

At 12-bit resolution, the ADC's output will mean "N/4096ths of Aref".

muscle75 wrote:6. If I decide that I need to calibrate the analog input, I see there are registers in the SAMd21G to do this. Also, I see there is a feature to adjust the gain presented to the ADC internally on the SAMD21G. Are there example sketches on how to manage these parameters?

The chip supports those features, but there are no wrapper functions for them in the Arduino environment. You'll have to read through the datasheet to find the registers that need to be set, and read the analog code from the board support package to see how that's handled in code:

https://github.com/adafruit/ArduinoCore ... g_analog.h
https://github.com/adafruit/ArduinoCore ... g_analog.c

adafruit_support_mike
 
Posts: 50143
Joined: Thu Feb 11, 2010 2:51 pm

Re: Feather M0 Aref

by muscle75 on Thu May 17, 2018 3:28 pm

Thanks for the responses! I'll be a busy bee for the next couple of days tinkering.

muscle75
 
Posts: 3
Joined: Wed May 16, 2018 12:26 pm

Please be positive and constructive with your questions and comments.