* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
-void quadramp_set_2nd_order_vars(struct quadramp_filter * q,
- uint32_t var_2nd_ord_pos,
+void quadramp_set_2nd_order_vars(struct quadramp_filter * q,
+ uint32_t var_2nd_ord_pos,
-void quadramp_set_1st_order_vars(struct quadramp_filter * q,
- uint32_t var_1st_ord_pos,
+void quadramp_set_1st_order_vars(struct quadramp_filter * q,
+ uint32_t var_1st_ord_pos,
int32_t previous_var, previous_out ;
if ( q->var_1st_ord_pos )
int32_t previous_var, previous_out ;
if ( q->var_1st_ord_pos )
if ( q->var_1st_ord_neg )
var_1st_ord_neg = -q->var_1st_ord_neg ;
if ( q->var_2nd_ord_pos )
if ( q->var_1st_ord_neg )
var_1st_ord_neg = -q->var_1st_ord_neg ;
if ( q->var_2nd_ord_pos )
/* var_2nd_ord_pos > 0 */
/* real EQ : sqrt( var_2nd_ord_pos^2/4 - 2.d.var_2nd_ord_pos ) - var_2nd_ord_pos/2 */
ramp_neg = -sqrt( (var_2nd_ord_pos*var_2nd_ord_pos)/4 - 2*d*var_2nd_ord_pos ) - var_2nd_ord_pos/2;
/* var_2nd_ord_pos > 0 */
/* real EQ : sqrt( var_2nd_ord_pos^2/4 - 2.d.var_2nd_ord_pos ) - var_2nd_ord_pos/2 */
ramp_neg = -sqrt( (var_2nd_ord_pos*var_2nd_ord_pos)/4 - 2*d*var_2nd_ord_pos ) - var_2nd_ord_pos/2;
/* try to set the speed : can we reach the speed with our acceleration ? */
/* si on va moins vite que la Vmax */
if ( previous_var < var_1st_ord_pos ) {
/* try to set the speed : can we reach the speed with our acceleration ? */
/* si on va moins vite que la Vmax */
if ( previous_var < var_1st_ord_pos ) {
/* deceleration would be to high, we increase the speed */
/* si rampe deceleration active ET qu'on ne peut pas atteindre Vmax,
* on sature Vmax a Vcourante + deceleration */
if (var_2nd_ord_neg && ( var_1st_ord_pos - previous_var < var_2nd_ord_neg) )
var_1st_ord_pos = previous_var + var_2nd_ord_neg;
}
/* deceleration would be to high, we increase the speed */
/* si rampe deceleration active ET qu'on ne peut pas atteindre Vmax,
* on sature Vmax a Vcourante + deceleration */
if (var_2nd_ord_neg && ( var_1st_ord_pos - previous_var < var_2nd_ord_neg) )
var_1st_ord_pos = previous_var + var_2nd_ord_neg;
}
/* same for the neg */
/* si on va plus vite que la Vmin (en negatif : en vrai la vitesse absolue est inferieure) */
if ( previous_var > var_1st_ord_neg ) {
/* same for the neg */
/* si on va plus vite que la Vmin (en negatif : en vrai la vitesse absolue est inferieure) */
if ( previous_var > var_1st_ord_neg ) {