I've figured out where my problems were coming from with the PID velocity control!
1. I was trying to be too efficient. Trying to reuse the volatile variables means they were likely updating in the middle of a PID routine resulting in drastically incorrect floating point representations for some of the tuning parameters and control setpoints causing the PID calculations to basically stop. I've since setup signalling from the ISR handlers to the main loop so that the main loop can know when to pull volatile variables into local non-volatile variables that are used in odometry and velocity control.
2. I'm occasionally missing capturing when the I2C library should be receiving a value as a register location instead of register content data. This was resulting in the output range max value getting set to 0 which of course means no more PID output. Still need to track down why this is happening but I'm very close to getting to very tight joystick control of the rover!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I'm pretty sure I figured out that the issue I was seeing with some values getting reset was due to race conditions in accessing the I2C bus on the Pi's software. My suspicion is that the I2C comms for reading the IMU orientation was colliding with the I2C comms to my motor controller so the motor controller would randomly see that it should be resetting some values instead of the comm methods locking access to ensure atomic access to the bus.
Are you sure? yes | no