Tag Archives: quadcopter testing

Alfa2test. Introducing PID

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:

  1. 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.
  2. The opportunity to change the target roll by the user  using the buttons a (increesing ) and z (decreesing).

The main targets were:

  1. pure debugging and code verification
  2. verification of the generated log
  3. 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.

Two  comments:

  1. 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.
  2. 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.

Preparing test session

It’ is now time to move from my desk to the garage to start the second phase of the development.

The targets are:

  • verify the start up procedure of the esc. I want to see if and how  I can start up properly the esc evenif it is already power on. This is useful in case I want to power rpi directly from  one Esc BEC.
  • verify the disturbance in the IMU data due to the motors vibration.Setup in the best way the filter severity
  • verify the control loop and tune the pid parameters for quadcopter rotation
  • develop the user remote control via wifi to control motors and quadcopter position

To do this tests I build up a frame that I hope it can allow me to stay safe.Here the picture of the original design and the final result.




I’ve  also finalized the wiring of the system including the IMU and an home-made board for the motors connections.rpi power is still via usb and ethernet connection via wire.


So the new motor connection setup is:

  • GPIO 18 (pin 12) >M0
  • GPIO 23 (pin 16) >M1
  • GPIO 24 (pin 18) >M2
  • GPIO 25 (pin 22) >M3