Hi Ian,The ADC is 0-5v input and your math regarding the steps and values are correct. However you can get better resolution (more steps) by using a routine called map() to map the 1023 steps to any other value, which is a nice feature. By using the map routine I was able to get each step to represent 4 inches of water.
Regarding the sensor accuracy, you are correct with the numbers however I would expect that the error is steady. Since the sensor was just sitting on my workbench the pressure was not changing quick enough to cause a 4 step difference over 1 or 2 seconds.
I think the voltmeter was accurate because the voltage corresponded to the range of steps that were being displayed. In other words, I know that the sensor puts out 1v at 0psi which corresponds to an ADC step of 204.8 on a 1023 step scale. The average ADC reads were in the 212, 213, 215 range which represents +/-14psi. So it looked like the range was correct for 1ATM of pressure which also matched the output of the sensor. The problem was the steps jumping around when the sensor was holding steady.
I tried sampling 20 times a second but found that the sampling was no more accurate than just reading once, after I had gotten the hardware to a point of only producing a 3 step difference. However, I didn't try the algorithm you described which would have smoothed out the results nicely. I knew I could take care of things with software enough to get fairly accurate and dependable results, but it wasn't making sense that the output from the ADC was erratic especially since the temperature sensors were rock steady. If anything, I would expect more variation from the temp sensors than the pressure sensor, relative to just sitting on the workbench while I'm testing the circuit. So I was trying to make sure that I had looked at every possible angle from a hardware perspective before "fixing" things in software.
I'm a software person as well and hate the electronics part. And I can prove I'm no good at it...last night I was getting really weird results. I tested the pressure sensor this morning and I apparently burned it up at some point. The pressure sensor is no longer producing an output voltage. I used both my ac/dc converter and tested it with a car battery to double check.
sigh.... On 10/24/2011 12:38 AM, irox wrote:
Hi Jon, what is the input voltage range of the ADC? If it's 0-5v, which when mapped to a 1-4v scale it gives 819 useful discrete values (0-1v is not used). Each step would represent 1.22 psi. According to the PDF, the accuracy of the sensor is +/-0.5% for the 1000psi range. Which give +/- 5psi error. Or +/- 4 step/discrete values read on the ADC. Unless it's a really high end ADC, you can probably discount the least significant bit. I've found, even when spending $100 on a ADC, if I want 12bit accuracy, buy a 16bit converter. I think what you are seeing would match what I would expect. I guess the read mystery is why the volt meter is showing a stead reading and the ADC isn't. How accurate is the volt meter? What type of ADC is in the volt meter and does the right most digit really count for anything? I tend to kill volt meters, so I buy cheap ones and find the last digit is more for show than use... To really find out what is happen, I would look to borrow an oscilloscope and see what is happening with when hooked up to the Arduino and compare that to the voltmeter. Ultimately, I would just solve this in software (as best as I could). Over sample the sensor voltage (take 100 or more samples per second) and average that. Since the temp sensor are steady (and unlikely to change very quickly), you could sample them once every few seconds and use the CPU cycles for more pressure sensor readings. How many times a second are you sampling? How many times a second can you sample if you didn't do anything else? There is another algorithm I use a lot in situations likes this: - Calculate the your normal wobble/wonder/variation. (call it "W") - Keep the last "X" sample average (X = 100 or how ever many works) - If the delta between the latest sample and average is less than "W" then discard it as noise, otherwise update the average. - Display the average. I normally have to tweak this depending on what I am sampling, how often and accurate I can sample it and what I am doing with the results. Hope that helps. I am mainly a software guy, probably fixing my hardware mistakes with software... Your project looks great! Cheers! Ian.
************************************************************************ ************************************************************************ ************************************************************************ The personal submersibles mailing list complies with the US Federal CAN-SPAM Act of 2003. Your email address appears in our database because either you, or someone you know, requested you receive messages from our organization. If you want to be removed from this mailing list simply click on the link below or send a blank email message to: removeme-personal_submersibles@psubs.org Removal of your email address from this mailing list occurs by an automated process and should be complete within five minutes of our server receiving your request. PSUBS.ORG PO Box 53 Weare, NH 03281 603-529-1100 ************************************************************************ ************************************************************************ ************************************************************************