AnalogInput.SetRange method
#1
Posted 16 October 2011 - 02:24 PM
#2
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