PID line follow with three sensors in NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
bungeshea
Posts: 207
Joined: 14 Aug 2011, 08:45
Location: Australia
Contact:

PID line follow with three sensors in NXC

Post by bungeshea »

Hello,

I'm currently working on a line-following robot which uses three sensors to follow a black line. The sensors are pretty much in line and right next to each other.

Right now, I'm doing a simple line follow: if on the line go forward, otherwise turn left or right to regain the line. This means that the robot is wiggling along the line most of the time.

I'm looking for a better way for this robot to follow the line using three sensors. The program I'm writing is in Not eXactly C code. I'm trying to get the robot to utilize the power of PID control, but I'm not sure how one would go about writing a three-sensor PID line-follower program in NXC. Any help would be greatly appreciated.
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: PID line follow with three sensors in NXC

Post by hassenplug »

Using three light sensors, and simple boolean values (either it's on the line, or off the line) there are eight possible states.

For most of them, you should know what to do, simply by looking at the sensors.

However, without getting too fancy, you can greatly improve things by knowing the previous state the sensors were in.

For example, if the sensor on the left sees the line, you know you need to turn left.

If NO sensor see the line, but the sensor on the left just saw the line (previous state) you know you need to turn sharper left.

But... if the sensor on the left see the line, and the previous state was no sensor on the line, you know the robot is currently turning onto the line. In this case, you can stop turning, go straight and let momentum continue to turn the robot.

Using this type of logic will be a huge gain over basic line following techniques.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests