Any one can teach me how can I Voltage-to-Range Conversion?
thx~
I tried "R = (6787 / (V - 3)) - 4"......but difficult to senor after 2m..
The sensor is 1m-5.5m
Any one can teach me how can I Voltage-to-Range Conversion?
thx~
I tried "R = (6787 / (V - 3)) - 4"......but difficult to senor after 2m..
The sensor is 1m-5.5m
yin,
Take a look at this thread . . .
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230387822/6#6
"hurley" suggested plotting voltage and distance in Excel and then doing a "best fit" graph to get a formula.
That worked pretty well for my model of sensor. (I posted the results in Reply #6.)
Thank you so much! But GP2Y0A710K0F have some different with 2Y0A02...
the data not stable after 2.5m...thank you.
any other method?? thx
#define sensorPin 0
#define VOLTS_PER_UNIT .0049F // (.0049 for 10 bit A-D)
float volts;
float inches;
float proxSens = 0;
int cm;
void setup() {
beginSerial(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
proxSens = analogRead(sensorPin);
volts = (float)proxSens * VOLTS_PER_UNIT; // ("proxSens" is from analog read)
inches = 23.897 * pow(volts,-1.1907); //calc inches using "power" trend line from Excel
cm = 60.495 * pow(volts,-1.1904); // same in cm
if (volts < .2) inches = -1.0; // out of range
Serial.print(cm);
Serial.print(' ');
}
the cm will not over 50.....
help............
yin,
You can not just take the formula I gave for the GP2Y0A02YK0F and apply it to the GP2Y0A710K0F - they have different curves.
Have you looked at your datasheet?
http://sharp.com.cn/products/device/lineup/data/pdf/datasheet/gp2y0a710k_e.pdf
On page 5 you will see a graph of the output. You want to make a formula for this graph - or better yet, from what you actually measure.
The method suggested here is to use Excel.
Also note that on graph very close distances create the same voltage as further distances. (i.e. 2V @ 20cm and 2V @ 180cm)
Unless someone responds with a formula for your exact sensor, you may have to create one yourself.
thank you~ but i don't know p.3
[ch916]VO2
Output voltage difference (L=100cm[ch8594]200cm)/
Output voltage differentce (L=200cm[ch8594]550cm)(Note 1,2)
from the curve....200cm[ch8594]550cm, so little change of the voltage.. how the measure it?
Dear BroHogan,
I really don't how to calculate the distance using your method, please teach me~ please~~~~~~~~~
from the curve....200cm[ch8594]550cm, so little change of the voltage.. how the measure it?
Yes, it is a very flat curve - only ~ 0.35V from 250-550cm.
However analogRead gives you .0049V/'click' so in theory you should get a difference of 71 clicks for that distance.
I suggest you print what you are getting from analogRead at various distances to confirm this. Then you could graph that in Excel or you may find it to be flat enough to be used as is.
In any case, it doesn't seem likely that you will get accurate distance measurements from that sensor.
Do you really need actual distance? Wouldn't just the relative distance from analogRead be enough? (You haven't said what your trying to do.)
As far as helping you use Excel, I don't know if you have Excel, or if you have experience with it. If yes, please let me know what you don't understand about the process. (Personally, I hate Excel and the last thing I'd like to do is teach it to someone. ) If no, and you have Excel, open it and mess around. Then we could have a basis for discussion.
In summery, look at your output from analogRead and see if it looks like you can do something with it. If not, you can look into changing the Aref voltage to get more accurate measurements. You could also consider an opamp.
Thank you so much~ I can't measure the data...because my room is so small....I live in Hong Kong.
I don't know I need what data if I want to dim a light. ( the light will dim up when a people walk close the sensor~)
maybe a need relative distance from analogRead be enough.
thank you thank you....
I did a data record
#define sensorPin 0
int sensorValue = 0;
// this is called on startup
void setup() {
beginSerial(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue );
Serial.print(' ');
}
0cm 330-350
25cm 550-560
50cm 625-628
75cm 599-610
100cm 515
125cm 450
150cm 411
175cm 390
200cm 363
225cm 343
250cm 330
275cm 320
300cm 310
325cm 302
350cm 295-297
375cm 290-293
400cm 287
425cm 285-287
450cm 279
I did a data record
#define sensorPin 0
int sensorValue = 0;
// this is called on startup
void setup() {
beginSerial(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue );
Serial.print(' ');
}
0cm ~330-350
25cm ~550-560
50cm ~625-628
75cm ~599-610
100cm ~515
125cm ~450
150cm ~411
175cm ~390
200cm ~363
225cm ~343
250cm ~330
275cm ~320
300cm ~310
325cm ~302
350cm ~295-297
375cm ~290-293
400cm ~287
425cm ~285-287
450cm ~279
after 200cm....the data is very unstable~ :-/
my frd have some data collect
Distance (cm) 1/Distance Reading Voltage Ratio
60 0.01667 647 3.1600 189.6000
65 0.01538 647 3.1570 205.2050
70 0.01429 648 3.1630 221.4100
75 0.01333 647 3.1600 237.0000
80 0.01250 644 3.1450 251.6000
85 0.01176 626 3.0570 259.8450
90 0.01111 600 2.9280 263.5200
95 0.01053 572 2.7950 265.5250
100 0.01000 547 2.6730 267.3000
105 0.00952 526 2.5670 269.5350
110 0.00909 505 2.4640 271.0400
115 0.00870 485 2.3700 272.5500
120 0.00833 467 2.2800 273.6000
125 0.00800 449 2.1930 274.1250
130 0.00769 435 2.1250 276.2500
135 0.00741 420 2.0500 276.7500
140 0.00714 405 1.9780 276.9200
145 0.00690 395 1.9280 279.5600
150 0.00667 385 1.8780 281.7000
155 0.00645 378 1.8450 285.9750
160 0.00625 367 1.7900 286.4000
165 0.00606 359 1.7520 289.0800
170 0.00588 343 1.6730 284.4100
175 0.00571 332 1.6230 284.0250
180 0.00556 326 1.5920 286.5600
185 0.00541 324 1.5800 292.3000
190 0.00526 304 1.4820 281.5800
195 0.00513 294 1.4350 279.8250
200 0.00500 277 1.3530 270.6000
205 0.00488 251 1.2280 251.7400
210 0.00476 267 1.3050 274.0500
215 0.00465 242 1.1800 253.7000
220 0.00455 236 1.1500 253.0000
Average Rat. 266.2509
Average (H10-31) 277.8102273
hihi
From what I understand, you want the light to get brighter as someone gets closer to the IR sensor.
Does it really matter the exact distance a person is from the sensor?
If not, you can just take the inverse of the analog read and use that value in the code that controls the light voltage. For example,
Output voltage = (1/IR Reading) * 1000
This will give you output voltage values ranging from approx 1.5 to 4.2 based on the data you posted above. However you can replace that 1000 with whatever you want to the values you need. You can also use the "map" function to convert those values to the value range you need.
If you need something more exact. Plot the Reading (y-axis) vs the Distance that reading was taken at (x-axis). Then add a trendline and have it show the equation of the line. This will allow you get an approximate equation relating the distance to the analog output.
From your data above that equation is
y = -2.7973x + 826.46 R² = 0.9773 where y=analog reading, x=distance R2=how well the data fits the line, 1 is perfect fit.
thank you so much~~