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 voltage inconsistent when use USB versus battery


  • Please log in to reply
8 replies to this topic

#1 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 03:12 AM

Chris, There seems to be an issue when using analog devices on USB cable versus External battery. When running on 5VDC (in conjuntion with AREF) -voltage from netduino->analog device measured=4.90vdc (if using USB cable) -voltage from netduino->analog device measured=3.66vdc (if runs on external battery) When runing on 3.3VDC (in conjuntion with AREF) -voltage from netduino->analog device measured=3.27vdc (if using USB cable) -voltage from netduino->analog device measured=2.80vdc (if runs on external battery) This result in wrong signals. Could you verify. Thanks!

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 August 2010 - 03:19 AM

Hello Hai, Could you please give me more details on this? How are you powering the Netduino (which connectors/pin headers), and where are you reading the voltages? Chris

#3 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 03:21 AM

Hello Hai,

Could you please give me more details on this? How are you powering the Netduino (which connectors/pin headers), and where are you reading the voltages?

Chris


Chris, you woke me up with that question, I power netduino via FEZ interface card, may be that is the reason, let me strip it naked and test again. Will let you know soon

Thanks!

#4 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 04:19 AM

Chris, you woke me up with that question, I power netduino via FEZ interface card, may be that is the reason, let me strip it naked and test again. Will let you know soon

Thanks!


Chris,
I removed extra parts, and connect 4.5V battery directly to Vin, GND. Turn it on, I measure voltage going to the analog sensor 3.0v instead of expected 3.3v. is that right?

What so strange about this was my robot has two 2 analog sensors in the front, whenever i powered the board with laptop's USB cable, and operate the robot on debug mode, it works just fine. but everytime I tried to run on a external battery powered, it failed due to some sort of unexpected analog reading...

basically what the robot does is when an object near to the robot, the robot would stop and reverse. now the robot stops and reverses everytime without going forward whenever netduino is powered by an external battery which indicates front analog reading is invalid, I dont have LCD so I cannt see what the value are

#5 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 04:59 AM

Hi Chris, I think I sorted out the issue, I used 3 sensors, two of them may not have correct driver/incompatible with Netduino, or whatever that reason is. They are: Sharp 2Y0A21, The one that is working fine is: GP2D12. Strange thing is when operate on USB powered netduino, they works just fine, just on battery, how does that sound logical? Here is driver I used. If anyone have any idea how to make these two work for me, would be appreciate! using System; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; namespace SecretLabs.NETMF.Hardware.Netduino.Drivers { class DistanceDetector: IDisposable { AnalogInput port; float Y0 = 0; float X0 = 0; float Y1 = 0; float X1 = 0; float C = 0; public enum SharpSensorType : byte { GP2Y0A21YK = 0, GP2D120 = 1, GP2Y0A21 = 2, } public void Dispose() { port.Dispose(); } public DistanceDetector(Cpu.Pin pin, SharpSensorType type) { InterruptPort temp = new InterruptPort(pin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); temp.Dispose(); port = new AnalogInput(pin); port.SetRange(0, 100); switch (type){ case SharpSensorType.GP2Y0A21YK: Y0 = 10; X0 = 315; Y1 = 80; X1 = 30; break; case SharpSensorType.GP2D120: Y0 = 3; X0 = 315; Y1 = 30; X1 = 30; break; case SharpSensorType.GP2Y0A21: Y0 = 20; X0 = 315; Y1 = 80; X1 = 30; break; } C = (Y1 - Y0) / (1 / X1 - 1 / X0); } public float GetDistance() { return C / ((float)port.Read() + (float).001) - (C / X0) + Y0; } } }

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 31 August 2010 - 05:23 AM

Chris,
I removed extra parts, and connect 4.5V battery directly to Vin, GND. Turn it on, I measure voltage going to the analog sensor 3.0v instead of expected 3.3v. is that right?


Hai,

Vin is rated for 7.5VDC-12VDC (although it will handle ~6.5V-20VDC). The USB input is connected to the 5VDC "regulated" power pin. I'd generally recommend providing a 5VDC regulated input to the 5V pin header...but if you're providing a clean 4.5VDC regulated power input you're probably alright plugging that in as well.

But don't plug your 4.5V battery into Vin...it will run thorugh two LDO power regulators (each dropping it ~1VDC) before reaching the Atmel MCU--which is out of spec.

Does that answer the question well?

Chris

#7 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 05:50 PM

Hai,

Vin is rated for 7.5VDC-12VDC (although it will handle ~6.5V-20VDC). The USB input is connected to the 5VDC "regulated" power pin. I'd generally recommend providing a 5VDC regulated input to the 5V pin header...but if you're providing a clean 4.5VDC regulated power input you're probably alright plugging that in as well.

But don't plug your 4.5V battery into Vin...it will run thorugh two LDO power regulators (each dropping it ~1VDC) before reaching the Atmel MCU--which is out of spec.

Does that answer the question well?

Chris


Chris,
That explained why, I thought the 5VDC pin is output pin the same fashion as 3.3V pin. I should have read netduino's manual before even plug it in :-), but anyway, it is even better to have a walky-talky manual right here :-)

Though it wierd that one of the 3 sensors I have works fine with both USB powered or external power that way despite my mistake. not quite sure why

I hope I didn't BBQ mine board by doing so?

Thank You so much Chris.

#8 Hai Nguyen

Hai Nguyen

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 31 August 2010 - 11:42 PM

Chris, That fixed the issue now. all sensors work just fine. Thanks!

#9 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 10 December 2011 - 05:45 PM

I have just bought a Sharp distance sensor from www.hobbytronics.co.uk - http://www.hobbytron...distance-sensor

It is a 10cm to 80cm analogue sensor. The full part number on the bag is: GP2Y0A21YK0F.
The data sheet says the distance in cm is approximately = (27 / voltage).
This gives quite a good result. (Apart from the occasional divide by zero error!)

Doing a search on the forums, I found this thread. So I copied the code above into a test program on my Netduino plus.

I assumed that my sensor would work with the settings for the "GP2Y0A21YK":
                case SharpSensorType.GP2Y0A21YK:
                    Y0 = 10;
                    X0 = 315;
                    Y1 = 80;
                    X1 = 30;
                    break;
But, I got results that were completely wrong.
I noticed that the analogue port range is being set to 0-100: port.SetRange(0, 100);
So I am not sure how X0 can be 315.

To cut a long story short, I added a new sensor type and the following case to the switch statement:
                case SharpSensorType.GP2Y0A21YK0F:
                    Y0 = 10;    // Minimum distance cm
                    X0 = 64;    // Raw analogue port reading at minimum
                    Y1 = 80;    // Maximum distance cm
                    X1 = 11;    // Raw analogue port reading at maximum
                    break;


So the questions I have are as follows:
  • should the code have worked with my sensor using the GP2Y0A21YK settings? (Is the GP2Y0A21YK equivalent to the GP2Y0A21YK0F?)
  • where did the code come from? (Was it written for a different device (e.g. Arduino) with a different ADC range?)
  • can I feed my results back into a library somewhere for others to use?

Paul




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.