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

5V sensor with netduino 2


  • Please log in to reply
6 replies to this topic

#1 xmen

xmen

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 31 December 2014 - 08:17 AM

I have a sensor that works with 5V and netduino 2. What I understood so far about its 3 pins.

 

  1. 5v in - from netduino 2
  2. GND - from netduino 2
  3. 0-5V output

I can give it 5V and GND, but I think the output may destroy the netduino 2 if I connect it directly to any analog pin.

 

So, I was searching how would I read its value(analog) and I found Bi-Directional Logic Level Converter. It seems to do what I want, but Im wondering if Im missing something. Any advice would help.

 

 

Thank you.



#2 Stanislav Husár

Stanislav Husár

    Advanced Member

  • Members
  • PipPipPip
  • 99 posts

Posted 31 December 2014 - 10:43 AM

Hi,

 

I don't think logic level converter would work for analog signal. Maybe you could try voltage divider.



#3 Zoot

Zoot

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 01 January 2015 - 03:18 AM

A voltage divider is the way to go on this one.  Here's a link to the theory behind the voltage divider and a handy calculator:

 

http://hyperphysics....ric/voldiv.html

 

Also, this is a pretty good voltage divider calculator:

 

http://www.sengpiela...tagedivider.htm

 

Use calculator # 2.

 

 

According to the datasheet, the input resistance of the ADC is maximum 50k Ohms (If I read it right) so that would have to be taken into account for your measurements to be accurate.  The input resistance would be represented in a voltage divider as RL.

 

You can mess around with the calculator on that page and try different values.  Best to do your calculations to get 3V or 3.3V as an open circuit voltage and hook it to the Netduino.  The voltage will then drop to around the value given for the loaded voltage.  You can then adjust the voltages as necessary.  Remember to disconnect the voltage divider from the Netduino when changing out resistors.  You don't want to brick your analog port.



#4 xmen

xmen

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 01 January 2015 - 05:08 AM

I tried with these, is that alright?

Attached Files

  • Attached File  test.PNG   15.23KB   2 downloads


#5 Zoot

Zoot

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 01 January 2015 - 04:11 PM

You want higher value resistors to limit the current into the Netduino.  Make Z1 10000 Ohms.  Also, make ZL 50000 Ohms to reflect the input resistance of the Netduino.  That will give you a more accurate voltage when hooked up.  Don't forget to test the voltage before hooking it up to the Netduino.

 

You also might want to choose a value for Z2 that provides 3V rather than 3.3V.  3.3V is the maximum for the analog port.  I prefer to use a little less voltage than the maximum for safety reasons.



#6 xmen

xmen

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts

Posted 01 January 2015 - 04:16 PM

Thank you zoot but one thing is bothering me, 2V difference may effect sensor signal output accuracy. Should I use something other than netduino, which works on 5v ? arduino comes in my mind, but since I only need to read analog, I could try something more cheaper.



#7 Zoot

Zoot

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 02 January 2015 - 02:49 AM

Don't think of it as losing 2V.  You aren't really losing any of the span and accuracy of the sensor output signal, you're just scaling it into a voltage that the Netduino can understand and work with.  It pretty common to do this in the analog to digital world, where some of the analog voltages are outside the range at which ADC chips can work.  The input signals have to be adjusted for the ADC chip to use them.  That's exactly what is happening here.  5V becomes 3V, and 0V is still 0V.  You're taking the output range and compressing it slightly, but you still have all of the range represented in the 0 - 3V span of the signal.

 

You'll have to do some translation tricks in the code, like using a correction factor to arrive at the actual value represented by the new voltage, but that can be arrived easily enough by using the ratio of voltages.  In this case 3V/5V = a 0.6 correction factor.  If, in a 5V span, the sensor puts out 3.3V, the new circuit would display that 3.3V signal as 3.3 * 0.6 = 1.98V.  You just have to interpret that in your code the right way.  So if your sensor is saying that it is at 10 PSI when putting out 3.3V, your Netduino will read that same 10 PSI pressure reading at approximately 2V, you just have to teach your Netduino code to understand what that means.

 

To obtain your correction factor, take 5V and apply it to the top of the voltage divider with the divider connected to the Netduino pin.  Measure the voltage on the resistor leg at the Netduino pin.  Take that voltage and divide it by 5 Volts.  Presto, you now have a scaling, or correction factor to use in your code.  To scale downward, multiply by the correction factor.  To scale upward, multiply by the inverse of the correction factor (1/correction factor).






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.