Hello, I have a self balancing robot based on a stripped down version of Steven Witzand's code. The values for the PID loop and loop delay work well enough but they were chosen using the WAG method through trial and error. It occurred to me that I'd never know if these values were the most stable and efficient ones to use. So I coded a genetic algorithm to shuffle, mutate and test all the combinations of PID weightings. The mutations couldn't be too radical otherwise the robot would fall. For the fitness assessment I figured that the PID loop attributes that showed the least power variance over time were the best.
One problem I had to contend with is that all the extra maths the robot has to do impacts its balancing performance, but it seemed to work and the robot started to become less jittery through each generation of PID loop attributes. But it became apparent that the improved robot stability was an illusion and if the robot was nudged it performed much worse than before. It seems that, while the robot is just standing still, by using the least power variance test the P&I weightings for the PID loop wither away through lack of use. So I need either a better way of testing or a way of giving the robot a controlled nudge to keep it tough.
Can anyone give me any tips on determining the optimal values for a PID loop?
