I have been wondering whether I have a basic mistake in my feedback loop. I am measuring distance and adjusting rate of speed and rate of turn. Maybe I should be measuring rates not scalars

This means differentiating. I would need to measure two distances a fixed time apart. Then do some subtraction. I do that a little bit in my code, when I include "oldrangeright" in my state machine, but since there is no consistency to my sample time...... Rate of turn is even less clear.

Is this the PID flaw you are suggesting? What is the solution? What are the technical limitations? Will a 16F887 do the job? Do I need C code including appropriate libraries? I do not know how to start.

Your comments about my PWM are true. I found what works by trial and error. To get 50hz would I need to install an outside oscillator? Might I somehow divide down the internal one?
Ken