Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

ADC Reading wrong?


  • Please log in to reply
32 replies to this topic

#1 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 May 2011 - 05:15 PM

Hello I am new to the netduino though I do have plenty of experience with the arduino. I am currently having a problem getting accurate analog readings from my pins. I am using a TMP36 to get a a temperature reading when I attach the sensor to my arduino I get the proper ambient readings of about 25C or a reading of 153 from the ADC. But when I plug it into my netduino it reads about 205 and I can not figure out why. I have looked for any documentation and searched for similar problems but have not found an answer. Any help on this would be greatly appreciated seeing as I am kind of stuck at the moment.

#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 08 May 2011 - 08:33 PM

Is the reference voltage the same on both platforms? Regards, Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 May 2011 - 08:48 PM

Is the reference voltage the same on both platforms?

Regards,
Mark

Yes Roughly 700 mV, I am hooking it up exactly the same way as well.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 May 2011 - 09:08 PM

Hi sism3477,

Yes Roughly 700 mV, I am hooking it up exactly the same way as well.

When you say that the reference voltage is 0.7V, do you mean the external AREF or the voltage going to the analog input?

P.S. The allowable external reference range for the microcontroller is 2.7V to 3.3V.

Welcome to the Netduino community,

Chris

#5 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 May 2011 - 09:14 PM

Hi sism3477,


When you say that the reference voltage is 0.7V, do you mean the external AREF or the voltage going to the analog input?

P.S. The allowable external reference range for the microcontroller is 2.7V to 3.3V.

Welcome to the Netduino community,

Chris


The Voltage going into the analog input. Im unsure of how to check the AREF i have a meter handy if you can tell me ill let you know.

#6 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 May 2011 - 09:36 PM

Yes Roughly 700 mV, I am hooking it up exactly the same way as well.


After some research I found that you mention the AREF multiple times and that on the new netduino plus rev. b boards, which I have, include a internal AREF. I have been assuming that the netduino also used a 5v AREF as the arduino does but I was wrong as it is as you stated 3.3v. Now that i know this the math works out properly sorry to waste your time.

#7 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 May 2011 - 12:43 AM

Now that I have the proper VREF the only problem that I am having is that the readings bounce all over the place. From 85-65F after i calculate it or 210-230 ADC value its reading. I have tried using the Internal VREF as suggested in another thread and the external VREF by connecting the 3.3v pin to VREF and it still dosnt keep it from floating. Any ideas what could cause this?

#8 Michel Trahan

Michel Trahan

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts

Posted 09 May 2011 - 12:51 AM

the only problem that I am having is that the readings bounce all over the place. From 85-65F after i calculate it or 210-230 ADC value its reading.

I found that it takes about 10 seconds for the values to stabilize

Any ideas what could cause this?

Could it be that the current heats things up and it takes a while for everything to stabilize ?
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !

#9 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 May 2011 - 01:04 AM

Now that I have the proper VREF the only problem that I am having is that the readings bounce all over the place. From 85-65F after i calculate it or 210-230 ADC value its reading. I have tried using the Internal VREF as suggested in another thread and the external VREF by connecting the 3.3v pin to VREF and it still dosnt keep it from floating. Any ideas what could cause this?


The problem is that the values never stabilize they they jump very rapidly. This is a copy of the feed look at field two. I had it set to update every 5 seconds to get more data. Here is a link http://api.thingspea...I0VEBVMVFVVFCXH

#10 Michel Trahan

Michel Trahan

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts

Posted 09 May 2011 - 01:29 AM

I looked at it using http://api.thingspea...ls/637/charts/2 and it looks relatively stable ... have you tried to see the average over a couple of readings to eliminate the jitter ?
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !

#11 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 May 2011 - 01:37 AM

I looked at it using http://api.thingspea...ls/637/charts/2 and it looks relatively stable ... have you tried to see the average over a couple of readings to eliminate the jitter ?


The problem is im trying to get accurate readings. The arduino's readings are much more stable. Looking at the chart doesn't do it justice how off it is because of that -6.3 spike you see.

#12 KodeDaemon

KodeDaemon

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 09 May 2011 - 01:58 AM

The problem is im trying to get accurate readings. The arduino's readings are much more stable. Looking at the chart doesn't do it justice how off it is because of that -53 spike you see.


Are you powering via USB? I believe it works fine when using external power supply other than USB. I am unsure if this is an issue with certain USB ports or all.

#13 Michel Trahan

Michel Trahan

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts

Posted 09 May 2011 - 02:03 AM

Are you powering via USB? I believe it works fine when using external power supply other than USB. I am unsure if this is an issue with certain USB ports or all.

Indeed, it was stable when powered by an external 9V
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !

#14 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 May 2011 - 02:25 AM

The problem is that the values never stabilize they they jump very rapidly. This is a copy of the feed look at field two. I had it set to update every 5 seconds to get more data. Here is a link http://api.thingspea...I0VEBVMVFVVFCXH


I just tried it again using the a 12v power supply and it gives the same results. I cleared the previous data and have it updating now.

#15 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 09 May 2011 - 04:42 AM

The VRef is 3.3V and the ADC quantization is 1024 steps: it means that each step is worth about 3mV.
You should expect a jitter of at least +/-1 step on the best chance.
On the other side, it is easy having noise on the supply and on the ADC input itself: that could count for several steps high and low.
Assuming you don't own a scope to analyze where is the noise, I'd suggest to apply a digital-filter to the ADC readings.
Often I use this formula:

Vnew = (Vold * (N-1) + ADC) / N

Where:
  • ADC is the current reading;
  • Vold is the result at the previous calculation;
  • Vnew is the current result to keep as were the ADC unfiltered;
  • N is a constant and it is a kind of "responsiveness"-factor: the higher is the slower will react to a change: I'd try from 3 to 8.

Bear in mind that:
  • the sensor itself it is NOT responsive to a temperature change, so don't be worried about the slowness of the function;
  • just use floats in the formula, even the ADC is given as an integer: the calculation using integer could not converge properly. However you may cast to int after the Vnew has been calculated.
Cheers

PS: I built some circuit based on the ADC reading and I have some suspect on the accuracy of the hardware/firmware around the ADC itself. So, perhaps, it could not your fault all that jittering.
Biggest fault of Netduino? It runs by electricity.

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 May 2011 - 10:13 AM

Odd question, but if you flash your Netduino Plus with the regular Netduino firmware (bootloader using SAM-BA and then the .NET MF runtime using MFDeploy)...do you get more consistent results? Chris

#17 ThingSpeak

ThingSpeak

    Member

  • Members
  • PipPip
  • 13 posts

Posted 11 May 2011 - 03:00 PM

If you want to use the ThingSpeak API to normalize the data you have some options. Just add to the query string some additional parameters: average=10 (this will average the data into 10 minute increments) median=10 (this will take a median) You can also set some ranges, so you can filter out data that does not fall into a range you are interested in or to filter our bogus data. As an example... min=100 max=200

#18 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 11 May 2011 - 08:12 PM

If you want to use the ThingSpeak API to normalize the data you have some options. Just add to the query string some additional parameters:

average=10 (this will average the data into 10 minute increments)
median=10 (this will take a median)

You can also set some ranges, so you can filter out data that does not fall into a range you are interested in or to filter our bogus data.

As an example...

min=100
max=200


I understand that I can use thingspeak can do this but this is not something I want to do in software. The netduino's hardware should not be giving such noisy readings with such a simple sensor. I have yet to find a solution for this but I don't want to move forward on any of my projects while I am questioning the accuracy of the ADC.

#19 sism3477

sism3477

    Member

  • Members
  • PipPip
  • 12 posts

Posted 12 May 2011 - 12:49 PM

Odd question, but if you flash your Netduino Plus with the regular Netduino firmware (bootloader using SAM-BA and then the .NET MF runtime using MFDeploy)...do you get more consistent results?

Chris


Ok I finally got a chance last night to flash my Netduino Plus with the regular netduino firmware as you suggested and now the readings are perfect. So does that mean this is a firmware issue?

#20 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 May 2011 - 02:05 PM

Ok I finally got a chance last night to flash my Netduino Plus with the regular netduino firmware as you suggested and now the readings are perfect. So does that mean this is a firmware issue?


That's very helpful feedback.

The analog inputs do not block the Ethernet interrupts when they measure readings. We may need to tweak this so that all interrupts are disabled temporarily. That's not a bad thing to do if we're conducting a quick operation--but for extended readings it could be troublesome.

We'll explore it. Thank you again for the testing.

Chris
  • sism3477 likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.