Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: benji 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?
-
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.
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
-
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.
-
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
-
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.
-
no i dont know this, thanks for informing, but how do you see it using a cellphone's camera?
-
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)
-
thats cool, thanks
-
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...