Author Topic: sharp IR question  (Read 3264 times)

0 Members and 1 Guest are viewing this topic.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
sharp IR question
« on: October 11, 2007, 04:44:51 PM »
what does the sharp ir output as a largest output ? 5 v ? how close would that object be when it outputs its maximum voltage?
and about 2d mapping , considering mounting 2 sharps onto one servo motor
the first scans from -90 to 0 and the second scans from 0 to 90
also considering that i want to take 90 readings from the sensor's output (each one degree a reading) and write the 2 sensors outputs into 180 bytes of data
whats the maximum time or one scan (left to right) to keep things fine for mapping if my robot is a hexapod (slow motion)
and should i make my servo move continusly or a little delay between each degree?
good ol' BeNNy

Offline frank26080115

  • Supreme Robot
  • *****
  • Posts: 322
  • Helpful? 2
Re: sharp IR question
« Reply #1 on: October 11, 2007, 06:28:39 PM »
it never goes over about 2.6 volts
range depends on model, check this chart
http://i156.photobucket.com/albums/t31/frank26080115/Screenshot.png

180 readings? that's going to take a while, and it's going to take longer to get just right.

place your servo control function inside a for loop, and adjust the number of loops until the servo pauses but barely before it starts to move again.

Code: [Select]
byte range[180]; // 180 freaking numbers deserves only 180 BYTES and not two byte INTegers

for(float angle = 0; angle > 90; angle++) // float for accuracy
{
for(int repeat = 0; repeat > change_this_number; repeat++) // change that number until you notice the servo pauses very shortly
{
pinHigh(); // replace this with how ever you want to set the pin to high
delay_us(1000 + 1000 / 180 * angle); // 1000 being the min pulse width
pinLow();
delay_ms(5); // it can be anywhere between 5 and 20, so 5 just to be safe
}
range[angle] = analogRead(sensor1) / 4; // take the reading
range[angle + 90] = analogRead(sensor2) / 4;
// dividing by 4 shifts the bits 2 times to the right, making it a 8 bit value
// only divide by 4 if you have a 10 bit ADC
}
// you can tell, some functions are fake, change them
« Last Edit: October 11, 2007, 06:37:27 PM by frank26080115 »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: sharp IR question
« Reply #2 on: October 11, 2007, 06:34:18 PM »
Quote
also considering that i want to take 90 readings from the sensor's output (each one degree a reading)
Although you can take 90 readings, or even a 1000 between 0 and 90 degrees, your servo itself is only accurate to about 2 degrees at best. I think it best to just get it to work, and then tweak it as you understand better what does/doesnt work well.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: sharp IR question
« Reply #3 on: October 12, 2007, 07:43:53 AM »
thanks for the code
but actually im a 8051 cores assembly programmer,but anyways i got the algorithm .
, i would also consider to have a reading each 2 degrees thanks admin
good ol' BeNNy

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: sharp IR question
« Reply #4 on: October 13, 2007, 08:32:14 PM »
Hey benji,

just in case you don't know this, you can actually see IR light using a webcam or your cell phone's camera. Good tool for debugging.

and if you do know this, then its for the rest who don;t.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: sharp IR question
« Reply #5 on: October 14, 2007, 04:28:08 AM »
no i dont know this, thanks for informing, but how do you see it using a cellphone's camera?
good ol' BeNNy

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: sharp IR question
« Reply #6 on: October 14, 2007, 07:12:14 AM »
Just turn on the IR LED ( which is in the IR sensor) and turn on your cell phones camera. Look at the screen on your cellphone and you will see a blue light coming from the IR LED but without the camera screen there is no blue light.

( you dont need to take a picture for it to work. Open your camera and point the camera towards the IR scanner( or IR LED) as if you were taking a picture, and look at the screen of your phone. It should show a blue light coming from the IR LED)
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: sharp IR question
« Reply #7 on: October 14, 2007, 07:21:55 AM »
thats cool, thanks
good ol' BeNNy

Offline frank26080115

  • Supreme Robot
  • *****
  • Posts: 322
  • Helpful? 2
Re: sharp IR question
« Reply #8 on: October 14, 2007, 02:32:44 PM »
Hey benji,

just in case you don't know this, you can actually see IR light using a webcam or your cell phone's camera. Good tool for debugging.

and if you do know this, then its for the rest who don;t.

You guys know what's funny? I don't need any of that to see it, if you look at it dead on, you see a red light. I don't know if that is just me though...

 


Get Your Ad Here