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

Problem with Analog Input


  • Please log in to reply
13 replies to this topic

#1 Jan Olof

Jan Olof

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationSweden

Posted 08 January 2011 - 09:19 PM

Hi



 public static void Main()
        {
            // write your code here
            
            AnalogInput pin0 = new AnalogInput(Pins.GPIO_PIN_A0);
            while (true) 
            {
            int value=pin0.Read();
            Debug.Print("value " + value);
            Thread.Sleep(500);
            }
        }

If I have nothing connected to A0 or connects it to 3.3V I have a steady 1023 value.
But whwn I connect A0 to GND I get a VERY unstable reading.
Only the USB cable connected to the PC for debugging.

value 0
value 0
value 0
value 63
value 15
value 0
value 0
value 0
value 255
value 0
value 63
value 0
value 0
value 0
value 31
value 127
value 255
value 0
value 0
value 0
value 0
value 0
value 255
value 0
value 255
value 0
value 63
value 255
value 255
value 255
value 127
value 0
value 63
value 0
value 255
value 127
value 0
value 255

I have seen values 511 common and 1023 uncommon!

What is the problem?

/Jan Olof

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 January 2011 - 09:44 PM

If I have nothing connected to A0 or connects it to 3.3V I have a steady 1023 value.
I have seen values 511 common and 1023 uncommon!

Do you have 3.3V connected to Aref pin?

#3 Jan Olof

Jan Olof

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationSweden

Posted 08 January 2011 - 10:09 PM

THANKS! I connected 3.3 V to aref, that solved it. I thought that aref was default switched to the internal 3.3 V, I can see in the schematic that PB24 is aref source control, how can I control that output from my program ? /Jan Olof

#4 Jan Olof

Jan Olof

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationSweden

Posted 08 January 2011 - 11:22 PM

I found this information from Chris in another thread, how to select aref. He also states that internal aref should be default. OutputPort arefSelect = new OutputPort((Cpu.Pin)56, true); // use internal aref But perhaps my Netduino plus is a rev A, hmm looking at the board it says rev A. I thought the Plus boards was all rev B. /Jan Olof

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 January 2011 - 11:26 PM

I thought that aref was default switched to the internal 3.3 V, I can see in the schematic that PB24 is aref source control, how can I control that output from my program ?

Well, the schematics is for the latest Rev. B board, you probably have Rev. A - see the label right to "Analog In" text, just below the Erase pad. For detailed information please have a look at Chris Walker's Netduino, now with internal AREF.

#6 teachop

teachop

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 09 January 2011 - 02:25 AM

the schematics is for the latest Rev. B board

Where is the Rev. B schematic for Netduino Plus found, from the download page I get Rev.A. I can see a circuit for switching aref on the Netduino schematic, but not on the Netduino Plus one.

#7 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 09 January 2011 - 03:52 AM

I am looking to do Analog input with a potentiometer, and I can't make out from this conversation what aref is. Is it ground? Analog reader? or 3.3v out? -cwbh
-Cwbh

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 January 2011 - 06:09 AM

Cwbhx, If your analog sensor outputs 0-3.3V, then connect the 3.3V header on your Netduino Plus to the AREF header. Netduino Plus "Rev B" boards just started shipping to resellers. We'll update the schematics to reflect the new "external AREF" option soon. The Rev A->Rev B changes with the Netduino Plus are identical to the updates we made to Netduino. Chris

#9 Jan Olof

Jan Olof

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationSweden

Posted 09 January 2011 - 10:09 AM

Chris, In your code for switching aref you use OutputPort((Cpu.Pin)56 Pin 56 is PA24 but on the schematic for the Netduino it shows aref source ctrl connected to PB24 pin 70 on the cpu. Before I realised that I had a rev A board I tried with "70" in the code but then I got an exception. Why the ....Pin)56 ? Confused Jan Olof

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 January 2011 - 12:08 PM

Pin 56 = GPIO pin 56. PA0-31 = 0-31; PB0-31 = 32-63 Chris

#11 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 09 January 2011 - 12:27 PM

Why the ....Pin)56 ?

The Cpu.Pin enumeration defines constants for general purpose I/O pins only - PB24 is pin 24 of the second GPIO port PB, so the value is 24 + 32 = 56, where 32 is the number of pins of the first GPIO port PA (*). The numbers in schematics refer to physical pinout, which is package dependent - for example, PB24 is pin 70 in LQFP-100 package, and G2 in TFBGA-100.

(*) Note: The microcontroller has actually only 62 GPIO pins (PA0 - PA30, PB0 - PB30), but the control registers are 32-bit.

#12 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 09 January 2011 - 01:46 PM

cwbhx: here's a thread with a diagram including a potentiometer, if it's helpful.

#13 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 09 January 2011 - 03:27 PM

Yup :D Thanks Bill! It was helpful. P.S. Nice Graphing App :P -Cwbh
-Cwbh

#14 QuickMik

QuickMik

    New Member

  • Members
  • Pip
  • 2 posts

Posted 20 January 2011 - 12:01 AM

Hi all ...

well I have the same problem but I was not able to solve it by using the ARef. As I understand the postings, the ARef thing is only relvant for boards prior Rev.B. Hope I'm right.

I was trying to read MEM gyro sensor values using the analog port. I've got a nearly stable reading for the neutral value of the sensor. The majority of measurements have correct values while some of them are wrong. Only for one step and always the same value.

Is there a way to avoid such a behaviour? If not, does anybody know a filtering to remove those artefacts?

Here are a some of my readings



U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:385 1.246V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:385 1.246V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:384 1.242V
U:385 1.246V
U:384 1.242V






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.