# Query on Speed Scaling (Attitude.cpp)

With the speed scaler (scalar…?) in Attitude.cpp, it is limited to a calculated max and min threshold with the following code:

``````    // ensure we have scaling over the full configured airspeed
float scale_min = MIN(0.5, (0.5 * aparm.airspeed_min) / g.scaling_speed);
float scale_max = MAX(2.0, (1.5 * aparm.airspeed_max) / g.scaling_speed);
speed_scaler = constrain_float(speed_scaler, scale_min, scale_max);
``````

Given that speed scaler/ar is calculated by:

``````        speed_scaler = g.scaling_speed / aspeed;
``````

should not the max and min values be calculated the same way? i.e.:

``````    float scale_min = MIN(0.5, (g.scaling_speed / (1.5 * aparm.airspeed_max)));
float scale_max = MAX(2.0, (g.scaling_speed / (0.5 * aparm.airspeed_min)));
``````

Also, given that one can fly a quadplane in hover mode in FBWA mode (for example), shouldn’t we also have an assisted_flight test for this code along side the vtol mode test?:

``````    if (quadplane.in_vtol_mode() && hal.util->get_soft_armed()) {
// when in VTOL modes limit surface movement at low speed to prevent instability
``````

Hi Andrew,

I too have questions about the speed scaling equations. but in relation to the expnential nature of the lift equation vs the linear scaling that is coded in the firmware. Hopefully one of the devs can shed some light on these areas.

The scaling coded in the versions I’m familiar with is a 1/x function so is not linear. In the speed scalar calculation,

``````    speed_scaler = g.scaling_speed / aspeed;
``````

aspeed is the thing that is changing. Because it can go to infinity and towards zero it gets clipped

Hey Andrew,

I ran into a problem with my hydrofoil because the 1/x type function does not model the v^2 term of the lift equation correctly. The steeper slope decreasing the servo deflection should be at the higher throttle or speed instead of lower.

Should be the blue line shape and not the orange

But also, what you mentioned about the calculation does appear correct to me. As with my issue, it would appear that there are a lot of small mistakes in the speed scaling that are being masked by forgiving planes and PID loops!