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

Minimum AnalogInput Read value


  • Please log in to reply
13 replies to this topic

#1 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 15 March 2012 - 09:51 AM

Hi all,

I have a sharp analog infrared sensor which I'm having problems with regarding the lower voltage values (corresponding with larger distances).

- sensor is powered from 5V netduino+ pin
- Vout connected to analog 1

The datasheet states 3.1V max for Vout so this is the code:


analog.SetRange(0, 3100);
for (int i = 0; i < 60; i++)
{
   Debug.Print(analog.Read());
   Thread.Sleep(500);
}            


When the distances are small, the voltages seem to correspond with the datasheet specified values (between 2 and 3V). However when the distances are larger, the voltage doesn't seem to drop as I would have expected. I'm not really seeing anything below 1.7V or so. I tried measuring the voltage between Gnd and Analog 1 using a multimeter and the values seem to be good (below 1V when I would expect it to be). Does anyone know why analog.Read would be giving me values that are higher than what the voltage actually is?

thanks

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 15 March 2012 - 10:58 AM

Am I understand bad, or do you own a Netduino Plus? If so, take care to unplug the Ethernet. In any case, consider to *avoid* powering the board by using the USB. It's mostly coming from a very noisy supply. Try using a normal 9V battery: when you plug it, the USB power will be automatically disabled. Cheers
Biggest fault of Netduino? It runs by electricity.

#3 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 15 March 2012 - 11:22 AM

Hi Mario, I don't have an ethernet cable plugged in. I tried the test using batteries only and it yields the same incorrect results. Since I'm getting expected readings from the multimeter (<1V when appropriate), is there something wrong with my code? thanks

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 15 March 2012 - 12:30 PM

So...
...proceed as follows:
  • comment the SetRange call, so that the value given by the port won't be elaborated at all;
  • point the multimeter on the analog input and give me a stable value;
  • at the same time, tell me what's the Read method returns.

I'd also try to swap the photosensor with any trimpot, if you have. Please, tell me if you own any, and -if so- what value is marked on.
Cheers
Biggest fault of Netduino? It runs by electricity.

#5 Bainesbunch

Bainesbunch

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationFrance

Posted 15 March 2012 - 01:32 PM

So...
...proceed as follows:

  • comment the SetRange call, so that the value given by the port won't be elaborated at all;
  • point the multimeter on the analog input and give me a stable value;
  • at the same time, tell me what's the Read method returns.

I'd also try to swap the photosensor with any trimpot, if you have. Please, tell me if you own any, and -if so- what value is marked on.
Cheers


You might also want to tie the unused analogue inputs to ground. I have had erratic readings when these are alowed to "float"

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

#6 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 15 March 2012 - 02:09 PM

You might also want to tie the unused analogue inputs to ground. I have had erratic readings when these are alowed to "float"

Cheers Pete.


That's interesting. Could you point out how was the circuit and the code?

I guess to have performed such a test, but I did not notice any problem. However, it is surely a good practice to tie the unused input to a low-impedance source.
Cheers
Biggest fault of Netduino? It runs by electricity.

#7 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 15 March 2012 - 07:04 PM

Hi spcboog,

Have you spotted this post in the forums.

I have a sharp GP2Y0A21YK0F, and used the code from the above post.
It did not work initially, but I added a new case statement to it for my device and got it going.
(I posted my addition.)
The code with my modification has worked quite well for me.

I am confused about what the SetRange function actually does because I have read conflicting descriptions, but I don't think that SetRange(0,3100) is doing what you expect it to do.

Hope this helps - Paul

#8 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 16 March 2012 - 10:33 AM

Hi everyone, Pete, I tied the unused analogue pins to ground, but it didn't seem to change the results. Mario, I commented out the SetRange and for ~0.7V reading from the multimeter, AnalogInput.Read would return ~500. Since I am taking the multimeter measurements directly at the ground and analog1 pins, I am really confused about why the Read values would read so much higher. Unfortunately I don't have a trimpot. Paul, my raw analogue port reading is way too high at the maximum distance so I don't think the code is going to help until I get that sorted. thanks

#9 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 16 March 2012 - 11:13 AM

Hi Spcboog I know I am late on this but I think there are a couple of readings you should try. Tie at least 2 of the "Analogue In" pins to ground each via a resistor say 1k and disconnect the sensor. Measure the following pins with the black probe connected to GND. Vin, 5V, 3.3v, ARef, AGND, and obviously the analogue pins. Tell us what your readings are. What does your software read. Also Are you using ARef in your code? It often pays to double check the obvious.
STEFF Shield High Powered Led Driver shield.

#10 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 16 March 2012 - 09:54 PM

Hi Magpie, Thanks for the suggestions. With the sensor disconnected. Vin - 9.84V 5V - ~5V 3V - ~3.3V ARef - 17.7mV AGND - 0.6mV A1 tied to ground with 800 Ohm - 1.6mV A2 tied to ground with 800 Ohm - 1.6mV thanks

#11 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 17 March 2012 - 01:28 AM

Hi The readings you did looked fine unless of course your software is using Aref. There was a couple more questions you didn't answer. What does your software read. Tied to ground. Also Are you using ARef in your code? The is a setting in code you might have to call.
STEFF Shield High Powered Led Driver shield.

#12 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 17 March 2012 - 07:11 AM

Hi Magpie, Sorry about that. I'm not using ARef in my code. The two analog pins tied to ground via 800 Ohm resistors read in code ~40 with no SetRange call. If I'm not screwing up the calculation, that's ~129mV (3.3/1024*40), which is pretty far off from the multimeter reading of 1.6mV. thanks

#13 Magpie

Magpie

    Advanced Member

  • Members
  • PipPipPip
  • 279 posts
  • LocationAustralia (south island)

Posted 17 March 2012 - 10:04 AM

Hi Probably the last thing I can think of is for you to post some repro code. If you can post some code that allows people to reproduce this, then I could do a comparison. Also mention any other wiring you might have, Secret Labs firmware version, also are you using ethernet? Sorry you already answered this. Maybe its something called "burden voltage", although it seems very high.

Edited by Magpie, 17 March 2012 - 10:05 AM.

STEFF Shield High Powered Led Driver shield.

#14 spcboog

spcboog

    Member

  • Members
  • PipPip
  • 17 posts

Posted 18 March 2012 - 02:17 AM

Thanks Magpie, I'll try removing other elements from the overall circuit to see if it makes any difference.




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.