o Control the machine through keyboard and interact with users through LCD o 2 modes of operation: - Continual mode mode 1: enter speed through keyboard - Periodical mode mode 2: enter n
Trang 1EMBEDDED CONTROL SYSTEM DESIGN
Rotating Welding Positioner
Trang 21
TABLE OF CONTENTS
1 Rotating welding positioner 3
2 Specifications 3
3 Architecture design 4
3.1 User interface 5
3.2 24V-to-5V DC/DC converter 5
3.3 Voltage regulator 5
3.4 MCU block 5
4 Solution selection 5
4.1 LCD & keyboard 5
4.2 Emergency stop button 6
4.3 24V-to-5V DC/DC converter 6
4.4 Low dropout regulator: 6
4.5 Isolation 7
4.6 MCU 7
5 Schematic diagram 7
5.1 Digital input 11
5.2 Digital output 13
5.3 Analog input (AI) 16
5.4 Power block 18
5.5 Overall MCU circuit with keyboard, LCD and button 19
6 Software design 21
6.1 Finite state machine 21
6.1.1 User interface 21
6.1.2 Control unit 24
6.2 Software structure 25
Trang 32
TABLE OF FIGURES
Figure 1 System architecture 4
Figure 2 SPBW03F-05 6
Figure 3 LP5907MFX 3.3/NOPB 7–
Figure 4 PC817 7
Figure 5 MCU and user interface block 8
Figure 6 Digital output and analog input block 9
Figure 7 Digital input block 10
Figure 8 Digital Input 11
Figure 9 Digital Output npn type 13
Figure 10 Digital output pnp type 15
Figure 11 Analog input 16
Figure 12 Power supply rails diagram 18
Figure 13 Isolated DC/DC 24V/5V 18
Figure 14 Voltage regulator (5V-3.3V) using LDO LP5907MFX-3.3/NOPB 19
Figure 15 User interface 19
Figure 16 Emergency button circuit 20
Figure 17 User interface finite state machine 21
Figure 18 Mode selection flow chart 22
Figure 19 Setting flow chart 22
Figure 20 Keyboard specification 23
Figure 21 Control unit finite state machine 24
Trang 43
• Overview:
o Rotating welding positioner is used to assemble work pieces
o The users perform the welding process manually
• Features:
o Control the machine through keyboard and interact with users through LCD
o 2 modes of operation:
- Continual mode (mode 1): enter speed through keyboard
- Periodical mode (mode 2): enter number of welding points, pausing time after each point through keyboard
o Emergency stop: button
o LCD: Displaying
• Mode of operations
o Continuous mode: display the speed
o Periodic mode: display number of welding points
• Errors: too fast/ slow rotating speed (table), position error, motor error (receiving from motor drive)
Controller Specification
• 8 Digital Input: receiving the signal from the motor controller when occurring the error
in the motor
Trang 54
Type
of limit
Digital Input
VL (V)
IL (mA)
VH (V)
IH (mA)
Trang 65
• LCD: display in each mode of operation
o Mode 1 (continuous): display speed
o Mode 2 (periodical): display number of welding points, temporary stopping time
o Error notification
• Keyboard:
o Mode 1 (continuous): set the speed
o Mode 2 (periodical): set the number of welding points, temporary stopping time
• Button: let users emergency stop the machine
o Speed setting for mode 1
o Number of welding points and temporary stopping time settings for mode 2
• Read the signal regarding speed and position of welding table from rotating sensor of the table
o Mode 1: Receive the working speed of the table and notify error if the table is not working properly (too over/under speed)
o Mode 2: Receive and notify positioning error of the table
• Process the input from keyboard and sensor signal to display necessary information corresponding each mode in LCD as indicated in 3.1
• Process the input from keyboard and give command to motor controller to make the welding table work properly as users’ settings Receive motor error notification from motor controller
• Receive emergency signal from the button and stop the table immediately
• Requirements:
o LCD: display input data, mode of operation, table speed, number of welding points
o Keyboard: enter number of welding points at periodic mode, table speed at continual mode
• Solution:
Trang 76
o 4x4 keyboard (3.3V supply voltage)
o 128x64 LCD (3.3V supply voltage)
• Requirements: stop the machine in emergency situations
Trang 87
Figure 3 LP5907MFX–3.3/NOPB
• Requirements: isolating the MCU with DI, DO
• Solution: photocoupler PC817 (DI) and PC847 (DO)
o 1 pin for external button interrupt
o Pins for connecting rotating sensor from the table
• Solution:
Choose the microcontroller STM32F103RF
o Flash memory 768Kb, RAM 96Kb
o 51 pins I/O
o 3x12-bit ADC
Trang 12Digital Input
VL (V)
IL (mA)
VH (V)
IH (mA)
• Using op-amp as the comparator
• Isolated by photo coupler PC817
• Use TVS diode for ESD and transient voltage protection
• Clamping diodes for overvoltage/ under-voltage protection
• Calculation
Trang 1312
➢ Op amp comparator circuit
Trang 14A clamping circuit will bind the upper or lower extreme of a waveform to a fixed DC voltage
−0.6𝑉
Choose Schottky Diode SL110PL
✓ Maximum DC Blocking Voltage 100V
✓ Average Forward Current 1A
➢ Diode TVS
Diode TVS is used for protecting sensitive components against high voltage spikes from transient
or electrostatic discharge (ESD) and is selected according to the following parameters: working voltage, breakdown voltage and diode power
✓ Breakdown Voltage: 44.40 ÷ 49.10V
✓ Peak Pulse Power Dissipation: 600W
✓ Low impedance and fast response time
a, npn type:
Figure 9 Digital Output npn type
Trang 1514
• Isolated by photo coupler PC817
• ESD and transient voltage protection: using TVS diode
• Overvoltage/ undervoltage protection: clamping diodes
• Logic level: High (24V), Low (0V)
Diode TVS is used for protecting sensitive components against high voltage spikes from transient
or electrostatic discharge (ESD) and is selected according to the following parameters: working voltage, breakdown voltage and diode power
✓ Breakdown Voltage: 33.3 ÷ 36.8V
✓ Peak Pulse Power Dissipation: 600W
✓ Low impedance and fast response time
Diode D1 and D2 are the same as in Digital Input section
Trang 16➢ Diode TVS clamping diodes
Choose the same TVS diode and clamping diodes as in the npn type
Trang 1716
Figure 11 Analog input
Requirement:
• Input voltage: 0-10V
• Receive analog signal with filter
• Isolated MCU and overvoltage/ under-voltage protection
• ESD and transient voltage protection
• Quantity: 2
Solution:
• Isolated by unity gain amplifier
• RC low pass filter
• Clamping diodes for overvoltage/ under-voltage protection
• Use TVS diode for ESD and transient voltage protection
• SPI isolation using ADUM4154
Calculation:
• Voltage divider:
(because the input voltage of ADC range from 0 to 5V) We have:
Trang 1817
A clamping circuit will bind the upper or lower extreme of a waveform to a fixed DC voltage
Choose Schottky Diode SL110PL
✓ Maximum DC Blocking Voltage 100V
✓ Average Forward Current 1A
✓ Maximum Instantaneous Forward Voltage 0.6V
• Unity gain amplifier, it completely isolates the input side of the circuit from the output
side of the circuit We choose LM324
Output of LM324, choose RC low pass filter with cut-off frequency 100Hz
Diode TVS is used for protecting sensitive components against high voltage spikes from transient
or electrostatic discharge (ESD) and is selected according to the following parameters: working voltage, breakdown voltage and diode power
✓ Breakdown Voltage: 44.40 ÷ 49.10V
✓ Peak Pulse Power Dissipation: 600W
✓ Low impedance and fast response time
➢ Choose ADC MCP3204:
✓ 4 analog inputs (2 inputs for voltage and 2 inputs for current)
✓ ADC 12 bit
➢ SPI isolation using ADUM4154:
✓ Supports up to 17 MHz SPI clock speed
✓ 4 high speed, low propagation delay, SPI signal isolation channels
Trang 1918
➢ R 4 , R , R 5 6
Trang 2019
Figure 14 Voltage regulator (5V-3.3V) using LDO LP5907MFX-3.3/NOPB
Figure 15 User interface
High-speed external (HSE) clock oscillator: Choosing ECS ECS-2520MV-080-CN-TR
Trang 21LCD: choosing 10kΩ potentiometer to adjust the contrast of the LCD
Emergency button circuit: to avoid bounce effect, implementing a hardware debounce circuit
as shown in figure 14, connecting to 5V-tolerant PC12 pin of the MCU
Figure 16 Emergency button circuit
• Choosing Schmitt trigger ON Semiconductor NL17SZ14DBVT1G
o DC input voltage -0.5-6.5 V
The pull-up resistor should not be too low since it will consume more power, but not too high to lead to a weak pull-up Therefore, choosing the pull-up resistor value is as close to 1/10 of MCU pin impedance as possible Weak pull-up mode GPIO resistance of STM32F103RF is 40kΩ, so
Trang 22Figure 17 User interface finite state machine
➢ Mode selection: in the setting state, users can change the operation mode by pressing
RESET to enter “mode selection” In this state, press 1 or 2 means choosing mode 1 or 2 respectively
Trang 2322
Figure 18 Mode selection flow chart
• Press 1 to choose mode 1 and press 2 to choose mode 2
➢ Setting: enter speed (mode 1)/ number of welding points and pausing time (mode 2) into
the keyboard In case of continue operating like in the previous session, users only need to press ENTER
Figure 19 Setting flow chart
Trang 2423
to continue
start running If No (press 0), enter the parameters again
➢ Running: displaying the working information in each mode
➢ Warning: displaying the error in case the error is detected
Figure 20 Keyboard specification
Trang 2524
6.1.2 Control unit
Figure 21 Control unit finite state machine
➢ Idle: waiting while users entering the parameters
➢ If the operation mode is mode 1 (denoted by mode==1), the controller will set the table speed that users entered from the keyboard for the motor controller to control the rotating speed of the table as desired; if the operation mode is mode 2 (mode==2), the controller will set the number of welding points and pausing time for the motor controller to control the position and pausing time of the table
➢ While in operation, when users press PAUSE in the keyboard, value of pause variable becomes 1 then the table will temporarily stop rotating Press PAUSE once again (pause==0) to continue working normally
Trang 2625
➢ When errors occur (error==1), the controller enters the error state If errors are cleared (error==0), waiting 5s to re-enter normal state; if error are not cleared after 10s, the table and controller will be emergency stopped
➢ Press START again to restart the machine after emergency stop; now if errors are cleared, waiting 5s to re-enter normal operation
➢ Error: In both modes, check the error from the motor controller If there exist error
from the motor controller, jump to the emergency stop state Otherwise:
of the set speed), the controller will continuously recheck After 10s, if error still exist, go to the emergency stop state
set angle), the controller will continuously recheck After 10s, if error still exist,
go to the emergency stop state
Trang 2726
36 (press RESET) {state2 = if mode_selection ;}
37 (press ENTER) {State2 = if running ;}
59 (error == ) { state3 = if 1 error_state ;}
60 (button == ) {state3 = if 1 emergency_stop ;}
61 state4 = int idle ;
62 switch (state4))
63 {
64 idle :
65 (mode == ) {state4 = if 1 mode_1 ;}
66 (mode == ) {state4 = if 2 mode_2 ;}
Trang 2895 (error == && time == ) {state3 = if 0 5 normal ;}
96 (time >= && error == ) {state3 = if 10 1 emergency_stop ;}