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

How do you convert potentiometer values to voltage?


  • Please log in to reply
3 replies to this topic

#1 jasperbagyenyi

jasperbagyenyi

    New Member

  • Members
  • Pip
  • 2 posts

Posted 22 February 2013 - 09:04 PM

Hullo guys. I would like to convert my potentiometer readings into voltage..

This is my method. 

            sensorValue = potentiometer.Read(); // get the potentiometer reading.... Double Vxx = sensorValue * (1.0 / 1023) * 3.3; // convert to voltage String displayValue = Vxx.ToString();

Before doing the conversion, it displays the values i want(usually between 0 and 1023), but when i convert, everything goes wrong. instead of getting a value btn 0 and 3.3, i get funny values. I'd be glad for your help. Thanks.



#2 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 22 February 2013 - 09:09 PM

Hi,

 

Not sure, but it might be a missing .0 on 1023.

Or, maybe you need to cast the sensor value to floating point in the scaling operation.

 

Coming from a world where numbers are fixed point I normally multiply first, then divide to ensure the best accuracy.

Paul



#3 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 22 February 2013 - 09:53 PM

if you use the ms analog class just read - returns a single from 0-1 .. where 0 = 0% and 1 = 100%

multiply it with 3.3 and you have the voltage.

 

like its value is 0.5 = 50% = 1.65v



#4 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 22 February 2013 - 09:57 PM

btw: if you really _have to_ use the sl class (or used readRaw on ms class) the correct formula is:

Single voltage= sensorValue * (3.3f / 1024f);






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.