0
0
Simulinkdata~30 mins

Speed control with PID in Simulink - Mini Project: Build & Apply

Choose your learning style9 modes available
Speed control with PID
📖 Scenario: You are working on a simple speed control system for a motor. The motor speed needs to be controlled to reach a target speed smoothly and accurately. You will use a PID controller concept to adjust the motor speed based on the error between the target speed and the current speed.
🎯 Goal: Build a simple Python program that simulates a motor speed control using a PID controller. You will create the data for speeds, set PID parameters, apply the PID control logic, and output the adjusted motor speeds.
📋 What You'll Learn
Create a dictionary with current motor speeds for three motors
Create a variable for the target speed
Write a loop that calculates the PID control output for each motor
Print the adjusted speeds after applying the PID control
💡 Why This Matters
🌍 Real World
PID controllers are widely used in real machines like motors, robots, and vehicles to keep speeds or positions steady and accurate.
💼 Career
Understanding PID control logic is important for roles in automation, robotics, and control systems engineering.
Progress0 / 4 steps
1
Create current motor speeds dictionary
Create a dictionary called current_speeds with these exact entries: 'motor1': 45, 'motor2': 50, 'motor3': 55 representing the current speeds of three motors.
Simulink
Hint

Use curly braces to create a dictionary with keys as motor names and values as speeds.

2
Set the target speed
Create a variable called target_speed and set it to 60 representing the desired speed for all motors.
Simulink
Hint

Just assign the number 60 to the variable named target_speed.

3
Calculate PID control output for each motor
Create an empty dictionary called adjusted_speeds. Use a for loop with variables motor and speed to iterate over current_speeds.items(). For each motor, calculate the error as target_speed - speed. Then calculate the adjusted speed as speed + 0.1 * error (this simulates a simple proportional control). Store the adjusted speed in adjusted_speeds with the motor as the key.
Simulink
Hint

Use a for loop to go through each motor and calculate the new speed using the error and a proportional factor of 0.1.

4
Print the adjusted speeds
Write a print statement to display the adjusted_speeds dictionary.
Simulink
Hint

Use print(adjusted_speeds) to show the final adjusted speeds.