0% found this document useful (0 votes)
47 views24 pages

Exp - Report 20195784

This document provides an overview of control system design and then discusses implementing a one-axis PID encoder DC motor control system. It covers the basic components and objectives of control systems as well as applications. The document then focuses on using a PID controller to regulate the behavior of a DC motor based on feedback from an encoder. It describes the hardware setup and provides code examples to control the motor speed and read the encoder values. The overall goal is to design a PID controller that can accurately control the motor's velocity.

Uploaded by

Huy Vũ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views24 pages

Exp - Report 20195784

This document provides an overview of control system design and then discusses implementing a one-axis PID encoder DC motor control system. It covers the basic components and objectives of control systems as well as applications. The document then focuses on using a PID controller to regulate the behavior of a DC motor based on feedback from an encoder. It describes the hardware setup and provides code examples to control the motor speed and read the encoder values. The overall goal is to design a PID controller that can accurately control the motor's velocity.

Uploaded by

Huy Vũ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

SCHOOL OF MECHANICAL ENGINEERING


*****

CONTROL SYSTEM DESIGN


Experiment Report

Instructor Prof. Hoàng Vĩnh Sinh


Student Name Vũ Anh Huy
Student ID 20195784
Group 6
Class 738370

Hanoi, December 2023


TABLE OF CONTENT

CHAPTER 1: OVERVIEW......................................................................................... 4
1.1. CONTROL SYSTEM DESIGN IN GENERAL ....................................................... 4
1.1.1. Introduction ........................................................................................................ 4
1.1.2. Objectives: .......................................................................................................... 4
1.1.3. Components: ....................................................................................................... 4
1.1.4. Types of Control Design Systems: ..................................................................... 5
1.1.5. Applications of Control Design Systems: .......................................................... 5
CHAPTER 2: ONE-AXIS PID ENCODER DC MOTOR CONTROL .................. 6
2.1. PID in General: .......................................................................................................... 6
2.2. One-Axis PID Encoder DC Motor Control: .............................................................. 6
2.3. Pin connection and block diagram ............................................................................ 8
2.4. Hardware ................................................................................................................... 9
CHAPTER 3: CONTROL DC MOTOR .................................................................. 10
3.1. Control DC Motor by using PWM mode (or analogWrite) .................................... 10
3.1.1. Result ................................................................................................................ 11
3.2. Control DC Motor using frequency. ........................................................................ 11
3.2.1. Result ................................................................................................................ 12
CHAPTER 4: CACULATE MOTOR VELOCITY USING ENCODER ............. 13
4.1. Reading encoder ...................................................................................................... 13
4.2. Calculate the velocity .............................................................................................. 15
CHAPTER 5: TRANSFER FUNCTION ................................................................. 16
5.1. Find the transfer function ........................................................................................ 16
CHAPTER 6: DESIGN THE PID CONTROLLER ............................................... 20
6.1. PID Controller ......................................................................................................... 20
6.1.1. Result: ............................................................................................................... 20
CHAPTER 7: USING PID TO CONTROL MOTOR ON ARDUINO ................. 22

2
TABLE OF FIGURES
Figure 1: Basic PID control procedure. ................................................................................ 6
Figure 2: The Electrical Components Pin Connection ......................................................... 8
Figure 3: Hardware ............................................................................................................... 9
Figure 4: PWM-based motor control Code ........................................................................ 10
Figure 5: Encoder ............................................................................................................... 13
Figure 6: Reading one signal only Code ............................................................................ 13
Figure 7: Reading two signals Code ................................................................................... 14
Figure 8: Reading four signals Code .................................................................................. 14
Figure 9: Calculating velocity code .................................................................................... 15
Figure 10: Arduino code to get the transfer function ......................................................... 16
Figure 11: Matlab code to get the data to find the tf .......................................................... 17
Figure 12: Transfer function calculated by System Identification ..................................... 19
Figure 13: Simulink model ................................................................................................. 20
Figure 14: Code in Adruino ................................................................................................ 24
Figure 15: Experience result ............................................................................................... 24

3
CHAPTER 1: OVERVIEW

1.1. CONTROL SYSTEM DESIGN IN GENERAL


1.1.1. Introduction
Control design systems are a critical component of modern engineering applications,
ranging from aerospace and automotive to manufacturing and robotics. These systems are
designed to regulate and monitor the behavior of complex systems, ensuring that they
operate efficiently and safely. In this report, we will provide an overview of control design
systems, their components, and their applications.
It plays a vital role in various engineering disciplines and industries. Involves the
process of developing and implementing control strategies to regulate and maintain desired
system behavior. This chapter will provide a comprehensive overview of control system
design, including its objectives, components, and key considerations.
1.1.2. Objectives:
The primary objective of control system design is to develop a system that ensures
stability, accuracy, and robustness in controlling a process or a system. The specific
objectives can vary based on the application but generally encompass the following:
 Stability: Ensuring that the system remains stable and does not oscillate or exhibit
unstable behavior during operation.
 Performance: Achieving the desired system response with minimal overshoot, settling
time, and steady-state error.
 Robustness: Designing a system that can handle variations in operating conditions,
disturbances, and uncertainties.
 Tracking: Ensuring accurate tracking of desired setpoints or references, allowing the
system to follow desired trajectories.
 Noise rejection: Suppressing the effects of measurement noise and disturbances to
maintain accurate control.

1.1.3. Components:
Control design systems consist of three primary components:

4
 The plant: refers to the system being controlled, which can be any physical or virtual
system with inputs and outputs.
 The controller: responsible for adjusting the inputs of the plant to achieve a desired
output.
 The feedback loop: used to monitor the output of the plant and adjust the controller's
inputs to achieve the desired output.

1.1.4. Types of Control Design Systems:


There are several types of control design systems:
 Including open-loop control systems operate without feedback, meaning that the output
is not monitored or adjusted based on the system's behavior.
 Closed-loop control systems are designed to adjust the system's behavior based on
feedback from the output.
 Feedforward control systems use information about the system's inputs to adjust the
output, without relying on feedback.

1.1.5. Applications of Control Design Systems:


Control design systems are used in a wide range of applications, including aerospace,
automotive, manufacturing, and robotics. In aerospace, control design systems are used to
regulate the behavior of aircraft and spacecraft, ensuring that they operate safely and
efficiently. In automotive applications, control design systems are used to regulate the
behavior of engines, transmissions, and other components. In manufacturing, control design
systems are used to optimize production processes and ensure consistent product quality.
In robotics, control design systems are used to regulate the behavior of robotic arms,
ensuring accurate and precise movements.
Modern engineering applications must include control design methods to make sure
that complicated systems run effectively and safely. These systems consist of several
components, including the plant, controller, and feedback loop, and can be designed for a
wide range of applications. As technology continues to advance, control design systems
will continue to play an increasingly important role in shaping the future of engineering.

5
CHAPTER 2: ONE-AXIS PID ENCODER DC MOTOR CONTROL

2.1. PID in General:


PID (Proportional-Integral-Derivative) control is a widely used technique for
controlling the behavior of systems based on feedback (Error! Reference source not
found.). In this report, we will discuss One-Axis PID Encoder DC Motor Control, a type
of control system that uses PID control to regulate the behavior of a DC motor.

Figure 1: Basic PID control procedure.

This controller is widely used in closed-loop control systems with feedback signals.
The task of PID helps to calculate the error value which is the difference between the
measured value of the variable parameter and the value desired setting.
2.2. One-Axis PID Encoder DC Motor Control:
One-Axis PID Encoder DC Motor Control is a type of control system that regulates
the behavior of a DC motor using feedback from an encoder. The system consists of a DC
motor, an encoder to measure the motor's rotation, and a PID controller to adjust the motor's
behavior based on feedback from the encoder. The PID controller adjusts the motor's input
voltage based on the difference between the desired output and the actual output, as
measured by the encoder. The proportional, integral, and derivative components of the
controller are used to adjust the motor's behavior based on the past, present, and future error
values, respectively. The electrical components is represented in the Table below.

6
Table 2.1: Electrical components

Components Figure Specifications


Encoder motor Rated voltage: DC 24V.
DS4573 Rated torque: 0.6kgf-cm.
W/EC-38P Rated speed: 2,000rpm.
(24V); Rated current: 1.3A.
No load speed: 2,800rpm.
No load current: 0.4A.
Weight: 406g.
Encoder Pulse: 432p/r

Driver Dual Number of PIN pins: 8PWM


BTS7960H capability up to 25 kHz.Control
Bridge input level: 3.3~5V. Working cycle:
Configuration 0 ~100%.

Arduino Mega - ATmega2560:


2560 Microcontroller;
- Operating voltage of this
microcontroller: 5volts;
- Recommended Input Voltage:
7-12volts;
- Input voltage: 6-20volts;
- Digital input/output pins are
54 where 15 of these pins will
supply PWM o/p;
- Analog Input Pins: 16;

7
- DC Current for each
input/output pin: 40 mA;
- DC Current used for 3.3V Pin:
50 mA;
- Flash Memory like 256 KB
where 8 KB of flash memory
is used with the help of
bootloader;
- Static random access memory
(SRAM): 8 KB;
- Electrically erasable
programmable read-only
memory (EEPROM): 4 KB;
- Clock (CLK) speed: 16 MHz;
- USB host chip: MAX3421E;
- Length of this board: 101.52
mm;
- Width of this board: 53.3 mm;
- Weight of this board: 36 g.
2.3. Pin connection and block diagram
The pin connection of electrical components is shown in the Figure below.

Figure 2: The Electrical Components Pin Connection

8
2.4. Hardware

Figure 3: Hardware

9
CHAPTER 3: CONTROL DC MOTOR

3.1. Control DC Motor by using PWM mode (or analogWrite)


 The Arduino platform offers the analogWrite() function for generating PWM output on
a pin of the Arduino board.
 When we link the PWM pin to the L298 driver, we gain the ability to regulate the
average voltage supplied to our DC motor. Adjusting this voltage allows us to manage
the speed of the DC motor accordingly.
 The analogWrite() function generates pulses with a default frequency of 1000Hz.
 Below is the code for PWM-based motor control

Figure 4: PWM-based motor control Code

10
3.1.1. Result

3.2. Control DC Motor using frequency.


Another approach to regulate a DC motor involves dispatching a single pulse to the
motor, the control of which is contingent on the frequency of pulse generation. This is
achieved by utilizing Timer 1 in compare mode to generate pulses with diverse periods or
frequencies. The accompanying code facilitates the implementation of this method :

11
3.2.1. Result

12
CHAPTER 4: CACULATE MOTOR VELOCITY USING ENCODER

4.1. Reading encoder


Our Encoder has two channels, A and B. By reading both channels simultaneously,
we can determine the direction of rotation as well as the position of the motor.

Figure 5: Encoder

Depending on how we are reading each channel of encoder we can increase the
accuracy of velocity as well as the position of motor.

Here is the code for reading one signal only (x1) (on rising of A channel):

Figure 6: Reading one signal only Code

13
Here is the code for reading two signals (x2) (on Rising of both A and B Rising):

Figure 7: Reading two signals Code

Here is the code for reading four signals (x4) (on both Rising and Falling of both A
and B):

Figure 8: Reading four signals Code

14
4.2. Calculate the velocity
When we have the Encoder Count, we can calculate the motor velocity by take the
number of Encoder Count divide by the time passed between each time we take the value.
After that we can get the real RPM by dividing the output by gear ratio and number
of pulses per rotation of encoder.

Here is the code

Figure 9: Calculating velocity code

15
CHAPTER 5: TRANSFER FUNCTION

5.1. Find the transfer function


To find the transfer function of our DC Motor system, we can use the System
Identification Toolbox in Matlab. In order to do that we need to create a input and measure
the output of our system, after that we put it to System Identification to find our transfer
function.
Here is the code for create a sin square wave as an input on Arduino:

Figure 10: Arduino code to get the transfer function

16
Here is the Matlab code:

Figure 11: Matlab code to get the data to find the tf

The transfer function calculated by System Identification:

17
18
Figure 12: Transfer function calculated by System Identification

From the results obtained from the Matlab tool, we get the form of the transfer
function of the block motor– driver DS4573 W/EC 38P (24V) and BTS7960H as follows:
0.0143
𝐺 (𝑠 ) =
𝑠 2 + 0.6732𝑠 + 0.08368

19
CHAPTER 6: DESIGN THE PID CONTROLLER

6.1. PID Controller


To find the PID for our system, we need to model our system in Simulink and use the
PID controller block to tune and find the suitable Kp, Ki, Kd for our system.

Figure 13: Simulink model

We use the Autotunning method to identify the Kp, Ki, Kd value, matlab code:

6.1.1. Result:

20
We get Kp = 92.8, Ki = 11.8, Kd = 124 with that we have Tr = 0.7709s, OS = 1%,

Ts = 1.1917s

21
CHAPTER 7: USING PID TO CONTROL MOTOR ON ARDUINO

7.1. In PWM mode


After we got the Kp, Ki and Kd value, we can apply it on Arduino code by calculating
error and the reference will be calculated by the formula:
𝑑𝑒
Ref = Kp * error + Ki * ∫ 𝑒𝑟𝑟𝑜𝑟 + Kd *
𝑑𝑡

Here is the code in Arduino

22
23
Figure 14: Code in Adruino

7.1.1. Result in real experience

Figure 15: Experience result

24

You might also like