So I was working on a project and trying to figure out how to do auto-trim and while I wasn't entirely successful I made some progress. The rotators deflect too much and cause the plane to wobble and doesn't let it pitch the way it needs to. I used two equations on two different rotators due to the way the graph needed to be shaped:
(PitchRate<0)*smooth(-clamp(log10(-PitchRate+1)/1.7,-1,1),.2)
and
(PitchRate>0)*smooth(clamp(log10(PitchRate+1)/1.7,-1,1),.2)
Smooth didn't help me a whole bunch and using round on Pitch Rate won't help with small differences in PitchRate. If yall got any ideas it would be very much appreciated. Maybe I could just use a linear graph to remove the need for two equations but idk if the lack of curve will make it overpowered again.
Well, I tried to make auto trim.
13.9k ChrisPy
3.6 years ago
that top one says PitchRate<0
How do I turn this into MCAS
clamp((Trim-PitchRate/5)/20*clamp01(smooth(Pitch,1)=0)+
smooth(sign(Trim-PitchRate/5)*clamp01(TAS>5),abs(Trim-PitchRate/5)/2
*clamp01(smooth(Pitch,1)=0)*clamp01(TAS>5)+clamp01(TAS<5)),-1,1)
try this. another type of PID but replace sum() with smooth(sign(target-current),abs(target-current)) to prevent overvalue
@edensk sp keeps doing formulas correct until i hit the reset button and it keeps saying NaN
heres the formula which should work
DebugExpression
clamp01(Activate5=1)*clamp(smooth(rate(Altitude)/TAS*10,.5),-1,1)
@ChrisPy increasing the derivative ensures it doesn't oveshoot by slowing everything down, you might wanna decrease it a bit.
Regarding the proportional, increase it till the plane starts wobbling, then divide that value by half
@edensk the problem im having is that it adjusts to slow and i cant really change that. So I have to have it not change the value while I'm moving the stick around. Any ideas?
@edensk so its not really responding fast enough so i increased the proportional and the derivative but it still doesnt respond fast enough
@ChrisPy you're welcome man, good luck! If you need more help you know who to ask
now it makes sense thank you!
@edensk ahhhhh i get it now
it will fight against your pitch commands though, specially because of the integral
@ChrisPy if that's what you want, sure
@edensk why shouldn't I just put 0 for the target and PitchRate for the variable
@ChrisPy if the target is Pitch*20 and pitch is 0 then the pid will try to maintain 0 pitchrate...
@edensk ok thank you but if I wanted to have 0 pitch rate what would i put in there
Also, the output of the PID function happens to be more or less the same than
(variable-target)*p + sum(variable-target)*i + rate(variable-target)*d
meaning you don't really have to use a pid but it's easier to use one
@ChrisPy
PID(target,variable,p,i,d)
target will be the value you want your variable to be, variable is self explanatory, p is the gain, i is the retarded thing- I mean the sum of the error, and d the derivative, which smoothens the output to prevent overshooting.
you can set the target to Pitch*20 and the variable to PitchRate so that the PID will try to maintain 20 degrees per second when full pitch up is applied.
you can go here to learn how to tune p,i and d. (use small values from 0.001 to 0.1 though)
I personally dislike the integral for certain reasons, but it's usually necessary for complete stability.
@edensk idk how to use it m8 no one is explaining it well i tried to do what toxicgamer88 said but it doesn't work. I've tried multiple sources
PID is the way to go
you tried
@WHlTE more AOA???
@2Papi2Chulo noice I was considering there too!
@ChrisPy thats awesome. I'm trying to go to embry riddle next year.
@toxicgamer88 hmm tried it but currently it just only uses the values of 1 and -1
@2Papi2Chulo or another aerospace company after I get out of college Im going to Wichita State University this coming fall