Pages: [1]   Go Down
Author Topic: Sharp GP2Y0A02YK0F linearizing voltage  (Read 1577 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i, im buid a project with an arduino Duemilanove, im using a  Sharp GP2Y0A02YK0F IR Sensor, but the output voltage is non linear, i really need obtain a true value of proximity object, anyone can helpme in this situation?

im used this code:

#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(' ');

}

but is not precise, the values are not linear, ex: when i put an objetct to 20 cm, the output says 21-22 cm, and when put an objetct to 3 cm, the ouput says 28-30 cm.

the pin order is this:

pin 0 (analogic input) -> output voltage from IR Sensor
pin 5V -> input Voltage in IR Sensor
GND -> GND Ir Sensor


i need a way to mesure the distance an objetct from 3 cm and up.

i apreciate your help.

tnx
« Last Edit: March 24, 2010, 01:39:09 pm by cadrogui » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

The range of GP2Y0A02YK0F is 20cm ~ 150cm.
If you need to  measure distance from 3cm to 20cm, use another sensor.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes, but if lineralize the output voltage can be work?

the issue on this web is taht i dont understand the topic

http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html

tnkx

pd: i buy 10 of this IR... Duhhh  :'(
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

int val;  
int distance = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  val = analogRead(0);
  distance = (6787 / (val + 5)) - 1;
  
  Serial.print("Valor Analogo: ");
  Serial.print(val);
  
  Serial.print(" - Distancia Lineal: ");
  Serial.print(distance);
  
  Serial.println(" ");
  delay(1000);
}

doesnt work for my model, can anyone helpme?

tnxs
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think it's possible to linearize values between 0 to 20 cm.
You can see graph for the GP2D120 (same familly) :
http://www.pobot.org/IMG/png/courbe_sharp.png
Sorry in french but interresting. (thanks again Luj06   smiley-wink )
« Last Edit: March 24, 2010, 05:29:01 pm by startx » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

snif... yes its impossible!!!...

thanks!!!
Logged

Pages: [1]   Go Up
Jump to: