Electronics > Electronics

sharp IR question

(1/2) > >>

benji:
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?

frank26080115:
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: ---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

--- End code ---

Admin:

--- Quote ---also considering that i want to take 90 readings from the sensor's output (each one degree a reading)
--- End quote ---
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.

benji:
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

airman00:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version