Speed Control
Speed Control
speed of a system based on three inputs: desired speed, current speed, and
the error between the desired and current speeds. The two outputs are the
control signal to increase or decrease the speed and the magnitude of the
control signal.
Inputs:
1. Desired speed: This input measures the target speed of the system. It can
have low, medium, and high values.
2. Current speed: This input measures the actual speed of the system. It can
have low, medium, and high values.
3. Error: This input measures the difference between the desired and current
speeds. It can have negative (slowing down), zero (constant), and positive
(accelerating) values.
Outputs:
Fuzzification: The inputs are fuzzified into linguistic terms to capture the
uncertainty in the input values.
Rules: A set of if-then rules is used to translate the inputs into outputs. For
example, if the desired speed is high and the error is negative, then the
control signal should be positive and the magnitude should be high.
Defuzzification: The outputs are defuzzified into crisp values, which can be
used to control the system.
Here are some example rules for a fuzzy logic system for speed control:
1. If the desired speed is low, the error is negative, and the current speed is low, then
the control signal should be negative and the magnitude should be low.
2. If the desired speed is low, the error is zero, and the current speed is low, then the
control signal should be zero and the magnitude should be low.
3. If the desired speed is low, the error is positive, and the current speed is low, then
the control signal should be positive and the magnitude should be low.
4. If the desired speed is medium, the error is negative, and the current speed is
medium, then the control signal should be negative and the magnitude should be
medium.
5. If the desired speed is medium, the error is zero, and the current speed is medium,
then the control signal should be zero and the magnitude should be low.
6. If the desired speed is medium, the error is positive, and the current speed is
medium, then the control signal should be positive and the magnitude should be
medium.
7. If the desired speed is high, the error is negative, and the current speed is high, then
the control signal should be negative and the magnitude should be high.
8. If the desired speed is high, the error is zero, and the current speed is high, then the
control signal should be zero and the magnitude should be low.
9. If the desired speed is high, the error is positive, and the current speed is high, then
the control signal should be positive and the magnitude should be high.
These rules are just an example, and can be modified or extended depending on the
specific requirements of the system.
A fuzzy logic system for speed control with three inputs and two outputs can be designed to
control the speed of a vehicle based on the input variables such as the distance to the vehicle
ahead, the desired speed, and the road slope.
1. Distance to the vehicle ahead: This input represents the distance between the current vehicle and
the vehicle in front.
2. Desired speed: This input represents the speed at which the driver wants to travel.
3. Road slope: This input represents the slope of the road.
The membership functions for the inputs and outputs would be defined to describe the
relationships between the inputs and outputs. For example, if the distance to the vehicle ahead is
low, the acceleration/deceleration output would be high, and if the road slope is steep, the brake
output would be high.
The rules for the fuzzy logic system would then be defined based on these relationships. For
example, if the distance to the vehicle ahead is low and the desired speed is high, the
acceleration/deceleration output would be high. If the distance to the vehicle ahead is low and
the road slope is steep, the brake output would be high.
Once the membership functions and rules have been defined, the fuzzy logic system can be
implemented in a software environment such as MATLAB or Python, and the inputs can be fed
into the system to obtain the outputs.
1. If the distance to the vehicle ahead is "Very Close" and the desired speed is "Very High", then the
acceleration/deceleration should be "High".
2. If the distance to the vehicle ahead is "Close" and the desired speed is "High", then the
acceleration/deceleration should be "Moderate".
3. If the distance to the vehicle ahead is "Far" and the desired speed is "Low", then the
acceleration/deceleration should be "Low".
4. If the road slope is "Very Steep" and the desired speed is "High", then the brake should be
"High".
5. If the road slope is "Steep" and the desired speed is "Moderate", then the brake should be
"Moderate".
6. If the road slope is "Flat" and the desired speed is "Low", then the brake should be "Low".
Note: The input and output terms (e.g., "Very Close", "Very High", "High", etc.) and the number of
rules will vary depending on the specific requirements of the system.
1. Define the membership functions for the inputs and outputs: The membership functions can be
defined using the fuzzy toolbox in MATLAB. The membership functions describe the
relationships between the inputs and outputs and determine how the inputs map to the outputs.
For example, the membership function for the distance to the vehicle ahead input could have
terms such as "Very Close", "Close", "Far", and "Very Far".
2. Create the fuzzy inference system: The fuzzy inference system (FIS) can be created using the
newfis function in the fuzzy toolbox. This function generates an empty FIS structure that can be
populated with the membership functions and rules.
3. Add the input and output variables to the FIS: The input and output variables can be added to
the FIS using the addvar function. The input variables represent the distance to the vehicle ahead,
the desired speed, and the road slope, while the output variables represent the
acceleration/deceleration and brake.
4. Define the rules: The rules can be defined using the addrule function in the fuzzy toolbox. The
rules describe the relationships between the inputs and outputs and determine how the inputs
map to the outputs. The rules are specified in the form of "IF [condition] THEN [consequence]".
For example, a rule could be: "IF distance to the vehicle ahead is Very Close AND desired speed is
Very High THEN acceleration/deceleration is High".
5. Evaluate the FIS: The FIS can be evaluated using the evalfis function. This function takes in the
inputs and returns the outputs based on the membership functions and rules defined in the FIS.
6. Plot the results: The results of the FIS evaluation can be plotted using the plotfis function. This
function displays the input and output variables and their relationships as defined by the
membership functions and rules.
This is a high-level overview of the steps to implement a fuzzy logic system for speed control in
MATLAB. For more information, please consult the MATLAB documentation for the fuzzy
toolbox.
Here is an example of how the code for defining the membership functions for an input
variable "distance to the vehicle ahead" might look:
css
distanceMF = [0 0 1 1; 0 0.5 0.5 1; 0 0 0 0];
input = 1;
distance = addvar(fis, 'input', 'distance to vehicle ahead', [0, 100], 'mf',
distanceMF);