Notifications
Clear all

Line Follower Over Reacting

4 Posts
2 Users
0 Likes
985 Views
(@ozcraig)
Member
Joined: 4 years ago
Posts: 9
Topic starter  

   
Quote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

First let me say I have not done the line following experiment. However, since you are using the photo sensors as feed back I believe you can just rely on them to keep your car on track rather than trying to compensate for motor differences. 

So why don't you remove the motor speed compensation and start out with lowering the speed of both motors until you get the system working. Additionally, remove the delay() commands in the turn code as that with high speed may be the cause of your overshoot. Once you get the system to reliably track the line then you can tweak it to perform better. I hope that helps 😊 


   
ReplyQuote
(@ozcraig)
Member
Joined: 4 years ago
Posts: 9
Topic starter  

Thanks for your comments Ruplicator. I have spent a few hours following your recommendations. I have found that my two cheap Chinese motors just do not want to run at the same speed and I am continually going in circles unless I code in a speed differential, even without trying to follow lines. I have used this same pair on a different project and did same on that one.I have some new motors ordered so it will be interesting to see if they are any better.

However, I took your advice and removed the speed compensation, to no avail. I lowered the speed of both motors as low as I can without the slower one stalling and refusing to move, and removed the delays, to no avail. It is my understanding that the delays are there to run the motors at the speeds relevant to the left or right turn as required, so a longer delay should result in holding the turning speeds for longer, and a short or no delay should result in very little or no turning action. Is that how you read the sketch?

After faffing about for a few hours I have found that a delay of 50ms seems to work with my setup, with both motors as slow as I can make them. I also found that fine tuning the IR sensors to close to the edge of the black track reduces oscillations. With this combination I am able to follow a straight line. Since the car is currently parked over my other more fancy black track line I'll give that one a shot over the weekend.

Once again, thanks for your advice. 😀 


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @ozcraig

It is my understanding that the delays are there to run the motors at the speeds relevant to the left or right turn as required, so a longer delay should result in holding the turning speeds for longer, and a short or no delay should result in very little or no turning action. Is that how you read the sketch?

Yes and no. First of all remember that once you set both motors on and set a specific speed for each motor that same speed configuration will continue until it is changed delay or not. Any time the sensor (left or right) is indicating that it is not seeing the line you are slowing the motor on the opposite side. Without the delays the loop will continue to test the sensor as quickly as the MCU can process it. If MCU finds the sensor not seeing the line it will slow the motor it's opposite. If on the next loop the sensor still doesn't see the sensor then MCU will continue to slow the appropriate motor. Therefore , as soon as the sensor can see the line the MCU will then speed up the motor that was slowed and continue straight. 

With the delays installed, there will be obviously a delay before the MCU can make any corrective action.  The delay is tuning the circuit and you will most likely be able to tune it for a specific track but if you move the car to a different track with different degrees of turns, it most likely won't work again.

Make sure the correct motor is slowed when a given sensor looses the track i.e., if the left sensor can't see the track the right motor should be running slower.

If you car leaves the track in a turn you may not be slowing the inside motor enough. If the turn in your track is sharper than the difference in motor speed then the car will leave the track.

If your car is leaving the track in the a strait section then the sensors may not be reading the track correctly.  Once neither sensor sees the track then the MCU doesn't know what to do.

If the car wobbles from side to side in bigger swings before it leave the track, that says there is something wrong with the freed back loop. In other words the MCU can't control the motors fast enough before the car looses sight of the track.

I hope that helps.


   
ReplyQuote