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.
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:
for (int i = 0; i < 60; i++)
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?
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.
Biggest fault of Netduino? It runs by electricity.
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?
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.
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.
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.
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
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.
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.
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.