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

AnalogInput.SetRange method


  • Please log in to reply
1 reply to this topic

#1 RichardE

RichardE

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationNorth Yorkshire, UK

Posted 16 October 2011 - 02:24 PM

I'm starting to play around with the analogue inputs but cannot figure out what the AnalogInput.SetRange method does. I looked at the tutorial for reading a temperature sensor, but the code does not use this method. The comments say that when you read the analog input you get 0 for 0V and 1024 for 3.3V (shouldn't that be 1023?). How does SetRange modify this behaviour? On a more general note - are there any documents describing the Netduino specific classes (such as AnalogInput)? I can find the Microsoft documentation but nothing on the stuff in the SecretLabs namespaces. Might need a book.

#2 MicroGuy

MicroGuy

    New Member

  • Members
  • Pip
  • 3 posts

Posted 05 December 2011 - 08:21 PM

I'm starting to play around with the analogue inputs but cannot figure out what the AnalogInput.SetRange method does.

I looked at the tutorial for reading a temperature sensor, but the code does not use this method. The comments say that when you read the analog input you get 0 for 0V and 1024 for 3.3V (shouldn't that be 1023?). How does SetRange modify this behaviour?

On a more general note - are there any documents describing the Netduino specific classes (such as AnalogInput)? I can find the Microsoft documentation but nothing on the stuff in the SecretLabs namespaces. Might need a book.


Just playing around with the SetRange it appears that it maps the 0-1023 raw adc count into a new range that you specifiy.
For example setting min = 100 and max = 200 would map a raw adc count of 0 to 100 and a Read count of 1023 would map to an Read count of 200.

Like this:
Raw acd Default Range SetRange(100,200) SetRange(500,1000)
-----------------------------------------------------------------
0 0 100 500
512 512 150 750
1023 1023 200 1000

Hope this helps




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.