arduino 4-20ma input
These are extremely robust and actually very easy to use. Even if you just want to interface it with an Arduino, all you got to do is add a voltage drop, resistor 250 ohms. We have whatever battery doesn’t matter. Doesn’T matter goes into the sensor itself, then through here, whatever amperage is going through here. We’Ll have a certain voltage drop. You got a size this so it’s. A maximum of 5 volts voltage drop then on the negative side goes to ground on the positive side of the resistor. Here, as you can see, the positive side of the resistor goes to analog input 0, whatever, whichever one you want, and then this gets plugged into your computer, you can fuse it reads off the values: easy peasy. Let me gentleman welcome back to the shop today. I’M. Going to show you how to use 4 to 20 mili amp sensors with an Arduino. Previously, we saw how to fabric on a remotely powered pressure transducer what outputs analog voltage and we read that both with a multimeter and with the smella scope perfect great for data logging. However, how are we going to do instrumentation that does not have the analog voltage output, but has current output without the need for obfuscation through technical minutia to make ourselves feel smarter, it’s? Actually, quite simple. You see here on these 4 to 20 mili amp devices there’s only two pins, two pins can’t – be that complicated to hook up so the difference between oh well, this one’s, then this one’s a current device, current loop device as well, but the difference between analog voltage Out the 0 to 0.
5 volts to 5 volts is that these are less susceptible to noise and also less susceptible for longer runs of instrumentation cable, less susceptible to voltage drop. So these are quite a bit more robust but there’s a little bit of fancy to stuff, and we got to do in order to use that for the Arduino. Well, bear with me if memory serves and most of the time, the vast majority of the time it does what we’ll do is: we’ll have a power supply here, cetera 24 volts, because I remember these numbers and we have a in Arduino microcontroller here. This will read this as an analog to digital converter and it can take up to 5 volts in then it it reads that that voltage, if it’s, 1, volt or 2 – and it assigns a numerical value to it. So this can read between 5 and 0 volts. How are we going to get 20 if we put 24 volts directly into that she’s going to fry, so we have 2 pins on this guy, so we’ll call this the measuring device plus minus and what we can do here. We want this between 0 and no. We want this between 4 and 20 milliamps, so to get 20 milliamps V equals I R, so that means 24 volts divided by X is equal to 20 milliamps. That means I did that wrong. 20 volts divided by 20 milliamps is 250 ohms. So what we do is we put in a resistor here – 250 heat ohms, then what we do is we have the microcontroller read that voltage.
How do we do that? Well, we connect this to an analog input, a 0 and we connect this. This is negative. We connect this to the ground of the Arduino simple. As that a positive goes to pin 1 and and negative goes to 250 ohm resister. I don’t have a 250 ohm resistor, so we just take 3 10 ohm resistors gang them up in series to get our 250. These little booklets, god sent definitely in addition to the bag of tricks and cheap and so useful, ok prior prior to have letting us smoke out of a 40. We know we’ll just do an idiot check here. So that’s the drop resistor there that’s. What we’re going to do is monitor the voltage across that resistor. That will tell us the voltage that the Arduino is going to see, and here we have a current meter and we’re going to see what the current is across that sensor at 0 psi about 24 volts and we are at just about 4 milliamps. So at 0 psi there’s the voltage that the Arduino is going to see 0.9 volts. So we’ve got to stand in here for 24 volt truck battery or system or the piece of gear or whatever. But the interesting thing is you: could you could take two 9 volt batteries? Sticking them together, like Lego, gives you 18 volts and you’re still going to get the same. Reading check this out I’m going to drop this down here as long as we’re within the range that the instrument is designed to work at the sensor is designed to work as we still get the same numbers so we’re going to pop up to 80 psi.
This a 25 bar gave so 25 times, 14 point 7, whatever that is so we’re at 7 and then, if I turn the voltage up to 24 volts we’re at 12 volts there on the supply, we’ll turn it up to 24 volts everything stays the same. So that’s proof that, even if you have kind of a nasty supply, this is where hey, even if it’s a noisy nasty supply in the voltage all over the place. This instrument is still going to work so it’s great for for automotive systems or equipment, or whatever that’s running off of an alternator alternators are very, very electrically noisy. This is robust enough to be able to handle at, and here we go of course, if we had a, we just want to measure this with a multimeter. All we would need to do is put this in series, so we break the connection from one the 24 volt in we break that connection put a multimeter in there and that would show us the current actually I’ll do that we can do that, but if you’re Just measuring voltage, you have a voltage measuring device that’s. What the Arduino analog to digital converter is what we need to do is put in a 250 ohm resistor, no big deal really as long as you got that this is going to have 24 volts in this. Will have the 24 volts negative here? This will go to the Arduino ground negative and this will go into analog.
Oh one, sensing pin so we’ve opened up the Arduino, IDE and analog in serial out. What that’s going to do is measure the analog voltage on a pin and then print that serially to the confused here, so that we can log it based in real, simple. We just made a couple changes. Analog pin is a zero and then we have an integer value. Sensor value equals zero output value equals zero, it initializes the serial monitoring, so it will send signals out. Then we say going through the actual loop, this just loops over and over and over the sensor value equals analog, read and it reads the analog pin that value it takes the voltage and assigns it a value from 0 to 1023, and we say the output value Is equal to the map of the sensor value, whatever the value that was from 100 to 1023, and that will change it over to 0 to 367 PSI? How do we know it’s 360 and that’s, the top scale 25 bar and then zero, of course, is the bottom of the scale. This number here is the best guess you can calculate it, but it’s, probably better, because there’s some there’s some non linearity in the sensor. At the bottom of the scale, it’s better just to guess you just sort of mess around, and here we go once it once it has – that output value mapped, it says serial print psi and then outputs the value and just delays for two milliseconds.
Okay, we’ll open up the serial monitor and we can see minus 21 psi what else going on it’s, because we’re not powering the loop a lot of times you don’t have our power supply. As I said, you could do two batteries 9 volt batteries back by each I’m, going to use this, however, tool battery so zero psi in the gauge we’re going to open the ball valve. I was coming right up now, we’re off by quite a bit, because we actually have something more like 90 psi, so we need to make an adjustment ace. Now we are running into a bit of a problem because of the non linearity of this sensor at the bottom of the scale: 0. 0 psi. So what I’ve gone and done is measured with my nice big gauge, accurate gauge, what the pressure in the tank, as is at this very moment, 66 psi. We are going to apply that to the sensor and see what we get on the serial monitor and what I’ve actually gone and done is I’ve added this serial print sensor, equal censored value, so that will tell us what this guy is actually reading here when it Reads this analog read, pin it will be that value from 0 to 1023, so let’s have a peek at it. Now it’ll start collecting data and we can see it’s at right around 100 and then, when we apply 66 psi it’s only showing 154. So let’s get a couple data points to try and figure out what the hell is going on so because 0 psi in the sensor now we’re going to put 110 psi in there see what it pops up to 190 190.
So what we need to do, then let’s just change. The calibration of this thing, so we go. 190 is 110. That should do it for us, 8.7, 2 milliamps showing 107 108 psi. Ok, well, we’re, getting too much into the pixie wrangling side of things. I give you the broad strokes, that is how you use a 4 to 20 mili amp sensor with an Arduino that’s, how you interface it. What you do with the data coming out of that how you treat it that’s up to you. One thing you can do is you can data log at there’s, little modules and it’ll save it to a common value delineated you can bring it into Excel and also do all sorts of stuff min maxes there’s. Also, if you have a different program on your computer called processing, you can take the serial data from here and actually graph it out that’s a little bit beyond the scope of just simply getting this thing to huge. What I wanted to show you was how to interface these analog, while these current loop devices with common stuff that you might have around the shop so that you can actually use the thing super useful.
arduino 4-20ma input Video
arduino 4-20ma input news
Posted on Wednesday July 19, 2017The 4-20 MA Current Loop Hackaday … Continue Reading »
Posted on Thursday July 13, 2017PLC vs. Arduino for industrial control Control Design … Continue Reading »
Posted on Monday July 17, 2017PLC Vs Arduino Show Down Hackaday … Continue Reading »
arduino 4-20ma input Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr