Close

Relearning important ISR lessons

A project log for Captain PIcar

2 wheeled rover for various robotics projects with high level logic implemented in LabVIEW running on a Raspberry Pi

derrickDerrick 05/24/2020 at 08:001 Comment

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

Derrick wrote 01/15/2021 at 19:42 point

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