The purpose of this lab is to get some practice with the basic ideas of control in the context of simulations of some simple but representative dynamical systems.
The following model describes a first order dynamical system with its initial conditions:
m o d e l M a i n ( s i m u l a t o r ) = i n i t i a l l y
x = 1 , x ' = -1 a l w a y s
x ' = 5 - x
Let us begin by considering an important technicality. In Acumen, one specifies more than the initial conditions usually needed for differential equations. In the above example, as a differential equation we would only need to specify the initial value forx, but here we also specify one forx’. For this model, the extra initialization
4.8 Lab: Exploring Control 75 will have no significant effect, as the equation in thealwayssection will update the value ofx’as soon as the simulation starts.
Going back to this system itself, this simple differential equation can be seen as a complete control system driving the value ofxto5using a negative feedback scheme where the speed with which x changes, that isx’is proportional to the difference between our target5and the current value ofx.
This type of controller will bring the value ofxrelatively quickly to be quite close to the target. If we want to speed up this process, we can multiply the term5-xby a factor greater than one.
Simulate the original model above. Next, add a gain factor as described above to see its effect on how the value ofxchanges over time. Confirm that changing the gain factor does not change the target value that the system seems to converge towards.
Change the target value to another value to confirm that the new controller (with the higher gain) still seems to converge to the target value you specified.
A disadvantage of such a controller is that the value ofxcan get arbitrarily close to the target, but will never really get there in any finite amount of time. This motives investigating second order systems. The simplest way to get a second order system is in fact to differentiate both side of the question above. This gives us the following model:
m o d e l M a i n ( s i m u l a t o r ) = i n i t i a l l y
x = 0 , x ' = 1 , x ' '= -1 a l w a y s
x ' ' = -x '
If we give the derivativex’the variable namey, then this equation isy’ = -y. This helps us see that this itself can be seen as a control system where we are driving the variableyto the target value0. This is a good property for our original model to have, where our explicit goal is to drive the value ofxto five, but we implicitly would also like to have the value ofxto stop changing when it reaches that value.
Explore modifying the above model to drive the value ofx’not to zero but rather to a non-zero speed, say 10. As a hint, you can look at our original model and how we drove the value ofxto 5 there. Run the simulation to verify that the model behaves as you expect.
But as long as we have an equation which we can reduce to a first order equation, we are not really exploring the full power of a second order equation. The following model is a more representative example of a second order system:
m o d e l M a i n ( s i m u l a t o r ) = i n i t i a l l y
x = 1 , x ' = 0 , x ' '= -1 a l w a y s
x ' ' = - x
Again, we can view this system as control system. Here, the acceleration is being used to actuate the system, and the value of the variablexis being driven via negative feedback to the target value of zero. At the same time, we can view this system as a spring mass system, where the acceleration, which is equal to the spring force, is proportional to the length of the string. With this analogy, however, we can expect the system will oscillate around the target rather than converge towards it. That said, we are making a bit of progress, since we are now able to get the value ofxto cross the target value. In a sense, what we need to do now is to get rid of the oscillation, or at least reduce it to an acceptable level.
Simulate the above system to verify this expectation.
Compared to the previous model above, we have lost the term that allowed us to drive the speed to zero. In a sense, we can “mix” the two effects by having both terms on the right-hand side of the equation, as in the following model:
m o d e l M a i n ( s i m u l a t o r ) = i n i t i a l l y
x = 1 , x ' = 0 , x ' '= -1 a l w a y s
x ' ' = - x -x '
This equation can also be seen as a control system where we are drivingxto zero and damping the actuation using the speedx’. The termx’is considered to damp the system because the higher the speed the lower the acceleration (as determined by the equation) will be. A key benefit of working with such a system is that now the variablexcan actually reach the intended value, overshoot it, but still gradually converge towards it.
Simulate the above to confirm these observations, and in particular, that the damping diminishes with time.
We can generalize the above model with the following template, introducing additional undefined variablesA,B,a,b:
m o d e l M a i n ( s i m u l a t o r ) = i n i t i a l l y
x = 1 , x ' = 0 , x ' '= -1 a l w a y s
x ' ' = - A *( x - a ) - B *( x ' - b )
The capital letter variables are gains, and the small letter variables are offsets. These variables remind us that we can tune the gain factor that we feedback to the actuation of acceleration, and we can choose target values for both position and speed as we see fit for our application.
4.9 Project: Acceleration-Based Player for Ping Pong Robot 77