help me to turn line following bot by 90deg by using interrupters and encorders

hi, i want to turn my line following robot by 90 degrees very accurately. i'm thinking of performing it by using an Arduino 2560 mega.
could somebody tell me how to turn a bot by using interrupters, magnetic wheel encoders and motor drivers? sketch is preferred. :fearful:

i'm using the motor - Pololu - 30:1 Metal Gearmotor 37Dx52L mm 12V with 64 CPR Encoder (No End Cap)

If I wanted to turn a small robot right or left by exactly 90 degrees, I'd use a compass. About $4 on ebay. Doing it by trying to measure the wheels will be problematical. Wheel encoders can measure the distance your robot has travelled, when it is going in the straight line. They don't work particularly well when the robot is turning.

are the compasses are reliable when we use it in an environment which has a varying magnetic field? such as many motors and power transmitting lines? Due to that, i decided to use wheel encoders to turning. eventhough the robot is turning, we could calculate the ticks which required to turn the bot by 90 degrees.(by arc lengths) I have the problem when I think to implement it with interrupters. :frowning:

The problem with wheel encoders, is that the wheel will turn predictably in contact with the ground in a straight line, but when turning, they are not.

The compass should work if you don't mount it too close to the motor. With a bit of logic, you should be able to avoid acting upon false readings from the compass. You could try not actually reading the compass when the motor is running.

In fact, you should probably implement both methods and use the compass to validate or calibrate the wheel encoder scheme.

Hi..

I wanted to navigate a robot by just using Digital Compass. My application required that the robot makes exact 90 degrees turns and moves dead straight. I used a 10 Degrees of Freedom Module ( 10 DOF) which has 3 axis - Accelerometer, 3 - axis Gyro , 3 - axis Digital Compass and a Pressure sensor.

After experimenting with this approach for a couple of weeks, I have come up with some insight that will be helpful in using Compass for Navigation.

-> Mount the Compass - at considerable height from the robot chases and motors:

The digital compass is very sensitive to any magnetic field. During my experiments, I felt that bring a metal too close to the compass module disturbs its reading. For this some plastic spacer can be used.

-> Implement Tilt Compensation :

The magnetic compass give stable reading when it is parallel to the surface. But as the compass is mounted on the robot which moves on surfaces that need not be planar. So the compass is not in its ideal operating condition and the reading which it gives are offset from the real value.

So, I used the accelerometer output in conjunction with the digital compass to have a very sense of reference.

You need to calculate the pitch and roll from the accelerometers output and then use it get have a tilt compensated digital compass output.

-> Take Care of the Error in orientation in the code :

Even tilt compensation was not enough of move the robot in a deterministic way. The reason was the use of differential drive in the robot. The motor used were not perfect, I mean the actual rpm of the 2 motor was not precise as per the specification.

So, I used PID Feedback Controller ( proportional, integral and derivative - feedback controller) to make the robot move dead straight with respect to the starting position.

However, I could not implement the PID Controller for pivot turn of the robot. I guess one need to find the differential kinematics equations for the pivot turn.

So, I implement my own error correction algorithms to dead with the few degrees error in the heading after each movement made by the robot.

For the future iterations on my project, I think of using rotary encoders and digital compass to have combined data for better reliability.

Hope that this information is useful.

Thanks.