Xiao Zhuohua, member of the first prize team of the 13th Wuhan University of Technology Electronic Design Competition, Gao Pengfei, Wang Biao, instructor Zhang Jialiang
The power supply circuit involved in the question mainly consists of two parts. The first part is a boost power supply, which is required to output a voltage of 15V when inputting 12V; the second part is a buck circuit, which provides working voltage for microcontrollers, measurement systems, etc., and the input voltage is still is 12V.
1.1.1 Boost power supply design
Option 1: Use LM2577 as the core chip
The LM2577 is a monolithic integrated circuit, and the chip is available in three different output voltage versions: 12V, 15V and adjustable. The advantages are that it requires few external components, is less expensive to design, and is simple to use.
And LM2577 has a wide voltage input range, up to 3.5V~40V, and has a built-in 52kHz oscillator. Moreover, the heat generated by the chip is small, and it can reach 15W without adding a radiator. After adding a radiator, it can reach an output power of 25W.
Option 2: Use LM5122 as the core chip
LM5122 is a high efficiency and high power density wide input voltage synchronous boost controller launched by Texas Instruments (TI). Supports input voltages from 3 V to 65V and output voltage ranges up to 100V. The controller is easily configurable and supports interleaved multi-phase operation to meet the needs of a variety of high-power applications.
Both of the above solutions can meet the requirements of the question. By comparing the performance of the two chips, we found that the high efficiency and high power characteristics of LM5122 are more prominent, which is of great help to the question. And the wide input and output of LM5122 facilitate circuit debugging. Therefore, LM5122 is selected as the core chip of the boost circuit.
1.1.2 Buck circuit design
This part of the circuit needs to provide working voltage for the microcontroller, measurement system, etc., so it is designed to step down and output two voltages of 5V and 3.3V; and the question requires the system quiescent current to be less than 5mA, so there are requirements for the chip performance of the circuit.
After consulting the information, we selected two chips, BL1117 and ME6206. The BL1117 chip has a low quiescent current of 2mA, and the output voltage is fixed or adjustable. The output accuracy of the ME6206 chip is about 2%, the output voltage range is 1.5 ~ 5.0V, and it also has the characteristics of low power consumption (8uA) and large output current (300mA).
Therefore, this part uses the BL1117 chip to reduce the 12V voltage to 5V, and uses the ME6206 chip to reduce the 5V voltage to 3.3V.
Option 1: L298N motor drive
The L298N circuit is simple and can realize the functions of forward and reverse rotation and speed regulation of the motor. It has good starting performance and large starting torque. It can control two DC motors at the same time. The working voltage of L298N can reach 36V, and the maximum current is 4A.
Solution 2: MOS tube motor driver
MOS tubes have good switching characteristics. The H-bridge circuit consists of 4 MOS tubes to control the motor. The control circuit and the motor circuit are independent of each other. The maximum current is not limited by the current of the microcontroller. The working voltage is 12-24V and the rated current is 7A.
The question requires that the motor drive working voltage is 12-24V and the rated current is >5A, so option 2 is chosen.
Option 1: Restricted unipolar control
This control method has low power consumption and only requires one PWM wave control. However, it cannot provide reverse torque when the load exceeds the set speed. The speed regulation static difference is large, the speed regulation performance is poor, and the stability is also poor.
Option 2: Unipolar control
This control mode starts quickly, can accelerate, brake, energy-consuming braking, energy feedback, and the speed control performance is not as good as the bipolar mode, but it is similar, and the motor characteristics are better. It can provide reverse torque when the load overspeeds and only needs to generate a PWM wave. But when braking, the speed cannot decelerate to 0. When the speed is close to 0, there is no braking force. It cannot be reversed suddenly. The dynamic performance is not good and the static speed difference is large.
Option 3: Bipolar control
This control method can run forward and reverse, start quickly, have high speed regulation accuracy, good dynamic performance, small speed regulation static difference, and a large speed regulation range. It can accelerate, decelerate, brake, and reverse. When the load exceeds the set speed, Provides reverse torque, which can overcome the static friction of the motor shaft and produce very low rotational speed. However, two complementary PWM wave controls are required, the power loss is large, and the motor is easy to get hot.
The question requires high motor control accuracy and low control speed, so the third solution with good dynamic performance and low speed is selected.
Option 1: Use Hall sensor
This method uses the Hall effect to convert current into Hall voltage, which has a linear relationship. By sampling and measuring the voltage value through the ADC, the current value can be deduced. The advantages of this method are simple principle, simple application method, sensitive response and wide measurement range. The disadvantage is that the accuracy is not high, there is large noise, and it is easily interfered by external magnetic fields.
Option 2: Use voltage amplifier components
This method uses a sampling resistor to connect to the circuit to be measured, obtains the voltage division of the current on the sampling resistor, and then uses a voltage amplifier to amplify the tiny voltage to a voltage range that the ADC can accurately collect. The measured voltage is divided by the amplification factor divided by the sampling resistor value to obtain the current value. The advantages are sensitive response, high resolution, and the range can be adjusted in a wide range. The disadvantage is that zero point drift may occur, and the accuracy of the sampling resistor and the extent to which the resistance changes with environmental factors are very demanding.
This system consists of six parts: STM32 controller, power supply, motor driver, encoding motor, Bluetooth, and OLED display. The power transformer module converts the +12V voltage into a +5V voltage to supply power to each module and the microcontroller. The PWM pulse wave generated by the microcontroller supplies power to the motor through the motor drive. The encoder motor encoder feeds back the position of the motor to the microcontroller through the pulse wave. The microcontroller is based on The feedback pulse wave calculates the angle and speed of the motor and displays it on the OLED display. It is transmitted to the host computer through the Bluetooth serial port, and the output PWM pulse signal is adjusted through the PID algorithm to achieve the effect of controlling the motor.
The structural block diagram of the system is shown in Figure 1.
Figure 1 Structural block diagram of the overall system
This part of the circuit is built with the LM5122 chip as the core. The LM5122 is a synchronous boost controller with polyphase functionality, primarily intended for high-efficiency synchronous boost regulator applications. This control method is based on peak current mode control. Current mode control provides inherent line feedforward, cycle-by-cycle current limiting, and simplifies loop compensation. Switching frequency is programmable to 1 MHz. Two rugged N-channel MOSFET gate drivers with adaptive dead-time control allow for higher efficiency.
The LM5122 package is divided into 20-pin and 24-pin packages. This design uses a 20-pin package. The chip pin distribution and functions are shown in Figure 2.
Figure 2 LM5122 pin diagram (top view)
Introduction to several main pins of the LM5122 chip: Pin 5 is the power input end of the VCC regulator. Use short, low-impedance paths to the input capacitor and source power connections. Pin 17 is the VCC bias supply pin and is decoupled locally to the PGND pin using a low ESR/ESL capacitor as close to the controller as possible. Pin 9 (AGND) is the analog ground terminal and returns the internal voltage reference and analog circuitry.
Pin 11 (COMP) is the output of the internal error amplifier. Connect the loop compensation network between this pin and the FB pin. Pin No. 10 (FB) is the feedback terminal and is the reverse input of the internal error amplifier. A resistor divider from the output to the TO pin sets the output level voltage. The threshold on the FB pin is 1.2V. If the FB pin voltage is higher than 2.7V on initial power-up, the controller is assigned to slave mode.
The input voltage in this design is 12V. The output terminal is designed as follows: a resistor and two capacitors are connected between the chip COMP pin and FB pin to form a loop compensation network. At the same time, the threshold on the FB pin is 1.2V, so the output voltage can be adjusted through resistor division. As shown in Figure 2, the FB terminal is connected to ground through a 6.8kΩ and adjustable potentiometer, and two series resistors are connected to the output terminal.
When the potentiometer resistance is 0Ω, the output voltage is about 22V
When the potentiometer resistance is 10kΩ, the output voltage is about 9.6V
Therefore, the output voltage through the potentiometer R15 is about 10V-22V adjustable, which meets the 15V output voltage required by the question.
The schematic diagram of the LM5122 boost circuit is shown in Figure 3.
Figure 3 LM5122 boost circuit schematic diagram
The circuit design of this part is mainly divided into two parts. The first part is built with the BL1117 chip as the core to convert 12V voltage into 5V voltage. The second part is built with the ME6206 chip as the core to convert 5V voltage into 3.3V voltage.
2.3.1 BL1117 step-down circuit
The BL1117 is a series of low dropout three-terminal voltage regulators with a low dropout voltage of 1.3V at 1A load current. Compared to other chips, BL1117 has a very low standby current of 2mA. At the same time, BL1117 provides thermal shutdown and current limiting functions to ensure the stability of the chip and power system. It uses fine-tuning technology to ensure that the output voltage accuracy is within ±2%.
The BL1117 model used in this design is BL1117-50CX, which has a fixed output voltage of 5V, an output voltage accuracy within ±2%, and is packaged in SOT-223. The design of the BL1117 step-down circuit is shown in Figure 3. Both the input and output ends are connected to ground through a capacitor for power supply filtering.
2.3.2 ME6206 step-down circuit
The ME6206 is a high-precision, low-power, high-voltage, positive voltage regulator manufactured using CMOS and laser trimming technology. This series offers high current with minimal voltage drop. This series is compatible with low ESR ceramic capacitors. The current limiter's foldback circuit also acts as an output current limiter and short-circuit protection for the output pins.
The ME6206 model used in this design is ME6206A33XG, which has a fixed output voltage of 3.3V, a source current of 8μA, and is packaged in SOT23. The design of the BL1117 step-down circuit is shown in Figure 3. Both the input and output ends are connected to ground through a capacitor for power supply filtering.
The schematic diagram of the auxiliary power supply circuit is shown in Figure 4.
Figure 4 Auxiliary power circuit schematic diagram
The motor drive circuit consists of four parts: isolation circuit, motor circuit, boost circuit and filter circuit.
2.4.1 Isolation circuit
74HC244 is a common driving signal chip with an eight-way buffer and line driver with three-state output. 74HC244 can be used for isolation to prevent circuit board failures from burning the microcontroller and I/O ports.
Figure 5 Isolation circuit
2.4.2 Motor circuit
The motor circuit uses 4 NMOS to form an H-bridge switching circuit. To make the motor run, a pair of transistors on the diagonal line must be turned on. Depending on the conduction status of different transistor pairs, current may flow through the motor from left to right or from right to left, thereby controlling the steering of the motor. Logic conversion is completed through the half-bridge exciter IR2184S, causing the two transistors on the diagonal to conduct. The H-bridge can realize motor forward and reverse rotation, motor PWM speed regulation, motor braking and other control functions.
Figure 6 Schematic diagram of the motor part
2.4.3 Boost circuit
The B0512S chip is used to increase the 5V voltage to 12V to power the IR2184S.
Figure 7 Boost circuit schematic diagram
2.4.4 Filter circuit
The filter circuit can suppress motor power supply noise and resist electromagnetic interference.
Figure 8 Schematic diagram of filter circuit
The current detection circuit mainly relies on the ACS712 chip. ACS712 uses the Hall effect to linearly convert the current passing through the chip into a Hall voltage output.
Figure 9 ACS71205B characteristic curve
This picture shows the characteristic curve of ACS71205B. The slope of the curve is the current sensitivity. The zero current reference point of the ACS712 chip is VCC/2. By measuring the voltage value at the output terminal, the value of the input current can be calculated using the current sensitivity. The ACS712 family has three chips with different ranges, namely 05B, 20A and 30A, corresponding to the ranges ±5A, ±20A and ±30A. The higher the range, the lower the current sensitivity. Considering that the current output range of this design will not exceed ±5A, the 05B type chip is used, and the current sensitivity is 185mV/A.
Figure 10 Typical application of ACS712
This figure shows a typical application in the ACS712 data sheet. CF is used to set the bandwidth of the ACS712, and CBYP is used to filter the power supply. The current detection circuit designed this time is based on this application circuit. Vout is externally connected to the ADC of the microcontroller, and is connected in parallel with a large capacitor and a 3.3v zener diode. The purpose of the large capacitor is to eliminate the high-frequency noise of the output signal as much as possible, and the zener diode is to protect the IO interface of the microcontroller.
Figure 11 Software system program block diagram
STM32F103C8T6, as the main control chip of this system, mainly completes functions such as motor closed-loop control, parameter display, and host computer communication.
(1) Motor closed-loop control: STM32 controls the motor through the timer output PWM pulse wave with a frequency of 6KHz, reads the motor status through the incremental encoder input, and then updates the PWM through the PID algorithm to achieve closed-loop control.
(2) Parameter and status display: The parameter display interface displays the motor speed, motor position and current PWM value.
(3) Host computer communication: The motor status is sent to the host computer through the serial port, and at the same time, the host computer's instructions for target speed, target angle and PID adjustment are received.
3.2.1 PID control part code
This part uses incremental PID to control the speed, and automatically adjusts PWM according to the speed value fed back by the encoder to achieve feedback control of the speed. code show as below:
Figure 12 PID control part code
3.2.2 Motion control and alarm codes
Motion control modifies the target speed Speed_Aim, and the microcontroller automatically and accurately controls the motor speed through PID to achieve the purpose of speed regulation. When entering the uniform speed stage, the uniform motion current is obtained through multiple detections. After the weight is added, the microcontroller monitors the current in real time. If it reaches Alarm conditions activate the buzzer alarm.
The rising code is shown below:
The descent code is shown below:
The core implementation idea of current feedback control motor is current PID. The internal magnetic field and number of coil turns of the motor are constant. When the internal coil current of the motor is constant, a constant torque will be generated. When the two forces of torque 1 and tension are balanced, the load object remains stationary or decelerates to rest under the action of resistance; when torque 2 - tension - resistance = Fa, the load object will accelerate upward with an acceleration of Fa/m. When Fa = 0 , will maintain the original speed; when torque 3 + tension - resistance = Fb, the load object will accelerate downward with an acceleration of Fb/m. When Fb = 0, the original speed will be maintained;
If the current values corresponding to these five states can be found, and combined with the current PID to make the current reach the preset value, the load object can be made to move in three states: uniform acceleration, uniform speed, and deceleration to standstill under the action of resistance.
code show as below:
The voltage measurement part uses the STM32 internal 12-bit ADC to measure the output voltage value, and the detection resolution is 3300/4096mV. The calculation formula of the input current: I=(ADC count value-no_current_cnt)*3300mV/4096/185mV/A, the unit is Ampere, where no_current_cnt is the ADC count value when the current is 0. For the specific code to obtain the current value, please refer to the source code get_Current.c
The speed and distance measurement display system is mainly based on the high-precision AB phase photoelectric encoder. Combined with the encoder mode of STM32, it can accurately calculate the number of motor rotations and obtain the accurate speed.
Set the timer's reload value to 65535, and one counting cycle will be 65536. As shown in the figure above, this code is embedded in the 100hz timer interrupt. Now is used to record the current count value, and before is used to record the previous count value. When the value of now-before is too large or too small, the two times are judged. The record spans a counting cycle of the counter. At this time, a cycle Counter can be used to record how many counting cycles the motor has spanned.
The figure above shows the distance calculation method, where Period_distance is the distance that the motor rotates in one counting cycle, which is a fixed value. Read_Encoder() returns the current count value of the counter.
The above figure shows the calculation method of speed. CNT_SPEED is the difference between two count values within 0.01s.
Through the monitoring of the host computer and the remote adjustment of the PID function, the three more difficult parameters of KP, KI and KD can be adjusted. Through repeated debugging, it has achieved fast acceleration, no overshoot, no jitter, and high-precision motor speed control. Some screenshots of the adjustment process are as follows:
Figure 13 Partial screenshot of the debugging process
After analysis, the speed adjustment time is within 0.3s and the accuracy reaches 0.005m/s.
4.2.1 Stationary-acceleration-constant speed test
Control the motor to achieve static-accelerating-uniform motion. It achieves a constant speed of 100cm/s after accelerating to 100cm/s from a standstill. The two waveforms on the left in the figure are waveforms without load, the four waveforms on the right are waveforms with a load of 1KG, the purple waveform is the distance (cm), and the green waveform is Speed(cm/s)
Figure 14 Screenshot of static-accelerating-constant speed test results
Result analysis: The speed fluctuates greatly when carrying load
Cause Analysis:
(1) The load shakes and jitters when being pulled, and it is not a strictly vertical movement;
(2) The motor works unstable when the load is 1KG and is not stable at no load;
(3) The PID parameters are adjusted under no-load conditions and cannot work well under load conditions.
4.2.2 Accelerated 0.3m test
The motor is controlled to achieve static-acceleration-uniform motion, achieving an acceleration of 0.3m/s and an acceleration distance of 0.3m. The purple waveform in the picture is the distance (cm), and the green waveform is the speed (cm/s)
Figure 15 Screenshot of acceleration 0.3m test results
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet