All the bits are together and the processor code tested. Bob should know when he is on track and how far out he is when he is off track. Time to get him running on the test track…
For this first run, the control was kept very simple. If the position error is positive, Bob needs to turn right. If it is negative, he needs to turn left. Turning is accomplished by removing power from the appropriate motor.
Well, that isn’t too impressive is it. Not that I expected much better at this stage. A couple of things worry me a bit though. The amount of wobble on the straights indicate that there is a lot of inertia and plenty of overshooting. The control loop is running at about 200 Hz and the frequency of overshoot is a couple of hertz. When I put Bob together, I though that having the wheels at the rear and the sensors way out in front would be a good thing. However, the batteries are well ahead of the wheels as well and have quite a bot of mass. The other thing is that, in the turns, the robot is only just turning fast enough to keep up with the turn even though one motor is off most of the time. Apart from the expected oscillations, this may also be due to the fact that the motor is driven from single transistor so there is little braking available. Once the PWM is turned off, the motor can freewheel so turning is not as sharp as it would be if the motor were braked. It may be necessary to replace the motor driver with a bridge to get better control. Finally, it is much noisier than I anticipated. Not serious in terms of performance but it wakes up the dog and, trust me, it is better to let this particular sleeping dog lie.