You are on page 1of 19

Hanoi University of Science and Technology

DC Motor Controller
Embedded Control System Design

Supervisor: MSc Chu Đức Việt

Group 1:
Đoàn Đức Cương – 20181864
Vũ Minh Châu – 20181862
Phạm Ngọc Đạt – 20181870
Nguyễn Thành Nam – 20181909

Hanoi, 2022
1. Specifications
- Able to control 24V 120W DC motor
- Supply voltage: 24V

- Input:

Input Name Type Description


Speed Analog Controls the speed of motor 0-10V, 4-20mA
CW/CCW Digital, Controls direction of rotation of motor
Sinking - LOW: the motor rotates clockwise
- HIGH: the motor rotates counter-clockwise LOW: 0,8 – 2,4V, 4-20mA
Power Digital, Turns the motor on/off HIGH: 10,4 – 36V, 4-20mA
Sinking - LOW: the motor stops
- HIGH: the motor moves
- Output:

+ 2 relays (24V, 10A)

- Communication: RS-485, RS-422

- Built-in overload and overcurrent protection

- LCD displays stats of the motor

- 3 LEDs

+ LED 1 is ON if there is power supplied to motor/ is OFF otherwise

+ LED 2 is ON if the motor is moving/ is OFF otherwise

+ LED 3 is ON if the motor is rotating clockwise/ is OFF otherwise

2
2. Architecture Design

Block diagram

- Display: consists of LEDs and LCD indicating status of the motor

- Power block: regulates the voltage, supplies power to components in the circuit, protects circuit
against reverse polarity

- Input block: Isolates inputs and components inside the controller, makes the input voltage suitable for
MCU

- Microcontroller: Controls the operation of the system

- Output block: Amplifies the output signal from MCU

- H-bridge: Controls the speed and direction of rotation of the motor, protects the circuit against
overload and reverse polarity generated from motor

- Sensor block: measures current and voltage level

- Quadrature decoder: decodes the output of a quadrature encoder

- Transceiver: for RS-485 and RS-422 communication

3. Overview of the Circuit

3
Power block:

Input block:

4
H-bridge

Current sensor:

Relay output:

5
LCD and LED:

MCU and quadrature decoder

6
Transceiver:

4. Detailed Design
3.1. Display block

- LCD 1602: 5V

- LEDs: 5V

3.2. Power block


Consists of reverse polarity protection circuit, buck converter and voltage regulator

7
Overview of power block

3.2.1. Reverse polarity protection circuit

8
+ MOSFET IRF9540: Max drain to source voltage is -100V, much larger than 24V; max drain
current is -19A

+ Diode 1N4740: Nominal Zener voltage is 10V, smaller than gate-source voltage of MOSFET
(20V)

3.2.2. Buck converter

Topology of buck converter

- Reason for using buck converter and LDO:

The power not delivered to the load is lost as heat in LDO, LDO is inefficient when input voltage
is much greater than the voltage needed for the components. To lower the voltage, a switching
converter is more efficient as the input voltage is 24V and the components in the circuit need around
3,3-5V

After the voltage is lowered, LDO can be used for better noise management

- High-Voltage Input Integrated Switch Step-Down Regulator MCP16301H:

+ Max input voltage is 36V

+ Output voltage range: 2-15V

- Isolator B0505S/D:

+ Input voltage from 4,5-5,5V; 1KVDC isolation

+ Output voltage: 5V

+ Output current: 20-200mA

9
- Isolator B1212S/D:

+ Input voltage: 10,8-13,2V

+ Output voltage: 12V

+ Output current: 9-83mA

Calculation to obtain 5V output voltage


𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜
𝑅𝑅𝑇𝑇𝑇𝑇𝑇𝑇 = 𝑅𝑅𝐵𝐵𝐵𝐵𝐵𝐵 × ( − 1)
𝑉𝑉𝐹𝐹𝐹𝐹
With 5V output voltage:

𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜 = 5𝑉𝑉
𝑉𝑉𝐹𝐹𝐹𝐹 = 0,8𝑉𝑉
𝑅𝑅𝐵𝐵𝐵𝐵𝐵𝐵 = 10𝑘𝑘Ω
→ 𝑅𝑅𝑇𝑇𝑇𝑇𝑇𝑇 = 52500Ω ~ 52,3𝑘𝑘Ω
Inductor
0,22𝑉𝑉 𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜 𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜 5
= → 𝐿𝐿 = = = 22𝜇𝜇𝜇𝜇
𝜇𝜇𝜇𝜇 𝐿𝐿 0,22 0,22

Calculation to obtain 12V output voltage


𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜2
𝑅𝑅𝑇𝑇𝑇𝑇𝑇𝑇2 = 𝑅𝑅𝐵𝐵𝐵𝐵𝐵𝐵2 × ( − 1)
𝑉𝑉𝐹𝐹𝐹𝐹
𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜2 = 12𝑉𝑉
𝑉𝑉𝐹𝐹𝐹𝐹 = 0,8𝑉𝑉
𝑅𝑅𝐵𝐵𝐵𝐵𝐵𝐵2 = 10𝑘𝑘Ω
→ 𝑅𝑅𝑇𝑇𝑇𝑇𝑇𝑇2 = 140𝑘𝑘Ω
Inductor
0,22𝑉𝑉 𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜2 𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜2 12
= → 𝐿𝐿2 = = = 54𝜇𝜇𝜇𝜇
𝜇𝜇𝜇𝜇 𝐿𝐿2 0,22 0,22
Input capacitor selection: input capacitance between 4.7 µF and 10 µF is recommended for most
applications -> Choose 𝐶𝐶𝐼𝐼𝐼𝐼 = 10𝜇𝜇𝜇𝜇

Output capacitor selection: According to datasheet, 𝐶𝐶𝑂𝑂𝑂𝑂𝑂𝑂 is recommended to be 20𝜇𝜇𝜇𝜇

Diode: B0540WS-7 (Rating: 40V; 0,5A)

10
3.2.3. Low-drop regulator

LF33CV: max input voltage is 40V, output voltage is 3,3V

LF50CV: max input voltage is 40V, output voltage is 5V

3.3. Input block

Overview of input isolation block

11
3.3.1. Digital inputs

Dual-channel digital input receiver ISO1212

+ Lower power consumption than optocouplers

+ Supports 9-300V DC and AC digital input design using external resistors

+ High input voltage range with reverse polarity protection: ±60𝑉𝑉

+ Supply range: 2,25-5,5V

+ Provides ESD protection

According to the datasheet, 𝑅𝑅𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 = 562Ω, 𝑅𝑅𝑇𝑇𝑇𝑇𝑇𝑇 = 1𝑘𝑘Ω is recommended if maximum threshold
voltage required is around 11V

3.3.2. Analog input

12
The transfer characteristics of this amplifier are shown in Fig. 7.

The input stage consists of a servo amplifier, U1, which controls the LED drive current. The servo
photodiode is operated with zero voltage bias. This is accomplished by connecting the photodiodes
anode and cathode directly to U1’s inverting and non-inverting inputs. The characteristics of the servo
amplifier operation are presented in Fig. 7a and Fig. 7b. The servo photocurrent is linearly proportional
to the input voltage, IP1 = Vin/R1. Fig. 7b shows the LED current is inversely proportional to the servo
transfer gain, IF = IP1/K1. The servo photocurrent, resulting from the LED emission, keeps the voltage at
the inverting input of U1 equal to zero. The output photocurrent, IP2, results from the incident flux
supplied by the LED. Fig. 7c shows that the magnitude of the output current is determined by the output
transfer gain, K2. The output voltage, as shown in Fig. 7d, is proportional to the output photocurrent
IP2. The output voltage equals the product of the output photocurrent times the output amplifier’s
trans resistance, R2
𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜 𝐾𝐾2 × 𝑅𝑅2
=
𝑉𝑉𝑖𝑖𝑖𝑖 𝐾𝐾1 × 𝑅𝑅1
Equation above shows that the composite amplifier transfer gain is independent of the LED forward
current. The K2/K1 ratio reduces to IL300 transfer gain, K3. This relationship is included in equation
below. This equation shows that the composite amplifier gain is equal to the product of the IL300 gain,
K3, times the ratio of the output to input resistors.
𝑉𝑉𝑜𝑜𝑜𝑜𝑜𝑜 𝐾𝐾3 × 𝑅𝑅2
=
𝑉𝑉𝑖𝑖𝑖𝑖 𝑅𝑅1
IP1, resulting from the peak input signal swing. This current is the product of the LED drive current, 𝐼𝐼𝐹𝐹 ,
times the servo transfer gain, K1. For this example, the Iout max is equal to the largest LED current signal
swing, i.e., 𝐼𝐼𝐹𝐹 = 𝐼𝐼𝑜𝑜𝑜𝑜𝑜𝑜 𝑚𝑚𝑚𝑚𝑚𝑚 .

𝐼𝐼𝑃𝑃1 = 𝐾𝐾1 × 𝐼𝐼𝑜𝑜𝑜𝑜𝑜𝑜 𝑚𝑚𝑚𝑚𝑚𝑚


𝐼𝐼𝑃𝑃1 = 0,012 × 15𝑚𝑚𝑚𝑚
𝐼𝐼𝑃𝑃1 = 180𝜇𝜇𝜇𝜇
The input resistor, R1, is set by the input voltage range and the peak servo photocurrent, 𝐼𝐼𝑃𝑃1 . Thus R1 is
equal to:
𝑉𝑉𝑖𝑖𝑖𝑖 1𝑉𝑉
𝑅𝑅1 = = = 5,6 𝑘𝑘Ω
𝐼𝐼𝑃𝑃1 180𝜇𝜇𝜇𝜇

13
determining the value of the trans resistance, R2, of the output amplifier. R2 is set by the composite
voltage gain desired, and the IL300’s transfer gain, K3. Given K3 = 1.0 and a required

Vout/Vin = G = 1.0,

the value of R2 can be determined.


𝐺𝐺 1
𝑅𝑅2 = 𝑅𝑅1 = 5,6𝑘𝑘Ω × = 5,6 𝑘𝑘Ω
𝐾𝐾3 1

LM2901

+ Power supply range: 2-36V

+ Low supply current drain: 0.9mA

IL300: Isolation rated voltage 4420 Vrms

3.4. H-bridge

Topology

Using boost trap ic to stabilize the voltage at the gate of the mosfet. In our project we use driver ir2184
to control 4 mosfet.

- Output source/sink current capability 1.4A/1.8A

- Gate drive supply range from 10 to 20V

- And we use reference configuration in datasheet to design the driver.

N-channel MOSFET: IRF460

- Max drain-to-source voltage: 500V >> 24V

14
- Max source current: 21A >> 5A

- Switching time (Ton and Toff) less than 100 ns

Half-bridge driver IR2184

To make sure the switching operation of the MOSFETs are safe from short-circuit, we use IC IR2184 to
create a delay.

- High side floating max voltage: 6,25V

- Max low side input voltage: 25,3 V

3.5. Sensor block

Current sensor ACS772ECB:

+ Current sensing range: 0-50A

+ Sensitivity = 10mV/A

+ Can measure current bidirectionally

+ 2,5𝜇𝜇𝜇𝜇 output response time

+ 200kHz Bandwidth

+ Output voltage propotional to sampled current, can be processed by ADC of MCU

15
3.6. Output block

PC817

+ Max reverse voltage: 6V

+ Max collector-emitter voltage: 80V

The forward voltage across the infrared LED with a forward current of 4mA should be about 1,2V, which
means 3,3 – 1,2 = 2,1V should be developed across Ri

Therefore, Ri = 2,1V/4mA = 525V -> Choose Ri = 500Ω

3.7. Microcontroller
- Requirements:

+ Number of I/O pins: 38 (8 for LCD, 3 for LED, 2 for sensors, 12 for decoder, 3 for input, 2 for
outputs, 4 for H-bridge, 4 for communication)

+ Number of ADC channels: 2 (2 for sensors)

+ Number of DAC channels: 1

+ Number of PWM pins: 4

+ Simultaneous-Sampling ADC

- Chosen component: STM32F358CCT6

+ 4x12-bit ADC, 38 ADC channels

+ 2x12-bit DAC

+ 2x16-bit PWM timer

+ 38 I/Os

+ Supports I2C, suitable for interfacing with LCD

16
3.8. Quadrature decoder

HCTL2032

- Interfaces encoder to MCU

- High noise immunity

- 14MHz clock operation

3.9. Communication

ISO1410BD Isolated RS-485/RS-422 Transceiver

- Provides isolation and ESD protection

TVS Diode SM712

- Provide ESD protection

- Working voltage: -7 to 12V

17
4. Finite State Machine
Variables:
r - the direction of rotation (r = 1 => change the direction of rotation)
s - the desired speed
cs - the current speed
p - the state of motor on/off (p = 1 for on, p = 0 for off).

States:
ILDE – the motor remain current state before receiving different signals
STOP – the motor stop (p = 0)
SPEED UP – when s > cs, the motor speed up to get the desired speed
SPEED DOWN – when s < cs, the motor speed down to get the desired speed
CHANGE DIRECTION – the motor change the direction of rotation

Code Template:

#define STOP 0
#define IDLE 1
#define SPEEDUP 2
#define SPEEDDOWN 3
#define CHANGEDIRECTION 4
void Dcmotorcontrol() {
int state = STOP;

18
while (1) {
switch(state) {
STOP: p = 0; r = 0;
if (p == 1) {state = IDLE;}
break;
IDLE: p = 1; r = 0;
if (p == 0) {state = STOP;}
if (s > cs) {state = SPEEDUP;}
if (s < cs) {state = SPEEDDOWN;}
break;
SPEED UP: p = 1; r = 0;
if (p == 0) {state = STOP;}
if (!(s > cs)) {state = IDLE;}
break;
SPEED DOWN: p = 1; r = 0;
if (p == 0) {state = STOP;}
if (!(s > cs)) {state = IDLE;}
break;
CHANGE DIRECTION: p = 1; r = 1;
if (r == 0) {state = IDLE;}
break;
}
}
}

19

You might also like