Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Scaling Analog Ports


  • Please log in to reply
4 replies to this topic

#1 Fred007

Fred007

    Member

  • Members
  • PipPip
  • 25 posts

Posted 16 May 2014 - 04:32 PM

I think I am missing a step. Trying to read a voltage on Analog0 and measured with a meter its 1.77v but when I read in program I get .5079 (float from .Read()) or 2074 from .ReadRaw(). Is there a calibration setting I am missing? I read about having to pull up the AREF but thought on the Plus 2's that is not necessary. Thanks for any pointers.

 

(wont be reading anything beyond 3.3v, had a voltage dividing in the circuit but don't really need it)



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 May 2014 - 05:12 PM

Hi Fred,

If you pull multiple ADC readings, what do they average out to?

2074 = 0.5065 and 0.5079 = ~2080, so I'm guessing that you're seeing a little bit of drift. We included some big caps on the board to help enhance the accuracy of the MCU's ADCs under varying current draws--but microcontroller-based ADCs are generally less precise than external ADCs.

What is the analog device you're measuring?

Chris

#3 jrlyman3

jrlyman3

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts
  • LocationNorth St Paul. MN

Posted 17 May 2014 - 01:28 AM

Fred,

 

I thinik that what you need to know is that the  0.5079 you are getting means 50.79% of your supply voltage.  So you're getting 0.5079 * 3.3 = 1.676v.    This started with NETMF 4.2.  Hope this helps.

 

John



#4 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 17 May 2014 - 02:41 PM

To just add something to John's great answer, the 2074 you're seeing from .ReadRaw() is out of 4095, that is, the ADC assigns 3.3V to 4095 and 0V to 0, which makes your scale a number from 0-4095. So:

 

2074 / 4095 = 0.5065

 

Which is the same percentage of your supply voltage as .Read(). Basically, .Read() does the calculation of fraction of supply voltage for you, while .ReadRaw() gives the raw number the ADC outputs.



#5 Fred007

Fred007

    Member

  • Members
  • PipPip
  • 25 posts

Posted 11 June 2014 - 02:59 AM

Thanks so much for the help, sorry to go dark on this thread. Got distracted with some cloud services stuff. Yes, I realized that i needed to factor the 3.3v supply. The device is a HM1500LF humidity sensor. The code I have for reading the actual humidity is:

 

        private float _referenceVoltage = 3.3f;
 
            double voltage = analogInput.Read() * _referenceVoltage;
            humidity = 0.03892 * (voltage * 1000) - 42.017;    
 
Close enough for what I am doing.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.