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

Is my netduino faulty? Simple analog test = 1023 constant :(


  • Please log in to reply
14 replies to this topic

#1 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 08 March 2012 - 10:33 AM

Hi, This is my first post and I've had my netduino now for around 3 weeks and I've now got a problem with all my analog sensors always reading 1023 when I connect for example a simple LDR. The example setup I'm using is: LDR - 3.3V LDR - A0-A05 (tried all ports) When I read the analog it's always coming back with 1023 and it's doing it for a number of other analog sensors also now. The issue is I'm very sure that it never used to do this and I remember getting it working before with the above exact setup. I've read other posts on this forum about connecting 3.3V to the AREF port (I've not tried this yet) but I thought the Netduino had a default AREF? Is there a reset I can do to get this working without now having to use the AREF port? As I said I've had it working with AREF use before so not sure what's changed. Any advice whould be much appreciated.

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 08 March 2012 - 12:41 PM

Hello Xocai, and welcome to join the community. the very first thing I would do, is measuring the voltage (respect to ground) on any of the analog input. You should use a multimeter. If the voltage is falling in the range 0...+3.3V, then the cause could be on the AREF. I own the REV.A board (printed on a corner), and I must connect the AREF pin to +3.3V, to make the analogs working. There's a difference on the REV.B, and -if I remind well- you don't need that wiring. Please, check the above and keep us informed. Cheers
Biggest fault of Netduino? It runs by electricity.

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 March 2012 - 05:02 PM

Hi xocai, Hmm, very odd. As Mario suggested, I would try measuring the analog voltage of your sensors. I would also double-check the power and ground connections to your analog sensors, to make sure that they're connected properly. Finally, try putting 3.3V power (from the 3V3 header) into the AREF pin and see what happens... Chris

#4 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 08 March 2012 - 05:49 PM

Hi, Thanks for the suggestions. I have a Rev B board I've discovered. Some trial and error when I got home made me discover the LDR works in that it reads 1022 and when I put my hand over it, it goes down to 900 (not very wide range but better than nothing). I've since wired a variable resistor and turning this from min to max has a range of 0 to 1023 so I'm happy to find it's working as should. I did however notice it's varying between when reading the same resistance by as musch as 20 when reading the value, is this normal? I'm going to be using this to detect infra-red and so ideally need stable figures. I tried using the AREF as suggesting thinking it would normalise the figures but still get fluctuations. Thanks for all your help and suggestions by the way. I must say other than having minor issues like this I'm very happy with my netduino and since I'm a C# developer in my job I'm really looking forward to writing some good software.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 March 2012 - 06:34 PM

Hi xocai, Are you supplying 5V or 3.3V power to the sensor? [You'll want to make sure to supply 3.3V.] I'd recommend taking a couple of readings and averaging them. That's pretty common for analog inputs on MCUs, especially when there are other sporadic current draws in the system (such as networking). Chris

#6 Bainesbunch

Bainesbunch

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationFrance

Posted 08 March 2012 - 07:54 PM

Hi,

You might want to try adding a simple digital low-pass filter to the output of the ADC to remove the noise..

This is an example of one that I am using in some inclinometer readings to remove the high frequency stuff and just give me the filtered version of the signal.

i have attached the code here to Attached File  Lowpass.vb   844bytes   1 downloads



Imports System

Public Class LowPassFilter

	Private m_Top As Double
	Private m_Cutoff As Double
	Private m_Value As Double

	Public ReadOnly Property Value() As Double
    	Get
        	Return m_Value
    	End Get
	End Property

	Public Sub New(ByVal cutoff As Double)
    	Me.New(cutoff, 0)
	End Sub

	Public Sub New(ByVal cutoff As Double, ByVal initialState As Double)
    	If cutoff > 0.75 Then
        	Throw New ArgumentOutOfRangeException("cutoff should be less than 0.75")
    	End If
    	m_Cutoff = cutoff
    	m_Top = 1 - m_Cutoff

    	m_Value = initialState
	End Sub

	Public Function Update(ByVal value As Double) As Double
    	m_Value = (m_Value * m_Top) + (value * m_Cutoff)
    	Return m_Value
	End Function

End Class



You call "update" each time you take a reading passing the raw reading to the filter and then use the "value" property of the filter to get the filtered value.

You instantiate the class object with either just a cut-off value or both a cut-off value and an initial value.


Have fun and I hope this helps :D


<edit for additional ideas >

One way to make this smoothe is to put your code that reads and updates the filter into a thread of its own. You can put a small thread sleep of say 100ms. The faster you read the adc the better the noise rejection of the filter. I have some examples of how I do this in my inclinometer code if you would like to use them drop me a MP and I will send you the code.

<edit end>

Cheers Pete.
I was going to change the world, then I discovered Netduino.
The world will have to wait.

#7 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 08 March 2012 - 11:47 PM

Wow didn't expect to get so many replies, thanks!. Chris, I'm definitely using 3.3V and not 5V. I believe the port is 5.5V tolerant and that anything over 3.3V will just read high. I think it might be the LDR at fault in reading the top of the range and will try other sensors to get an idea of what I'm dealing with. Pete this code looks exactly like what I've been looking for, thanks! I'll give it a go this weekend with my Infra-red sensors. Xocai

#8 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 09 March 2012 - 04:21 AM

Sorry for being in late, but you should add a resistor to the ground as well. Otherwise there's no current (too few) flowing through the LDR. Basically, you should create a voltage divider, using the LDR and another resistor. To value of this resistor could be hard to guess without the LDR specs. I suggest to use a trimpot of 1 Meg: one lead to ground, and the cursor to the analog input. The other lead has to be free. The digital filter is also a good suggestion. Cheers
Biggest fault of Netduino? It runs by electricity.

#9 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 09 March 2012 - 06:00 PM

Hi All, I've been doing some testing with my IR Compound Eye from http://arduino-direc...ct_detail&p=249 and I have the issue that when I connect the IR sensors to any of the netduino analog inputs they all read 1023, I read them all at the same time. I can't power this off the netduino as the IR compound eye needs decent current to power the IR emittors but I'm not currently using them. I've attached my setup diagram (but put a potentiometer where the eye goes). I've checked the supplied battery voltage in with a multimeter is 4.8V and if I connect my multimeter to the cables running to the netduino A0 and GND I read between 2.8V in bright light and 0.8V when I cover the sensor so I know the voltage is in the correct range. It's really confusing as the Analog inputs work fine off the 3.3V with other sensors. I've read on this forum that putting 5V on any analog input does this but I know for a fact I'm putting between 0.8V and 2.8V nowhere near 5V. Is this a known issue? Or am I doing something completely wrong? Thanks Xocai

#10 Bainesbunch

Bainesbunch

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationFrance

Posted 09 March 2012 - 07:34 PM

Do you have or have you used "Fritzing". Website

It is an excellent tool for designing circuits and sharing them with others.

It has a breadboard build platform that allows you to design your system using a visual interface.

If you get this and design your idea using it you can share the .fz file here on the forum and other can modify it and send it back to you.

This may help us to understand the way you have things wired up and make suggestions on how to fix it.

Cheers Pete.
I was going to change the world, then I discovered Netduino.
The world will have to wait.

#11 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 09 March 2012 - 07:54 PM

I thought I attached the fzz file but just realised it's not an allowed type. Here is my circuit with the above issue I described. Thanks.

Attached Files



#12 Bainesbunch

Bainesbunch

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationFrance

Posted 09 March 2012 - 08:12 PM

Hi, This is showing a pot not your IR LED. What is the resistor bridge for ? If you Zip up the FZ file it should load to the forun OK :) Cheers Pete.
I was going to change the world, then I discovered Netduino.
The world will have to wait.

#13 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 09 March 2012 - 08:34 PM

Hi, I've attached the FZZ file as a ZIP. The IR Compound Eye is not a component in Fritzing so I replaced it with a POT. The left wire being ground, the second wire being IR Sensor output and right wire being Positive. When I connect the middle wire (sensor output wire) and ground wire directly to a voltmeter instead of the Netduino all the Analog pins register as 1023, despite when measuring the directly with a multimeter the voltage is between 0.8V and 2.8V depending upon if I cover the IR sensor or not, so I know the sensor on the IR Compound Eye is working. Thanks, Xocai

Attached Files



#14 Bainesbunch

Bainesbunch

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationFrance

Posted 09 March 2012 - 09:16 PM

Hello, The file was not attached :( Can you try tying all the analogue ports you are NOT using to ground and re-try the mesuments on the port again. You should be seeing 0 on all the ports tied to ground and you should only see a value on the port you have the sensor attached to. Cheers Pete.
I was going to change the world, then I discovered Netduino.
The world will have to wait.

#15 xocai

xocai

    New Member

  • Members
  • Pip
  • 7 posts

Posted 09 March 2012 - 09:29 PM

Thanks, I've now uploaded it :)

I'll try and ground all the other pins also.

Xocai

Hello,

The file was not attached :(

Can you try tying all the analogue ports you are NOT using to ground and re-try the mesuments on the port again. You should be seeing 0 on all the ports tied to ground and you should only see a value on the port you have the sensor attached to.

Cheers Pete.






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.