# Help me understand the usefulness of control theory please

1. Aug 27, 2015

### knight92

I am looking at control theory but I don't understand how this is used in real systems.

Lets take an example of a cruise control system on a car which is also a control system. I can use an embedded computer connected to a hall effect sensor which measures the speed of the vehicle and also connect it to the throttle input which controls the speed of the vehicle. From a programmers perspective, I can just simply use if else statements to control the vehicle's speed e.g. if the hall effect sensor reads a significant drop in vehicle speed due to an upwards hill the the throttle input is increased until the desired speed is reached again and vice versa for a downwards hill. Why would I need transfer functions etc? Or can you give me an example where something like transfer functions and things like that would be used?

2. Aug 27, 2015

Sure you could tell the cruise control to just hit the gas when the speed drops, but control theory would help you do this in a way that doesn't make the speed oscillate about the setpoint, that doesn't make the vehicle occupants sick, that uses fuel efficiently, and other such niceties like that. You want that acceleration to be smooth and end on your speed of choice, not abrupt and jerky.

3. Aug 27, 2015

### knight92

Ok can you give me an example of what sort of equations one would use to ramp the throttle signal up to make the acceleration smooth? What if the speed is linearly proportional to the throttle, can I not just use that relationship in a loop to ramp it until the speed is reached? That way the acceleration would be smooth wouldn't it? Although I can kind of see how overshoot percentage could be used to reduce the oscillation if the throttle input is too much.

4. Aug 27, 2015

5. Sep 7, 2015

### Randy Beikmann

One thing that helped me to understand controls theory (still no expert) is to think about it as an oscillatory system, as boneh3ad has done. Consider a cruise control system that increases the throttle proportional to how much the speed is below the setpoint (the error). Now your change in torque is some gain times the error: dT = -K dv. Then this is much like a spring mass system where the spring force is proportional to displacement from equilibrium (dF = -k x). You know that a spring/mass system with no damping will oscillate forever. So will a cruise control system like this. To "damp out" the oscillation, you need to put in a term related to the rate of change of speed. So it would look like dT = -K1 (v-v_set) - K2 dv/dt. Depending on what K1 and K2 are, and the mass of the vehicle, etc., the system could respond quickly (high natural frequency) or slowly (low natural frequency), and be stable (exponentially decay of oscillations) or unstable (exponential growth of oscillations).
The K1 and K2 terms are gains you'd set in a PID (proportional/integral/differential) controller. the K1 above tunes the response to the speed error, and K2 tunes the response to the rate of change of error.
Again, I'm not a controls expert, so some of the details above might need to be tweaked a bit. But the main thing is that the control system will generally produce an oscillatory response of what's controlled (here speed). To get a quickly-responding system (large K1) you risk instability, so tuning in damping is essential.

6. Sep 9, 2015

### sgb27

If speed were linearly proportional to the throttle you wouldn't need a control system!

Anyway it sounds like what you are describing to do in code is essentially what a PID controller does. Because PID controllers have been studied a lot (they are used everywhere) there is a lot of information around about how best to tune them to a particular system. Sure, have a play about trying to develop something from scratch, it will be a useful learning experience. But also then look up PID controllers. The next system you are looking to control might not be so fast to respond as a car (eg heating a house) and using a trial-and-error approach would just take forever to get right.

7. Dec 21, 2015

### knight92

Hi, I am sorry for a late reply to my old thread but I went away and did some more learning and thought it will be better to ask the question here.

I do now somewhat understand what the usefulness is but still don't quite get many things e.g.

A transfer function is a ratio of output/input Laplace right? And if I wanted to control a rolling ball then would I need to find the equation of motion of the ball which will be the output differential equation and Laplace transform it but what if the input to the rolling ball was a baseball bat, how would I even go on to finding the differential equation for that? Am I even on the right path? As I understand it, I can use the transfer function to control how hard to hit the ball with a bat to achieve a certain speed?