Connecting 5v sensors to AnalogInput
#1
Posted 22 March 2012 - 06:11 AM
#2
Posted 22 March 2012 - 06:15 AM
#3
Posted 22 March 2012 - 06:24 AM
Thanks for the quick reply. It just occured to me that the digital I/O is also 3.3V based, which actually cuts out a number of digital sensors I am using as well, so I am rethinking this whole move. Unfortunately, everything I have for this project right now is 5V based (serial LCD, digital sensors, analog sensors).Hi drischar,
A voltage divider would be the first option I'd look at. If that doesn't give you the accuracy you need, you can use an external ADC chip (via SPI or I2C) that can accept 5V analog voltages.
Chris
I assume there is no way I can just force the board to use 5V all over without frying things :-P At this point, I would be converting every device I have.
#4
Posted 22 March 2012 - 06:56 AM
#5
Posted 22 March 2012 - 07:06 AM
There is a relatively easy way to convert 5V <-> 3.3V signal using a MOSFET - see Bi-directional level shifter (pdf) application note or SparkFun's Logic Level Converter to get the idea.At this point, I would be converting every device I have.
#6
Posted 22 March 2012 - 07:46 AM
Given that I can use 5V inputs (I have a few digital sensors that will output 5v), this may still be doable. In total I have:Hi drischar,
If you know that your analogue sensor output will not be above 3.3V, then there is not a problem. (I am using some 5V range sensors whose analogue output is always below 3.3V.)
If you have others that do generate above 3.3V, then the first thing to try is a voltage divider.
Yes, resistors are not 100% accurate, 5% is typical. You can get round this by calibration of the readings, or buying a batch of resistors and selecting ones that are a good match.
e.g. choose a pair that are both +5%, rather than one that is +4% and one that is -3%. That way you get an accurate ratio with inaccurate resistors.
As for digital sensors, 5V input levels to the Netduino are OK.
But, you might have some issues driving devices with the 3.3V outputs.
There are some shields that will convert digital voltages.
Its a lot to take in, but I'll think you will get on with the Neduino.
Hope this helps - Paul
- 2 analog temperature sensors (TMP36, designed for 3.3v so no problem there)
- 3 analog pressure sensors (from freescale, don't recall model but they require 5v)
- 3 swissflow SF800 flow sensors, no input but will output (input on the Netduino) 5v pulses at about 100-300/second.
- BlueSmirf bluetooth modem, which works fine on 3.3v
- 5V serial LCD, which won't work, but I could just get a 3.3v version and use the 5v elsewhere. Of course, my wife thinks I should leave the LCD out completely, so she may get her wish.
Sounds like this can all still work. I don't need to output 5V anywhere, and as long as the 3.3v inputs won't smoke at 5V I might be able to make this.
This is designed to record data from the 3 tap kegerator I have in my kitchen, if I were to run enough CO2 pressure in the lines to raise the analog input over the 3.3v threshold, I would be in danger of bursting my lines, so I might be able to get by just hooking them straight up to the analog pins.
Thanks everybody, I'll let you know how it goes.
#7
Posted 22 March 2012 - 10:13 AM
#8
Posted 24 March 2012 - 09:14 PM
#9
Posted 24 March 2012 - 09:19 PM
To be a little more clear, I relaize I can use a transistor or something to make the 5V communication 3.3v instead, but I've never done something like that with data transmission and I have no idea whether it would work or be worthwhile.Alright. I'm pretty set on making this work on the Netduino, so I've been looking into using external ADCs for the pressure sensors and communicating with SPI. For the temperature sensors (which would have worked on 3.3v), I may switch to 1wire DS18B20 and get rid of using analog sensors for temperature completely which makes it s little easier since I don't have to worry about switching the analog pin and sleeping to let it settle.
In looking at external ADC chips (say, MCP3002), I'm a little confused on how I can make the analog comparison get done at a 5V reference whil the SPI communication takes place at 3.3V. That is, unless I can just run it on the 5V and let is go. If the digital pins (10-13 for SPI) allow 5V in, then this could work, as long as 3.3V out will be good enough for the ADC. It still feels a little kludgy though. A really elegant solution would be a ADC that has two voltage inputs one for the data communication (3.3v) and one for the Vref (5V). Does such a thing exist or will the MCP3002 work out just fine?
#10
Posted 25 March 2012 - 04:13 AM
Alright. I'm pretty set on making this work on the Netduino, so I've been looking into using external ADCs for the pressure sensors and communicating with SPI. For the temperature sensors (which would have worked on 3.3v), I may switch to 1wire DS18B20 and get rid of using analog sensors for temperature completely which makes it s little easier since I don't have to worry about switching the analog pin and sleeping to let it settle.
In looking at external ADC chips (say, MCP3002), I'm a little confused on how I can make the analog comparison get done at a 5V reference whil the SPI communication takes place at 3.3V. That is, unless I can just run it on the 5V and let is go. If the digital pins (10-13 for SPI) allow 5V in, then this could work, as long as 3.3V out will be good enough for the ADC. It still feels a little kludgy though. A really elegant solution would be a ADC that has two voltage inputs one for the data communication (3.3v) and one for the Vref (5V). Does such a thing exist or will the MCP3002 work out just fine?
There's no need of extra hardware to connect the Netduino SPI to the ADC. The ADC chip is able to recognize an high level when the voltage is at least 3.5V: the Netduino gives it at 3.3V, so it's pretty close to the limit...but it should work. On the other side, any discrete input of the Netduino is +5V-tolerant, which means that you can apply a voltage above the nominal +3.3V.
Anyway, before starting to write code and glue various chips, I'd dig a bit deeper around your sensors. It's much like purchasing a box without actually knowing what's inside.
From what I see, the only doubt is about the pressure sensor. Could you get some additional info? Is it a low pressure (e.g. atmospheric), or high pressure (e.g. weight)? Is it possible for you to simulate a "worst case" pressure, and measure the output voltage with a multimeter?
I guess that you can glue any of your devices to the Netduino with a very small effort.
Cheers
#11
Posted 27 March 2012 - 03:30 AM
The pressure sensor that I am using is a Freescale MPX4250GP. Freescale has other sensors, but none that quite meet my requiremnts for pressure range. The idea is that the sensor reads CO2 pressure on a keg of beer which can range from 0 to 30psi (this sensor supports 0 to 36psi). Normally, I would have just about any beer at around 10-15psi which puts the output of the sensor within the 3.3V range (should be... I need to check with a multimeter but my CO2 tank is empty), but in the end it would be best to support the full range, which will require an external ADC. I'll just let the ADC communicate with the Netduino at 5V.There's no need of extra hardware to connect the Netduino SPI to the ADC. The ADC chip is able to recognize an high level when the voltage is at least 3.5V: the Netduino gives it at 3.3V, so it's pretty close to the limit...but it should work. On the other side, any discrete input of the Netduino is +5V-tolerant, which means that you can apply a voltage above the nominal +3.3V.
Anyway, before starting to write code and glue various chips, I'd dig a bit deeper around your sensors. It's much like purchasing a box without actually knowing what's inside.
From what I see, the only doubt is about the pressure sensor. Could you get some additional info? Is it a low pressure (e.g. atmospheric), or high pressure (e.g. weight)? Is it possible for you to simulate a "worst case" pressure, and measure the output voltage with a multimeter?
I guess that you can glue any of your devices to the Netduino with a very small effort.
Cheers
I'm still looking at the MCP3002 (it's the only standalone ADC I can find at Sparkfun). I've never done SPI before, but I'm always up for something new.
#12
Posted 28 March 2012 - 01:27 AM
Alright, I finally picked up the hardware to convert the tubing on my tank down to the 1/8" inside diameter tubing to connect to the pressure sensor. My tank wasn't quite empty (no liquid, but stil enough gas to run a test). I hooked up the sensor, and then eyeballed the values from the guage and I'm pretty accurate according to what the datasheet says I should be getting.The pressure sensor that I am using is a Freescale MPX4250GP. Freescale has other sensors, but none that quite meet my requiremnts for pressure range. The idea is that the sensor reads CO2 pressure on a keg of beer which can range from 0 to 30psi (this sensor supports 0 to 36psi). Normally, I would have just about any beer at around 10-15psi which puts the output of the sensor within the 3.3V range (should be... I need to check with a multimeter but my CO2 tank is empty), but in the end it would be best to support the full range, which will require an external ADC. I'll just let the ADC communicate with the Netduino at 5V.
I'm still looking at the MCP3002 (it's the only standalone ADC I can find at Sparkfun). I've never done SPI before, but I'm always up for something new.
The bottom line is, I don't hit the 3.3V limit until I reach nearly 24psi. At a temperature of 37*F that allows me to put 3.75 volumes of CO2 into a beer and still be able to handle the value on the Netduino ADC. That covers just about any style of beer I will put in there. If I were to put homemade soda, I'd want to raise it to 4volumes, which puts me at 30psi but that would be such a rare occasion I probably dont need to design for it (I can remove the sensor when that happens).
So thanks for all the help. It looks like I'll just be connecting the sensor directly to the arduino, and never raising the guage above 24 while it is connected. To be honest, I'd be afraid of >24psi on that thing anyhow.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users