Table of ContentsControl Theory

In order to maintain a competitive edge over the rest of the racers, your car should be able to monitor its state and adapt the changing conditions. For instance, if a transmission is implemented, climbing the hill should be done in first gear. The programmed control should be able to detect when the car needs to switch into a lower or higher gear and then exectute that action. A powerful design methodology, called Closed Loop Control, will enable your program to be designed in such a manner that it can react to changing conditions without losing control of the car. Finite state diagrams will also also be introduced to help simplify the overall contorl design.

  • OPEN LOOP CONTROL

    In order to understand the power of closed loop control, let's take a look at open loop control. In an open loop controled system, commands are issued from the computer in a sequential manner. For instace, an open loop car controller might look like this:

    In this system, the car simply runs for 5 seconds in each gear and then stops. As long as the performance of the car is know, ie the 5 seconds is the optimal time running on this track to change gears, etc..., this method is fine. However, if the slightest variable is introduced during the race, the algorithm could fail.

    Consider the case where the batteries are a little low. The car will not go as fast as when the times were calcualated and therefore not switch gears with it should. This illustrates the need for some type of feedback from the system to help make decisions.

  • CLOSED LOOP CONTROL

    Closed loop control creates a feedback loop in the control that allows the controller to make decisions based on the state of the car, ie if the RPMs are above 5000, shift up a gear.

    Consider this new diagram:

    There is now a closed loop, the cycle between 'Shift Gear' and 'Check RPMs', that monitors the system state and adjusts the transmission accordingly. Notice that the 'Stop Engine' statement has been removed. This is because we are not testing any condition to see if we should stop it. Another loop can be added to the design that determines if the race is over by checking for a finish line or a certain elapsed time.

    A car controled in with a closed loop controller will be able to adapt better to the changing conditions of the track and of itself. Sensors can return almost any imformation you will need to design a very fast and efficient controller.

  • FINITE STATE DIAGRAMS

    The last design methodology we will discuss offers a higher level picture of how a controller can be designed. Finite State diagrams consist of a group of states that each define a state of the car. Connections between the states show how a the car can go from one state to the next. Each transition is determined from the output of a sensor from a closed loop control system. The finite state diagram will have a beginning state and an end state along with all the states inbetween. A finite state diagram depicting a car with a two speed transmission that starts on a green light and stops on a red light is shown below.

    The starting state is indicated with the ^ on the side of the circle and the finishing state has a thicker border. A loop inside of each state checks the senosr that monitors that condition that it changes states on and the puts it in the appropriate state. For instance, in state S, only the light is monitored. When it becomes green, it changes to state 1. In states 1 and 2 two conditions are checked. The RPMs can cause changes back and forth from 1 and 2 while a red light will cause both states to go to the final state. The functiosn that happen in each state, such as stopping the motor in state F, need not be defined in the diagram, but do need to be considered in the overall design.

    One nice feature of a finite state diagram is the ease in which it can be converted to a program. A global varible can be kept keep track of the state and a series of if...else statesmets or a switch statement can be determine what needs to be done based on the state.

    Following these simple design strategies will make designing the control of your car easier and allow for a more powerfule control. Most computer software design follows the methodologies described above along with design of control systems for almost every machine you encounter in daily life. Oids Homepage