Lab 3 Control
Lab 3 Control
Objective:
a) To read the speed of dc motor through encoder using arduino and MATLAB.
b) To plot the step response of dc motor using experimental data.
c) To determine transfer function of a dc motor and compare theoretical and hardware
responses.
Apparatus
DC motor control apparatus
MATLAB in Laptop/PC
Explanation:
A first order control system is defined as a type of control system whose input-output
relationship (also known as a transfer function) is a first-order differential equation. A first-
order differential equation contains a first-order derivative, but no derivative higher than the
first order. The order of a differential equation is the order of the highest order derivative
present in the equation.
Result:
K = 75
T = 0.45
TF = 47.25
Task:
Write a MATLAB code to meet above objectives. A sample code is given below:
firstly check Arduino is connected to which port of PC/Laptop;
clear all;
a = arduino (‘COM port#’, ‘Uno’, ‘Libraries’, ‘rotaryEncoder’);
declare rotary encoder function;
use a ‘rateControl’ object from help, it will enable you to run a loop at a fixed frequency;
generate signals at arduino digital pins that will connect to motor driver;
generate PWM signal at arduino digital pin to enable motor driver;
use ‘readSpeed’ function to read the motor speed for 100 iterations;
after that disable PWM digital pin to stop motor;
generate a time vector;
Overall, these tasks illustrate the importance of understanding the behavior and dynamics of a
DC motor, as well as the need for accurate and reliable measurement and control systems in
order to optimize its performance in various applications.