This 3 days I essentially worked on the diagram bloc to self balance our board with a null angle to the horizontal.
Its a simple PID but we have to add some stuff to make the regulation working. First we need to prevent the wind up on the integrator when the output is satured. Then the D componet increase hight frequencies noise. So we attach a low pass filter. FinaLly we have the value to apply on the motor. The board move to an other angle. Perturbations can emerge. Like the ground slope, the wind or humans. We got the final position now. We need accelerometer and gyroscope output to calculate the new angle of the board to the horizontal. We can directly use the output of the accelerometer but we have to apply an anti drift filter to the gyroscope output to cancel the integrated error over the time. Then we compare the request angle with this angle and do the operation again.
Here, the diagram bloc !