I propped up the cart so it wouldn’t move and ran it at a variety of steady state PWM rates. I collected the data and plotted the average current and speed versus PWM rate. I plotted clockwise motion in white and counterclockwise motion in red.
The speed appears to be very linear versus the PWM cycle. At low PWM values under 50, the motor does not move. At 50, it jumps a little bit then is very linear from that point on. For a given PWM cycle, the CCW speed is about 2% larger than the CW speed. This explains the slight drift to the left when cycling the PWM sinusoidally.
The current ramps up somewhat linearly while the motor is not turning. Once the motor starts turning, the current drops a little bit then increases very slowly. This indicates the motor is overcoming friction and other forces to maintain a steady speed. The interesting thing is that the CCW current is significantly larger than the CW current, by about 20%. This explains the rapid drift to the right when cycling the current sinusoidally.
This causes problems when trying to control the cart using PID. If I try to control the current, I need to somehow balance the left and right directions of travel. Perhaps it could be accounted for by the controlling program, which would just boost the current in one direction. I would also have to figure out the relationship while the cart is moving so that speed and acceleration are accounted for.
Another option would be controlling the PWM cycle directly. The speed is almost perfectly linear to the PWM value. Adding a factor of 2% to correct for direction would be easy. The cart is so light relative to the amount of torque in the motor that it can accelerate almost instantly to the steady state speed that goes with the PWM. I could limit the rate of change of the PWM cycle to prevent acceleration values that exceed the safe values.
I think I need to do further tests to figure this all out. This was a good start, though.

