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 problem


  • Please log in to reply
10 replies to this topic

#1 andrewq2

andrewq2

    New Member

  • Members
  • Pip
  • 3 posts

Posted 14 September 2010 - 11:02 PM

I just got my netduino and I'm starting to try to get analog input and I always get 0 when I read my pin(A0). Do you see anything I did wrong?

My setup looks like this

3.3->AREF

A0->Photo Resistor->GND

public class Program
    {
        public static void Main()
        {
            // write your code here
            InterruptPort tester = new InterruptPort(Pins.GPIO_PIN_A0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            tester.Dispose();

            AnalogInput apin0 = new AnalogInput(Pins.GPIO_PIN_A0);
            apin0.SetRange(0, 100);

            int test = 0;
            while (true)
            {
                Thread.Sleep(250);
                test = apin0.Read();
                Debug.Print("Test: " + test);
            }

        }

    }


#2 klotz

klotz

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts

Posted 14 September 2010 - 11:19 PM

I just got my netduino and I'm starting to try to get analog input and I always get 0 when I read my pin(A0). Do you see anything I did wrong?

My setup looks like this

3.3->AREF

A0->Photo Resistor->GND

public class Program
    {
        public static void Main()
        {
            // write your code here
            InterruptPort tester = new InterruptPort(Pins.GPIO_PIN_A0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            tester.Dispose();

            AnalogInput apin0 = new AnalogInput(Pins.GPIO_PIN_A0);
            apin0.SetRange(0, 100);

            int test = 0;
            while (true)
            {
                Thread.Sleep(250);
                test = apin0.Read();
                Debug.Print("Test: " + test);
            }

        }

    }


You would need another resister to 3.3Vdc to develop a voltage divider. There is no pull-up in the An-in.

#3 andrewq2

andrewq2

    New Member

  • Members
  • Pip
  • 3 posts

Posted 14 September 2010 - 11:23 PM

You would need another resister to 3.3Vdc to develop a voltage divider. There is no pull-up in the An-in.

I'm confused would it look like
AREF+3.3v->resistor(what resistance?)->ground?->photo resistor->A0?

#4 klotz

klotz

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts

Posted 14 September 2010 - 11:41 PM

I'm confused would it look like
AREF+3.3v->resistor(what resistance?)->ground?->photo resistor->A0?

First you need to know what the resistance of the photo resister is. Mine was 25k full dark.
Second you need to decide if you want it to pull-up or pull-down. I used mine in a pull-up.
Then choose a resitance to give you some kind of reasonable current limit, I chose 10K since I just wanted to play.
So using the attached schematic, I put the photoresister in a R1, a 10k in R2, you can try it either way and pick the one you like.

Attached Files



#5 andrewq2

andrewq2

    New Member

  • Members
  • Pip
  • 3 posts

Posted 14 September 2010 - 11:52 PM

Thank you for explaining now i understand. Time to play with my netduino!

#6 klotz

klotz

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts

Posted 15 September 2010 - 12:49 AM

Thank you for explaining now i understand. Time to play with my netduino!

The fun is just begining :D
The next thing you want to do is check out the projects page.

#7 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 15 September 2010 - 03:40 AM

So using the attached schematic...



klotz, what software are you using to generate the schematic? Thanks.---AJB

#8 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 15 September 2010 - 06:06 AM

klotz, what software are you using to generate the schematic?

My guess: CadSoft Eagle (?)

#9 klotz

klotz

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts

Posted 15 September 2010 - 10:55 AM

My guess: CadSoft Eagle (?)


Yep, I use Cadsoft Eagle. But don't ask me for help with it. I am just returning to doing hardware after 40 years and am trying to catch up.I just kindof hack away with Eagle until something works.

#10 EC_dude

EC_dude

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 October 2010 - 06:55 PM

Hi I might sound very dumb here but how do you people come to know of those commands ? I found this thread when i searched for analog input syntax. Is there some documentation or anything which can help me getting familiar with such commands ? PS: I'm a beginner at Visual C# and micro framework.
Difficult I'll do it today, impossible it'll take a bit longer ...

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 October 2010 - 07:48 PM

Hi EC_Dude, For everything other than AnalogInput and PWM, the online Microsoft .NET MF reference is probably the best resource. For AnalogInput and PWM, the forums are the best resource for now...but we're also working on adding them to the "getting started" guide and adding "how-to's" to the projects page. 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.