Analog pins not accurate
Started by bene331, Jul 30 2011 10:20 AM
4 replies to this topic
#1
Posted 30 July 2011 - 10:20 AM
When applying steady voltage in the range of 3.3V to the analog pin I get no steady readings in the digital converted value.
The Netduino is a revB board and the AREF is also coubled to the 3.3V internal supply on the board.
The code attached
#2
Posted 31 July 2011 - 01:42 AM
When applying steady voltage in the range of 3.3V to the analog pin I get no steady readings in the digital converted value.
The Netduino is a revB board and the AREF is also coubled to the 3.3V internal supply on the board.
The code attached
private int read_a(AnalogInput readport) { int avg = 10; int[] a_data = new int[avg]; int average = 0; string readresult = ""; for (int i = 0; i < avg; i++) { a_data[i] = readport.Read(); average += a_data[i]/avg; readresult += a_data[i].ToString() + " " ; } Debug.Print(readresult); return average; }
I think this is wrong because of these values:
476 473 474 474 477 473 476 475 475 476
bat1_a 470
when it should return 474.9 or 475 if you prefer.
So try this:
private int read_a(AnalogInput readport) { int nums = 10; int total = 0; double average; string readresult = ""; for (int i = 0; i < nums; i++) { int temp = readport.Read(); total += temp; readresult += temp + " " ; } average = temp / nums; Debug.Print(readresult); return (int)average; }if you want to round up then do: return (int)(average + 0.5);
Let me know if those averages are accurate then.
Sorry I had to leave you this morning, I had to get to the airport.
#3
Posted 31 July 2011 - 04:15 AM
Hello Bene331 and welcome here.
Do you own a Netduino Plus? If so, be sure to unplug the Ethernet cable. It's a known issue that the ADC readings are not stable when the cable is plugged in.
However, a good average algorithm would be a workaround for that issue.
Cheers
Biggest fault of Netduino? It runs by electricity.
#4
Posted 02 August 2011 - 10:04 PM
Hi Both -You are right about the average is not correct as the values are cut on the /10 before summed. But this was not in my focus (it was a leftover from when the range was -30000-30000). I worry about the different readings as it mean 3 digits less accurange for the value.
I have no ETH cable attached even the LAN stack is initiated. It is my plan to have the LAN connected in normal run. So I can't fix it by removing the LAN cable.
More investigation shows:
Using USB power supply the 5V is pretty steady on my oscilloskope but the 3.3V is jumping a little. Something like 96mV. This to blame the IC doing 5V to 3.3V conversion on the netduinoplus.
Removing the USB cable, adding power to the whole setup on a 7V powered L7805 also the 5V is jumping +-100mV on a 92KHz freq.
This should be the course of the trouble.
The L7805 alone is pretty steady when no current is drawn from it.
Trying to adding LAN cable does not seem to add more problems.
There is already capasitors on 0.1uF included on the 5V power lines - I will try to add another 1.5uF to the 3.3V.
Also it could give some meaning to remove the Aref 3.3V connection to the jumping 3.3V on my father board. I try that also.
...
...
It didn't help more than just a little. Still 1% fluctation.
Then I discovered that when removing the display from the set the error was cut down to 0.2%
The Display is a standard 2X16 char monocrome. Current needed is 10mA. Powered from 3.3V on the netduino should be OK. But it is now known that it makes noice on the Aref. Affecting the analog readings.
I have to make some more noice protedtion when the display shall also be running.
All thise words to conclude that mixing analog and digital is a cocktail for the real guys.
#5
Posted 03 August 2011 - 03:39 AM
Bene331, there are at least three factors involving the accuracy of the reading:
However, an average must be applied.
Cheers
- the proper ADC accuracy, that is +/-4 LSB (see specs);
- the stability/accuracy of the Vref, that is depending on the external hardware (96mV are about 30 LSB);
- the error introduced by the ETH cable, that is proven issue.
However, an average must be applied.
Cheers
Biggest fault of Netduino? It runs by electricity.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users