Monthly Archives: June 2014

Beta1test. Bugs and a steps ahead

Yesterday I got this result:


Thanks to the following actions:

1)The test with the ball on the bottom of the drone,did not convince me. the friction on the ball, the  rotation limits due to the basement, were all components that are not present during the flight.

So I decided to switch to the more used and recognized  solution with the quadcopter tied up with 2 wires.


2) I realized  that something was wrong on the motors behaviour.When I  run the   the motor sound  was unstable and unconstant evenif  I was not  controlling it with PID ,just make them run in throttle speed.

This is not happening if I run the

Finally I was able to reproduce the problem and I realized there is a bug (or better an unexpected behaviour)  in the  library RPIO. If I run this loop (that reproduces the main loop of the beta1) I got the unstable motor rotation:

while true:

mymotor.servo.set_servo(, PW)



My explanation is everytime  calling the set_servo()  function, it resets to zero the signal than set it to the desired value PW).

Instead of that funciont I introduced the lower level function


When I put it in the test loop I got a perfect, stable, constant sound for the motor rotation.

This 2 improvements gave me the opportunity to move  a  great step haed. Now the tuning can be faster and more consistent.

Above just a graph showing the current behavior.In blue the requested   roll , in red the real roll when  the quadcopter is  using the pid controller. I still need to  tune it to reduce the time to reach the target (5/6 seconds)  and to avioid the oscillation ( +/- 3 degrees).But I’m really satisfy about the current situation.

Beta1test. Some remarks

During last days  I did some test with the following setup:

  • Throttle speed = 30 (this value does not permit the drone to fly but it can balance itself on the semisphere mounted on its base ).
  • Roll target=pitch target =0.
  • Command =1 ( only the PID controller for roll is active).When it is in this mode the motor1 and motor 3 ( pitch) are spinning at throttle speed.
  • PID k : I change them in different tests to have a first comparison .
  • Cycletime = 10ms.

Analizing the logs saved I find out those remarks :

  • The cycle time average is = 11ms, sometime I get a pick up to 21ms.I need to investigate on this .beta1_cycletime
  • I need to compare data from different logs coming from different threads (main loop and sensor for the moment).So I just modify the code including a column that reports the absolute time. This can allow me to match the 2 logs.
  • When I switch from command 0 (no PID controller) to 1 (roll PID controller) I notice a pick on the motor speed. I find a bug: one data initialization missing.Now it is corrected.
  • When I switch from command 0 to 1 it takes around 1,5 sec to start to balance,evenif the  difference in motor speed is already high. Possible explanation (to be investigated) is the inertia effect (to start the movement).I should allow a bigger speed correction.
  • Right now the best result is obtained with Kp= 0.6 Ki=0 Kd=0.5. I will try increasing a little the Kp and reducing the Kd.beta1_balancing