So, I currently have the robot programmed run motors and servos, but I have no idea how to program sensors. I want to program an infrared seeker sensor, but I have no idea where to start. I've searched for it, but most of all I found is just people who have had problems with accuracy or needing some driver or something. How do I start programming the sensor?

Thu Dec 09, 2010 8:44 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: Infrared sensor how to program?

Did you see the code posted on this thread?viewtopic.php?f=52&t=2780This code gives you a function that returns a relatively accurate heading if you point it sideway. If you use this function as the input to a PID controller, you will have a robot that will turn towards the IR beacon. For example, assuming zone 2 is the dead ahead zone, a simplified version of the code looks something like this:

Kp is the Proportional Constant in PID control. If you are not familiar with PID control, you can read the following article.http://en.wikipedia.org/wiki/PID_controlBasically, it said the output power of the motor should be proportional to how far you are from your target. If you are very far from your target, PID control will try to drive with maximum power. If your are very close to your target, PID control will slow down so you don't overshoot. Kp is a constant you must tune so that it's value is big enough to get the robot to target as fast as possible and yet not overshooting. To tune this value, you can try something big first. If it overshoots and oscillates when reaching target, tune this value smaller until it no longer oscillates. PID control involves other constants too, but if you are not familiar with it, you can just use Kp and ignore the other constants.In the IRDrive function, Kp is to control how quickly the robot turns towards the IR. The bigger Kp the faster it will turn towards the IR but risking overshooting (turn too much). The smaller Kp the slower it will turn to the IR but more accurate. You can try an initial value of 20 to 25 and see how it goes and tune it from there.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum