Relation between Gyroscope 3D axes values and ESCs and brushless motors

I am going to start a new project on making a balanced quadcopter, and apparently there is a lots of projects online with ready-scripts to use, but I read these scripts, and can't find how they use the converted values from gyroscope (Angles) into signals to ESCs and then to motors ?

So if the gyroscope is having a roll of 30 degrees to left and the user stopped using the RC, how to tell the ESC on the left to increase voltage and the motors on right to decrease voltage so the quadcopter is balanced ?

Here is a few links of the scripts that's I am talking about:

http://86.84.251.44/cgi-bin/YMFC-AL.cgi

The system is not simple, but at the same time it can be understood with a little effort.

As with all computer programming problems the trick is to break it down into small pieces.

Start by thinking about the system operating in a balanced steady situation. What values will be gyroscope be producing and what values will be required for the analogWrite() commands for the motors (for now you can invent values).

Next. think what happens if the drone starts to roll (perhaps due to a gust of wind). The gyroscope values will change but the motor values won't. So you need to determine if the roll is big or little and change the motor values to conteract the roll.

Then you need to imagine that your adjusted motor values probably will not actually be the correct ones. The drone may continue to roll in the same direction, or it might start to roll in the other direction. In either case another correction is needed - probably smaller than the first correction.

That sequence can continue for some time until a new equilibrium is reached.

There is a system called PID and there is an Arduino PID library that is designed to manage that process of successive corrections so as to get back to equilibrium as quickly as possible. Time to do some reading :slight_smile:

...R

My problem is that I cannot find a link between the gyro values and the motor speeds in the codes.

alexmhd9090:
My problem is that I cannot find a link between the gyro values and the motor speeds in the codes.

What sort of link do you expect to see? What have you been looking for?
Why are you looking for the link? What do you propose to do with it if you find it?

If you are planning to write your own code then you need to understand it from first principles. Hacking at someone else's code is unlikely to work unless you know enough to do it yourself. And if you know enough to do it yourself that will probably be quicker than trying to figure out existing code.

Alternatively, just use some existing code that does what you want.

...R