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

Analog input fluctuations


  • Please log in to reply
18 replies to this topic

#1 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 06 October 2010 - 12:21 AM

Hello! I am trying to read a thermistor based temperature probe, but the analog input fluctuates too wildly to be useful for my application. I am using a netduino plus that I obtained from maker faire, in case that is somehow relevant.

Any suggestions?

Some notes:
1. I have vref tied to the 3.3v pin
2. I am using a 47k resistor in my voltage divider, with one end to 3.3v, one to ground, and the analog input in the middle
3. The circuit runs are as short as physically possible, with the longest wire (besides the thermistor probe's actual cable) no longer than the distance between 3.3v and vref.
4. Using an external power supply makes the problem much worse - with our without usb hooked up
5. I've tried several external power supplies including rechargeable batteries
6. I've tried also tying all the other analog inputs to ground just in case

I vaguely remember reading somewhere to do something to an analog input pin before using it as an input, but I cannot find that post and think it might be for some other microcontroller. Using a multimeter, the voltage seems much more stable than the analog input would suggest.

Any ideas would be appreciated! Thanks, --Bill

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 October 2010 - 12:35 AM

Hi bill, What sort of fluctuations are you seeing (with the default range of 0...1023)? It's a 10-bit ADC, but it's not uncommon to lose a bit of accuracy with wiring... You really shouldn't see any difference with USB vs. AC power though--since all power goes through the linear power regulators first... Chris

#3 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 06 October 2010 - 12:56 AM

I'm seeing fluctuations +/- 4 'steps' if that is a sensible way to describe it. For example: if the reading should be "610" out of 1024, it is varying from 606 - 614, rapidly. On one of my computers, using only usb power, it fluctuates 1 step, which is fine - but not how I need to use the board. I'm not concerned about the accuracy, but "repeatability" is important. At first I thought it was a noisy power supply, but using a battery (with or without usb) has the same results. If for some reason it might be relevant, I do not have anything plugged into the network jack.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 October 2010 - 01:44 AM

bill, Do you have a trimpot that you can use to see if you get the same type of results there? Fluctuations of a few +/- values on a 10-bit ADC are pretty common, but losing 3 bits of accuracy (8 values) sounds like a power supply related issue. Curious that you saw it with a battery too. What type/voltage of battery? Chris

#5 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 06 October 2010 - 02:16 AM

Trimpot is a good idea, I will try it. I first tested the analog inputs using one, but was not looking for stability, just movement up and down. I just packed up for the night so it will have to wait until tomorrow. I've tried a variety of consumer wall wart 12v power supplies, an 11.1V li-po that was running at about 11.9v, and the last thing I tried before I packed up was a duracell 9V, with the same results.

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 October 2010 - 02:23 AM

Also, which analog input are you using? 0-3? 4/5? Chris

#7 hari

hari

    Advanced Member

  • Members
  • PipPipPip
  • 131 posts

Posted 06 October 2010 - 03:51 AM

I'm seeing fluctuations +/- 4 'steps' if that is a sensible way to describe it. For example: if the reading should be "610" out of 1024, it is varying from 606 - 614, rapidly. On one of my computers, using only usb power, it fluctuates 1 step, which is fine - but not how I need to use the board.
I'm not concerned about the accuracy, but "repeatability" is important.

This is not a solution, but a workaround.
You can use the SetRange(0,100) method of AnalogInput. This would effectively divide it by 10 and masked the fluctuation.
Depending on how accurate the sensor is, you may or may not loose accuracy.

#8 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 06 October 2010 - 05:39 PM

This is not a solution, but a workaround.
You can use the SetRange(0,100) method of AnalogInput. This would effectively divide it by 10 and masked the fluctuation.
Depending on how accurate the sensor is, you may or may not loose accuracy.





I use a temperature sensor from Microchip. This is a short excerpt from a PDF that might be relevant to your issue. I had a very similar problem with my circuit (not with the Netduino but on a standard microcontroller) where everytime I would run motors the analog values would go nuts. I added two resistors and a capacitor to smooth out the noise in the circuit and that made all of the difference in the world...

"IC temperature sensors use analog circuitry to measure
temperature. Unlike digital circuits, analog circuits are more
susceptible to power-supply noise. It is recommended that a
bypass capacitor CBYPASS of 0.1 μf to 1 μf be placed at close
proximity to the VDD and VSS pins of the sensor. The capacitor
provides protection against power-supply glitches by slowing
fast transient noise. However, the effectiveness of the bypass
capacitor depends upon the power-supply source resistance.
Larger source resistance provides RC network with the CBYPASS
and adds a corner frequency to filter out the power-supply
noise. Adding a series resistor to the power-supply line is
adequate to increase the source resistance."

source: http://ww1.microchip...eDoc/21895d.pdf (Page #5)



#9 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 06 October 2010 - 11:18 PM

I have tried a trimpot with the same results. Reading is acceptably stable using usb on my Sony computer. Using an external power supply (a battery), with or without usb, the readings are all over the place. I have tried both A0 and A5. Setrange won't work as i need as much precision as I can get. Power supply can't matter as it glitches when using a different batteries. Any more thoughts? Thanks!

#10 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 06 October 2010 - 11:50 PM

Hey Bill, do you live near a ski resort in Colorado? If so, I think I know you.

#11 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 07 October 2010 - 12:24 AM

Nope! I'm in central NJ. No ski resorts close by that I'm aware of. I'll have to update my profile, there are a couple Bill Frenches out there, some more famous than others. The most famous alive that I'm aware of created Laplink. I'm not that guy, either!

#12 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 07 October 2010 - 02:41 AM

Ah, ok. Wasn't sure since I have a friend with the same name whom is also skilled in this sort of stuff.

#13 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 07 October 2010 - 02:52 AM

Man were you wrong! I'm not in Colorado, near a ski slope, OR skilled! Can't even get a thermistor circuit to work.

#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 07 October 2010 - 07:14 AM

Bill, Do you have an oscilloscope (or perhaps a multimeter)? What does the voltage look like on the VIN header? On the 3.3V header? When on USB power? When on external power? Also--have you thought of using a 5V "USB" power brick--and feeding power in via USB? Chris

#15 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 07 October 2010 - 01:25 PM

No scope (it got stolen years ago... very sad day for me) but certainly a multimeter. The measurements I remember for 3.3V were 3.29V and when using the lipo battery, 11.9V on Vin. My multimeter is pretty cheap, but the readings were always steady. I might be able to borrow a scope tonight to take a deeper look. edited to add: using a usb power brick is another great idea!

#16 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 08 October 2010 - 02:03 AM

Ok I took some measurements and notes:

#.5V...3.3V.VIN.....Powersource
1 4.73 3.29 1.26....PC USB - short cable
2 4.22 3.26 1.08....PC USB via long cables and usb hub
3 4.99 3.30 11.79...Lipo Battery
4 5.05 3.29 1.56....Motorola Droid USB Charger


The only scenario where the analog input has been stable (+/- 1 step) is #2... oddly enough.

I still don't have a scope, so this is the best I can do at the moment.

As a recap, I have a wire going from 3.3V to Vref, and a voltage divider using a 47K resistor and a thermistor. I also have three LEDs for indicators. Attached is a badly drawn schematic.

Any more suggestions? Thanks!! --Bill

Attached Files

  • Attached File  adc.PNG   73.24KB   101 downloads


#17 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 14 October 2010 - 02:08 AM

Well, I've made some progress on my analog input fluctuations.

I borrowed a Rigol DS1052E -- the screen capture is below. I'm still trying to figure the scope out, I've never used a digital one before.

Anyway, is seems only on external power, there's fairly regular pulses of noise on the 3.3V line, regardless if the source is a battery or my 12v regulated supply.

I built the noise reducing circuit in this article, using an inductor and a bunch of caps:

http://www.arduino.c...Lib/Thermistor4

That is the blue line in the picture... so I've at least filtered it out, now, but my readings of the thermistor are certainly slowed.

Any ideas where the pulses are coming from and how to eliminate them, besides the inductor, etc?

Thanks!
Posted Image

#18 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 14 October 2010 - 05:37 PM

Is this applicable to the Netduino? (From the Arduino playground linked above)

For any unused ADC input pins, it's best to set their pullup resistors so they don't mess with
the others (pinMode(myPin, INPUT); digitalWrite(myPin, HIGH)).



#19 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 October 2010 - 06:01 PM

Is this applicable to the Netduino? (From the Arduino playground linked above)

For any unused ADC input pins, it's best to set their pullup resistors so they don't mess with
the others (pinMode(myPin, INPUT); digitalWrite(myPin, HIGH)).


Technically, it's always best to tie unused ADCs to ground. If you try setting them to InputPorts with pullup resistors enabled, let me know if that affects things for you...

Chris




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.