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 Help Needed


  • Please log in to reply
46 replies to this topic

#21 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 22 August 2010 - 05:02 PM

I really should pay more attention to the methods that are available in each class. I wrote my one code to do that recently. ;)

Same here! I copied the map method from the arduino reference page.

#22 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 23 August 2010 - 05:04 AM

We have two updates in the works:

v4.1.0.3 (patch 3):
* Minor updates to deployment/reboot code

v4.1.1.0 (first feature update)
* SD card mounting, file system support
* Expanded PWM support (ability to set clock times, etc.)

A few other things that we're working on:
* Networking capabilities
* Drivers for a number of shields

Chris

Is it possible to get a double from input pin? I feel like an integer is not good precision, or is it already possible?

#23 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 August 2010 - 05:29 AM

Is it possible to get a double from input pin? I feel like an integer is not good precision, or is it already possible?


The AnalogInput (ADC) is 10-bit, so you'll get 0-1023. If you'd like to translate that to a range of doubles, you can do something like this:

// assume a desired range of 0.00 - 100.00
double value;
analogInput.SetRange(0, 10000);
value = (double)((double)analogInput.Read() / 100)

Chris

#24 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 23 August 2010 - 05:32 AM

The AnalogInput (ADC) is 10-bit, so you'll get 0-1023. If you'd like to translate that to a range of doubles, you can do something like this:

// assume a desired range of 0.00 - 100.00
double value;
analogInput.SetRange(0, 10000);
value = (double)((double)analogInput.Read() / 100)

Chris


Yeah, I should have thought of that, as always thanks for the help :D

#25 xc2rx

xc2rx

    Member

  • Members
  • PipPip
  • 27 posts

Posted 23 August 2010 - 02:58 PM

We have two updates in the works:

v4.1.0.3 (patch 3):
* Minor updates to deployment/reboot code

v4.1.1.0 (first feature update)
* SD card mounting, file system support
* Expanded PWM support (ability to set clock times, etc.)

A few other things that we're working on:
* Networking capabilities
* Drivers for a number of shields

Chris


Hi Chris,

It would be very helpful if you could create a new thread and list out every bug found + future patches in progress and which bug/feature will they fix/have. That way it wouldn't be a surprise when a programmer discover a bug and have to report it.

I know you have a thread that sort of list what each patch fixes when you roll it out but would be great if you could list out future patches/found bugs too.

Thanks!

#26 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 25 August 2010 - 05:35 AM

I really should pay more attention to the methods that are available in each class. I wrote my one code to do that recently. ;)


Hi,
How do you get the analog sensor to work any sample driver? I wrote driver for sharp distance sensor and for some reasons the reading remains unchanged.

Thanks!

#27 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 August 2010 - 05:36 AM

How do you get the analof sensor to work any sample driver? I wrote driver for sharp distance sensor and for some reasons the reading remains unchanged.


Hi Hai,

Can you share your code? Also, which analog pin(s) are you using?

Chris

#28 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 25 August 2010 - 08:21 PM

Hi Hai,

Can you share your code? Also, which analog pin(s) are you using?

Chris


Chris,

Here are my wiring, I will update this post with code and photo tonight.

A0->Sensor's Vo
3.3v->Sensor's Vcc
GND->Sensor's GND
code has been removed due to it may trigger legal issue -Hai

Thanks!

#29 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 August 2010 - 07:17 AM

Here are my wiring, I will update this post with code and photo tonight.

A0->Sensor's Vo
3.3v->Sensor's Vcc
GND->Sensor's GND


Hai,

Did you attach the AREF pin to the 3.3V header too? If there's not an analog reference, the analog values will probably all read at their maximum value...

Chris

#30 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 26 August 2010 - 08:21 PM

Chris, You mean connect like this?

Attached Files



#31 greg

greg

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationChicago, IL

Posted 26 August 2010 - 08:33 PM

Chris,
You mean connect like this?


Yup, but see Chris' below. I wasn't looking at that, just the AREF link!

#32 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 August 2010 - 08:35 PM

Chris,
You mean connect like this?


Hai,

You have the sensor connected to digital pin 0 (D0), not analog pin 0 (A0). :)

Chris

#33 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 26 August 2010 - 09:20 PM

Oop! That was just my mistake on my drawing, I was too concern about the beauty aspect of the drawing and forgot about the technical aspect of it. I will try that out tonight. Updated image. By the way, just for my understanding, -What is the AREF pin for and why do I have to cross-connect analog pin to this to get work correctly? -Where else AREF pin is required when working with Netduino? Thanks! Thanks Chris.

#34 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 27 August 2010 - 03:40 AM

Chris I hook it up the way suggested but still didnt see any change on the reading. Any other thought? Thanks!

#35 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 August 2010 - 04:00 AM

-What is the AREF pin for and why do I have to cross-connect analog pin to this to get work correctly?
-Where else AREF pin is required when working with Netduino?


The AREF pin is "analog reference." The analog readings use this as their "maximum voltage" reading. You can make it anything between 2.7V and 3.3V, but basically it helps ensure good readings for your analog sensors.

Chris

#36 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 August 2010 - 04:01 AM

I hook it up the way suggested but still didnt see any change on the reading. Any other thought?


Hai,

AnalogInputs are pretty straightforward, but let's see what else we can find...

1. Can you take a photo of your setup? Just so we can eliminate any obvious questions...
2. Do you have a multimeter? If so, what is the reading on the analog input wire (a) not attached to the Netduino; (B) attached to the Netduino?

Chris

#37 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 27 August 2010 - 04:33 AM

Hai,

AnalogInputs are pretty straightforward, but let's see what else we can find...

1. Can you take a photo of your setup? Just so we can eliminate any obvious questions...
2. Do you have a multimeter? If so, what is the reading on the analog input wire (a) not attached to the Netduino; (B) attached to the Netduino?

Chris


Here is the image, I have multimeter I will post reading result soon

Attached Files



#38 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 August 2010 - 04:54 AM

Hai,

Your AREF is not connected in that photo.

Could you please run your test under the two scenarios that follow?
[a] connect the 3.3V line to the AREF pin in addition to your sensor
[b] if that doesn't work, disconnect the wire from the the RESET line and the wires from analog 1 and analog 2

Chris

#39 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 27 August 2010 - 05:09 AM

Hai,

Your AREF is not connected in that photo.

Could you please run your test under the two scenarios that follow?
[a] connect the 3.3V line to the AREF pin in addition to your sensor
[b] if that doesn't work, disconnect the wire from the the RESET line and the wires from analog 1 and analog 2

Chris


Chris,
Oop, careless mistake I thougth that was AREF pin for some reasons. all three sensors work fine now

Thanks very much for your helps

#40 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 August 2010 - 05:15 AM

Glad all is well for you now. I can't wait to see your project evolve!




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.