I am trying to read pressure (water level) of a wika sensor that has a 4-20ma output. I put a 250 ohm resistor across the output to read voltage and I get 1v (201-ish) to 5v (1024) volts for "zero and span" when i pressurize the sensor.
Does anyone have an idea or technique for either offsetting the voltage in the program so i can get a true zero or another technique? I am thinking i need to run it through an opamp but would rather do it in my program. I am pretty new at this.
Update:
Well, i tried to add an offset subtracting 201 to get it to go to zero and it did. Then i added a multiplier .168 to get in inches of water with a span of 100" and it seems to work using our amtec meter. Gallons seems to be working too but i have yet to test it in liquid.
Still be interested in other techniques. I seem to pick unorthodox methods of programming since that is not my training.
the solution is a hardware circuit called and op-amp, or better yet is an instrument op-amp.
you boost the strength of the signal
you increase or decrease the output until you get it where you want. in your case 0 volts
then you adjust the gain in order to alter the slope or the span.
the faster way is to get a higher bit count ADC. you only get to use 20%, but 20% of 4096 or 16,000 offers a higher resolution than 20% of a 10 bit ADC.
ElHefe:
I did but I don't want to send it to an output, just to an LCD. Maybe it will work though. I'll play with it, thanks.
'map()' just maps one range of values to another range of values. It has nothing to do with output. If you want to convert 200-1023 to 0-1023, you just do this:-
newVal=map(origVal, 200, 1023, 0, 1023);
What's done with it afterwards is irrelevant to the 'map()' operation.
im not sure about a wika sensor but you may have to watch the span when using a 250 ohm resistor. Most industrial 4-20ma sensors read between 3.8 and 23-24ma. Zero will still be 4ma and span will be 20ma but any reading over span can result in a reading higher than 20ma that will result in a reading over 5v at the arduino pin.
Take a look at the RCV420 from Texas Instruments, it'll give you the adjustments you need for a true 0-5VDC signal from a current loop. The datasheet has many examples you can duplicate.
Use a 51 ohm resistor, and the internal 1.1volt Aref.
Then current can rise to ~100mA without breaking things.
A 1-10k (4k7) resistor between the 51ohm resistor and analogue pin, and a 100n cap from pin to ground could protect further and reduce noise.
Oversampling is a must if you want a better resolution and no weird gaps in the readout.
IMHO adding an opamp to add ~20% is not worth the hassle.
I see (from your code) that you have/want a span of 140psi.
With oversampling, and with Arduino's A/D, expect an accuracy of one decimal place (1400 count).
Leo..
I have tested a 1 bar pressure transducer using my DMM. At no pressure I get 4mA. At 1bar I get 20mA as expected.
Over ranging the sensor above 2bar gives me 32.7mA. This will result in a 8.1volt input to Arduino analog pin. (not good).
However. I connected a series resistor inside the current loop 100ohm. At 4mA I get 0.4 volt. At 20mA I get 2 volt.
At 32.7mA I expect to measure above 8volt...
but I am Not! My DMM highest reading is 2.32volts.
I do not know what to assume of this testing, but using a 4.7volt zener would be good practice.
ElHefe:
I did but I don't want to send it to an output, just to an LCD. Maybe it will work though. I'll play with it, thanks.
Hi,
If you are referring to MAP.
You don't have to send it to an output , you are saving the new scaled value as a variable that you can do anything with in your code, including putting it on your LCD.
Tom.....
Wawa:
Not.
The moment the Arduino is off, only 0.5volt is allowed on the input.
A zener also introduces errors near the knee-point.
Read post#8 again.
That way protects beyond 100mA, and is more stable/accurate than the usual 250ohm resistor.
Leo..
Now it's getting more clear. Thank you.
I will search around for how to set analog ref voltage on single pin. I am using 6 thermistors on the other analoginputs. If reading is not precise I will check out oversampling.
A thermistor with a pull-up resistors is ratiometric.
Supply and Aref have to be the same.
Hard to combine with a current to voltage converter that needs a stable Aref.
Leo..
I have seen that page. Seems like using aref on one pin is not possible.
Currenlty my thermisters is NTC10k with a 10k resistor devider.
From what I understand with using the 1.1v aref and changing my thermistor source voltage to the 3.3v out would not give my correct temperature readings.
I searched google for arduino thermistor with 1.1v aref and could not find anything.
So this leads me to believe that going over to digital temp sensors would be an easier option.
Wawa:
Not.
The moment the Arduino is off, only 0.5volt is allowed on the input.
Ok, while the pressure sensor is on and the arduino is off the sensor will still transmit voltage. At this point when the temp rises will increase the voltage to possibly over the 0.5v input limit when arduino is off.
Will adding a NPN transistor before the pin help, when arduino is off transistor will be off?
Or would this mess around with the readings?
Welsyntoffie:
So this leads me to believe that going over to digital temp sensors would be an easier option.
The DS18B20 temp sensor is easy to use and well supported on this forum.
Welsyntoffie:
Ok, while the pressure sensor is on and the arduino is off the sensor will still transmit voltage. At this point when the temp rises will increase the voltage to possibly over the 0.5v input limit when arduino is off.
Arduino pins have internal clamping diodes to VCC and ground.
The 4k7 resistor limits fault current to a safe value.
Leo..
I have used the DS18B20 sensor in a different project, the one wire bus will save some pins and I do have a sketch ready to extract the sensor address.
I was a bit worried about the effects if the arduino is off. You have cleared my worries.
Thank you for your input on this. Much appreciated.
I have decided not to go digital right now. Using an external adc with 16bits seems more cost effective then replacing a couple of working thermistors and gives better resolution.
Also if anything goes wrong the arduino will be safe?
You could switch to 1.1volt Aref, read the pressure sensor, and switch back to 5volt Aref for the thermistors.
Read the part in the Aref page about the first A/D reading(s) being inaccurate.
So read at least twice and use the last value.
Leo..