From: Ben on
Hi all,

I'm supplementing an F-16 simulation with an automatic control system. The control theory is fairly straightforward, but I'm struggling to get a variable gain PID controller working, specifically for climbs/descents. Example: I need a low gain for large climbs of say, 10000 feet, and high gains for small climbs or altitude hold. This is proving difficult for me to implement--if I use switches, a function, or a look-up table for the gain based on the altitude error signal, it updates during the climb and causes instability/other problems. Instead of saying "I need to climb 10000 feet using X for a proportional controller" it keeps changing the gain every time a new error signal arrives.

What I need is a way for the system to record the initial climb request and deliver an appropriate gain, then, once the aircraft has completed the climb, change the gain. I'm looking at MATLAB functions and flags, etc. but I can't find any way to simply calculate and save the initial altitude error once, not every cycle. Any suggestions would be much appreciated!

Cheers,
Ben

P.S. My system is fairly simple: an altitude is requested, and the altitude error is fed through a gain block which supplies the climb rate controller with a signal. If I'm at altitude, the climb rate request is zero. Easy enough.