increase sensor to arduino sensitivity

I have a controller that outputs in 4-20mA or 1-5V DC. At 0 it actually puts out .992V and 3.99mA the range on the controller is 0-10000 I am using this code to map the value from an analog input as at 0 on the controller the arduino reads 202 or 203.

map(sensorValue, 202, 1023, 0, 10000)

so by my reckoning that gives only 821 data points on a 10000 range scale. Needless to say accuracy isnt all that great.

What options do I have to increase accuracy? if it helps I will never go above 4500 on the 0-10000 controller scale.

The arduino is wired in parrellel with a 250 ohm .05% resistor and controller to get it to the 1-5V scale.

What options do I have to increase accuracy

Basically you can use an operational amplifier to add a negative offset value to bring things down to 0V and also have a small gain to bring the maximum voltage you expect to receive up to 5V.

Welcome back, I see you managed to source a 250ohm resistor.

You have inadvertantly fallen into the old trap whereby the resolution of your measurement/display unit is an order of magnitude lower than that of your sensor device.

On the basis that the arduino ADC has 1023 points of resolution and you want to scale for a detector ranged 0-10000 it follows that the best resolution you can display from your 10,000 point input is 10000/1023 or just under 10 measured points per arduino point.

However the matter is even worse due to your 4ma / 1 volt zero elevation which equates to 0 input so you lose the first 206 arduino points. In effect therefore your true resolution is 10000/817 or 12.24 measured points per arduino point.

However, you have to be cogniscant of the fact that 1 part in 817 is 0.122%. There are few bog standard sensor devices that can guarantee accuracy or lineraity better than 0.5% so you really should appreciate that the arduino is doing a good job for you - even if you think that a resolution of 12 parts in 10000 is poor.

As Mike says, you could use an opamp with a gain of 1.25 and biased to remove the 1 volt elevation. This will give you an output of 0 to 5 volts for the 1 to 5 volts input. However the limiting factor is still the 1023 point resolution of the arduino.

Smile and accept the limitations of the digital display. Also bear in mind that, if you were using an analogue display 1 part in 817 would be less than the width of half a gnats hair, something that would be impossible to see. One of the problems with the digital age is that we think resolving to the Nth degree gives us better information - nothing could be further from the truth.

Kind regards jack

Awesome thanks guys. I thought that was where I was. Yea old mouser had the resister I needed for $1.21. shipping cost more but I picked up 5 incase I start anymore fires ;) thanks again for that thread. Wouldn't have gotten this far without it.

So.... Basically what I'm hearing is there is no way to make the arduino do more than 1023 data points when using the analog input. or digital?

So that leads me to my next thought. If my controller can output to a digital disply how can I do the same with the arduino. The digital side is 1 or 0 / high or low. not helpful by itself. I'm rambling here but is there a way to turn the arduino into a real voltmeter? if it can somehow read real voltage I can do the math outside of a map command. I'm thinking I saw a thread on that somewhere.

anyway. I think I can live with the 12 point gaps. But when I check my outputvalue against the controllers led display it bounces from 20-50 points above what it should be.

12 points around real tds is ok. 50 starts getting difficult to work with.

I think I will get my real TDS meter and do some testing on how accurate the LED display is before I panic any more.

happy turkey day.

other option is to get the other TDS meter I found that only does 0-4000 range. ;) but I've become such good friends with this one heh.

Microchip as cheaps 12 bits(i think that they have some with even more precision) ADC's.

im special :P I just want to know. Just because. I'm a real noob here. But I assume that my controller just has a bunch of peices and parts from mouser inside it. And an arduino is a bunch of peices and parts from mouser. So why can my controller output a real number but the arduino cant import a real number.

The problem im having is: I need to keep a solution at 1000 TDS. 1000 on the controller.

In my software I give it a range variance of 50. so at 1051 it will turn on one pump and at 949 it turns on a different pump.

Right now I'm seeing differences of 12-50 ish points between my map value and the controllers LED.

That means my pumps will be kicking on and off and my solution will never be where I need it.

Maybe I should finish eating my turkey and think on it some more.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287824219/60
is the thread where we discussed ad nauseum the controller. Sorry didnt think it was relevant.
dont want to bore you.
The controller is to measure hydroponic neutrients yes.
Ah I like the idea of averaging it. I could do that. I only really need to log the level every 30 minutes to an hour. but I could log it every minute via a cron script and then average it to use for deciding whether to act on the reading.
and now heading to the wifes parents for turkey. wish me luck.

The controller is to measure hydroponic neutrients yes.

I looked at the ingrediant list on my disolvable fertilizer, and there were nine soluable compounds listed. A probe would probably have to be pretty special to determine the ppm of any single compound in a solution of this fertilizer. Also the contamination level of nutriant solutions used in plant growing may well be anther issue. One probably could do just as well making a conductivity probe and calibrating it against desired/undesired nutriant solutions.

PPM in hydroponics is hocus pocus. Its a just a bullcrap formula of EC converted to TDS in microsiemens divided by 2. Usually hydro uses the Nacl salt conversion for EC to TDS but there are others.

Im not interested in PPM I'm reading TDS. You are right that its not exact because of the different salts but since TDS/PPM is the measurement we use in hydro its what I have... If the bottle says 1000TDS and you start with RO water at 0TDS you can assume that they were measuring with the same salts.

http://www.octiva.net/projects/ppm/ is a pretty cool site about making your own EC meter. It starts as measuring it just as EC via a volt meter. But then an LCD is attached to give easier readings. (and no 12 point gaps, lol) I bought all the parts for it but i dont have a ociloscope and it got a bit over my head. Also there seemed to be a bunch of guess work. ie maybe change this setting or that setting and I wasnt quite confident in the circut.

I also have a TDS meter that came free in my ZeroWater filter pack. But stealing the readings off the LCD was also over my head.

The controller im using is about $275. And its overkill. I dont need or want the LCD on the front. But it was one of only 2 on the entire interwebs with outputs on them. The other one was over $300.

It seems like if zerowater can give them away free and you can buy them all day with dual sensors for testing in/out for less than $50 I dont see why there isnt anything anywhere with outputs on it for a reasonable price.

ah hmm sampling… i guess i could sample once a minute. or I could sample 20 times in a second. Microchips are faster than my brain…
click goes the light bulb.

in my tests my display on the controller is typically 39-50 points off.
So I cheated. Heres some sample code.

 samples = 0.0;
   for (int i = 0; i < 20; i++)
   {
     temp = ReadFromLTC1298(0x0d); //single ended Ch 0
     samples = samples + temp;
     delay(1);
   }
  
   //now average the 20 samples
   analogValue = samples / 20.0;

i just subtract 39 from the outputvalue and its within a point or so of the controller now.
of course its -39 if the controller says 0. but if it says 0 in my application I have bigger problems and I can adjust for that in software.

But I’m thinking it could be a few things causeing the difference.

  1. noise in the circut as this is all breadboarded and theres a voltmeter hooked up and a bunch of alligator clips.
  2. The controller display is showing a temperature compensated value. and the 4-20 output doesnt do that calculation before outputting. I dont know this to be true but it seems likely. Unfortunately they didnt include a formula to include temp. I’ve requested some info from the manf.

Smile and accept the limitations of the digital display. Also bear in mind that, if you were using an analogue display 1 part in 817 would be less than the width of half a gnats hair, something that would be impossible to see.

orrr maybe I’ll do that :wink:
in real life Ill have the digital display on the controller stuff away where you cant see it.
In the grand scheme of things 39tds is nothing… Not sure what I have my head wrapped around it for. Other than im an IT guy and it doesnt match my thought process. to much variance. I need exact. I may do the opamp and gain route just to satisfy myself that Im at least using all 1023 data points.

Out of interest, how are you going to calibrate the sensor, the measurement circuits, the controller and the 4-20 output driver on your TDS measurement controller.

If you are not then why are you being so pedantic about 1 part in 10,000

If on the other hand you are going to make up or buy calibration samples and use alternative measuring devices such as DVMs then how are you ensuring that they themselves are accurate to 1 part in 10,000 (0.01%)

I trust by now you are seeing the point that I and several others are trying to make.

Unless you have calibrated standards that are directly traceable back to the national standards - which you won't have - then measurement MUST only be considered as a RELATIVE process. As long as you are confident that several measured samples relate to each other in a consistent manner then that is, to all intents and purposes, "good enough".

Working to 1, 10 or even 100 parts in 10,000 is, for applications and equipment such as you are using, impossible to achieve. What makes you believe the sensor, measurement and output systems are either accurate, linear or repeatable. And don't take the manufacturers word for it because at best they will only admit to a 1% total tolerance (100 parts in 10,000).

Individual errors accumulate so at best you might have a system that might be accurate to say 5%. But even that, if consistant, will be good enough for your application.

As to the "bouncing" of your arduino measurement, do the averaging equations as others have suggested. You might also want to fit a pair of capacitors, say 0.1 and 1000 microfarad across the 250ohm resistor. Voltage rating can be anything greater than say 12 volts. These will eliminate high and low frequency noise picked up from either the environment or the controller.

jack

i have calibration solution of 1439ppm designed for labratory calibration. I havent actually calibrated the controller. but its not really relevant. my issue was the discrepency between the controller and the arduino output. my assumption was I would get them to be 1 for 1. I now see why its not really relevant for this application. But still the question remains. how would you in a make believe application get a better resolution? The answer I found after a night of reading was use a 12bit or 16 bit ADC. I found a few online and some code to make it work. In this instance I wont be using it Im ok with the way it is now.

When I finalize the project and attempt to fit everything on a PCB ill worry about actually makeing the tds circut and use a builtin 12bit ADC and suckup 3 analog inputs. Which then leads to learning how to use shift registers to expand the number of inputs available. all fun stuff. thanks for all the help and suggestions.

One point on a calibration graph gives you neither slope nor offset
jack

But still the question remains. how would you in a make believe application get a better resolution?

Resolution is no better than the least accurate input plus a lot of other inaccuracies. You need to determine the limiting inputs and be satisfied with the limited result. Otherwise, roll another doobie and who cares?

Oversampling -- taking a lot of samples and do some statistical analysis Reduce noise -- there is a documented procedure for A2D sampling with the CPU slept Amplify or manipulate the signal to focus on smaller range of values, with greater accuracy -- use an op-amp with an offset and gain to focus on the range of interest Manipulate AREF to focus on different ranges with different accuracy -- eg: measure with AREF=default and if the value is small, measure again, this time with AREF=1.1V.

Expanding to focus on a smaller section of the system span does not increase accuracy, on the contrary it reduces accuracy. This is because system accuracy (% error) is always quoted with respect to full range. By way of example let us say the system accuracy is quoted as +/- 1.5%. If you only look at an expanded 20% of system span then the accuracy of this expanded view is still +/- 1.5% of full range but actually +/- 7.5% of the reduced span. jack

If the sensor is handing you a voltage that is not accurate, then, of course, there's nothing you can do to change that.

But overall inaccuracy can be increased by noise, including quantization error, and the things I mentioned are ways of helping to reduce that part of the overall picture.

As zoomkat said, you can't get better than the worst part. But if the worst part is that the range of interest lay between readings of 513.2 and 513.7 on the A2D input -- ie: a massive quantization error -- then amplifying the signal is going to do wonders.

Otherwise, roll another doobie and who cares?

sold