I am currently implementing more things into my model of a common kitchen / manufacturing scale and came up with the idea to assign different values to the gain variables of the PID controlling the system. The manner after which different values should be assigned to my variable is the following:
Assume this were the signal the controller reacts to (e.g. a voltage that is directly linked to the angular velocity)
Now i would like to assign a different value for every "section" of my signal. By "section" I am referring to the parts of the signal between two neighbouring zeros of the function.
This would allow me to control the behavior of my system in a very precise manner. (Instead of just applying constant or time depended gain variables).
The actual question:
Is it actually possible to implement such a behavior with adequate performance---remember that the gain variables are part of an equation inside
NDSolve and the whole thing should be so responsive that it is (still) usable with dynamics.
The only way i can think of would be something like a nested
If construct that jumps to a deeper level when
signal==0 appears, assigns a new value to the gain variables and then keeps looking out for another
signal==0, then jumps to the next level, and so on and so forth.
...sounds pretty slow to me and therefore I did't even consider to actually try it out. Hopefully someone else out there has a better idea how to solve the issue. The next step, considered someone came up with a nice idea, would be to make the transition from one gain value to the next smooth (maybe something using
Interpolation?). I would guess this had a better impact on the continuity of the system response.
Addition Using the suggestion concerning the "EventLocator" method for NDSolve, that came from the comments below, I actually managed do get the function to find the positions where the value of my control variable is zero (and e.g. print their positions). Now I am looking for an elegant way to tell "EventAction" what to do with my gain variables.
As mentioned before, I would like to use a list of values (that can be controlled by sliders) that than may be assigned to the first few segments detected by EventLocator (naturally it detects more segments than i actually need).
Another issue yet to solve is to smoothen the transition from one gain value to another between the various segments. I guess without smooth transitions the whole system response will get "jumpy"