I'm not 100% sure if the title is really representative of what I need. My apologies.
So I have a sketch that works for the most part, but in trying to tighten it up a bit, I've had a conceptual road block. Basically, an Uno controls an engine governor to maintain a constant RPM. It's a generator. My sketch uses the PID library to respond to changes in the RPMs as the load on the generator changes, and it works pretty well. BUT! PID values that are stable are also slow. About half the speed of the old mechanical governor. I can get much faster response with different PID parameters, but I get oscillations.
So I figured that perhaps I could add a load-sensing CT on the AC output and the Uno could monitor the active load and move the throttle plate to a pre-determined angle based on empirical data that I would determine manually. Perhaps drawing from a lookup table. I imagine that could get the governor to within a range where the PID would be closer and therefore less drastic. My problem is getting the code laid out properly.
In pseudo-code:
analogRead(AMPS);
lookup_throttle_angle_from_table;
myservo.write(table_value);
myPID(take_over);
myservo.write(PID_value);
I don't know how to effectively hand control of the servo back and forth between PID control and load lookup table control as needed. Any guidance?