|
Re: PID for velocity control
Thanks for the great replies. It validates that we should keep working on it and that it can work. So far it kinda works, but we have to turn down the proportional gain so far that it actually ramps to the desired velocity because if its highter it will oscillate around the desired velocity. Then since the proportional gain is so low, it can't make small changes to reach the desired speed. Adding in some integral makes it go crazy - it needs to be scaled way back and limited.
One problem we have is that there is a lag from the time you tell the motor to go and the time it starts moving. I see it with prints. You can see it in normal mode where you just assign the pwm value from the joystick. By the time the motor actually starts moving, it has already ran the PID a few times and cranked up the drive too high. Therefore the wheels starts spinning faster than they should. The same thing happens when holding a wheel and you let go and it spins faster for a short time. Each time through the velocity loop it adds to the drive.
Also, we are using gear tooth sensors, not encoders. We cannot tell the direction, so we assume the speed is in the direction we are pointing the joystick. At first we were using the value of the previouls drive, but if it crosses 127, then it will think the speed is going the wrong way. The GTS give us 1200 counts per seconds at full speed. We time it for 50ms and that gives us a relative "speed" of 0-60. Then we try to scale that 0-60 so it looks like the 0-255that comes from the joystick. The joystick minus the speed is our error.
I'm thinking of trying some "feed forward" that starts the wheel off moving at a value close to where it should be, then let the PID home it in. It seems like we need to allow time for the system to react before adjusting it again.
Thanks,
Brian
__________________
Brian K
Team 1225 Robotics Mentor
|