This Alfa2 test has the scope to introduce in the code the part dedicated to the PID control loop (see here an introduction of the PID Concept). So I included a new module pid.py. Here the complete code alfa2test
The used layout is stille the same as alfa1test so only one motor, mounted on the frame, the frame has got only one degree of freedom arounf the roll axis.
The software includes two new elements:
- The PID control that can calculate the motor speed according the current roll and a target roll . Please note that in the code thare 2 parameters used to limite the pid effect in order to keep it under control. They are the maxW allowed on the motor and the maxCorrection each loop.
- The opportunity to change the target roll by the user using the buttons a (increesing ) and z (decreesing).
The main targets were:
- pure debugging and code verification
- verification of the generated log
- first analysis of the log.
Below the roll and the motor speed W with a fixed roll target=0.
The most important thing to me was to see that the correction was correct according to the roll position.As you can see it is correct.
- in this test I did not work on the PID parameters. That’s appear clearly in the graph, with this periodical behavior or the system.
- In the phase when there is the riduction of the motor speed , the contrast to the inertia is now done only by the gravity. this cause the overshooting at every period.
With the scope to recreate now a more realistic behaviour of the system , in the next alfa3test i will adda new motor, and I will start to do some PID tuning.