# Pitch Controller input "AirspeedScaler"?

I’m trying to recreate ArduPlane’s basic PID flight controller algorithms for my custom Arduio/Teensy plane.

I’ve decided to look into implementing a pitch controller first and then move on to roll and yaw. I was able to find the attached picture of ArduPlane’s pitch controller diagram. I’m able to understand how to implement all of the pieces except for the input “AirspeedScaler”.

My question: Is “AirspeedScaler” a global constant defined somewhere (if so, what is the value?) or is it user defined (if so, what are the value limits)?

I’d look in the source code, but I know from previous experiences that ArduPilot is written/structured in a way that is very difficult for someone new to the codebase like me to understand/find things, lol.

It is calculated in Plane::get_speed_scaler() here:

It is the scaling factor for surface speed scaling. Control surfaces need to move less at higher speeds.

Interesting. But what is “g.scaling_speed”? Is that a set constant? Where does it come from/what is it’s value?

That is the mid-point for the scaling. It acts as an overall scaler for the fixed wing surface PIDs. Setting it to the cruise speed of the aircraft allow you to use the default PIDs on a much wider range of aircraft.
Basically if you are flying at airpeed=g.scaling_speed then the scale is 1.0
I usually only recommed that people set this on really fast aircraft (eg. jets)

I’m only planning on flying a somewhat slow electric prop plane (maybe 20mph max) - in that case, should my calculation of speed_scaler be:

if (aspeed > 0.0001f) speed_scaler = 1.0 / aspeed;
else speed_scaler = 2.0;

Also, one last question: I tried looking into how ArduPilot converts the controller output into a servo signal (either us pulse length or servo angle), but I couldn’t figure it out. How can I convert the pitch controller output to a servo us pulse length?

Is the above question too difficult to answer in a forum post? Does anyone know the answer?

I’m sorry, I’m just trying to understand and learn