A DIY design of a brushless motor controller

Publisher:LianaiLatest update time:2023-01-11 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I wanted to make a brushless motor controller a long time ago, but I was busy with work and never got around to it. Recently, I had some time to draw the board, proof, weld, and debug, and finally it worked smoothly. During this period, I encountered many problems. I searched online for information and measured the waveform myself for nearly a month (I was on a business trip for a week in the middle). Finally, I got it done, so I wrote a summary. The board is 100*60mm in size. DC 12V input, designed maximum current 10A. (I haven't actually tried such a large motor, the motor on hand is about 5 6A) The hardware can switch between inductive (HALL) and non-inductive (EMF) modes, and the external sliding rheostat speed control has reserved PWM input, brake, forward and reverse, USB and uart interfaces. Let's talk about the principle first. The brushless motor is actually a DC motor, which is the same as the traditional DC motor, but the brushed electric slip ring is changed into an electronic commutator.

eed6a7be-8992-11ed-bfe3-dac502259ad0.png

Because there is less friction in the electric slip ring, the life and quietness are greatly improved, and the speed is also higher.

eee3d678-8992-11ed-bfe3-dac502259ad0.png

Of course, the difficulty lies in how to obtain the current rotor position for phase change, so it is divided into two types: inductive and non-inductive. Inductive means installing Hall sensors at the motor end cover at intervals of 30 degrees or 60 degrees. Non-inductive means detecting the zero crossing of the induced electromotive force of the suspended phase (detailed later). Of course, each has its own advantages and disadvantages. Inductive is good at low speed and can be frequently started and stopped for phase change. The non-inductive structure is simple and low-cost, and is mostly used in model aircraft. Let's talk about inductive first. The power supply is first divided into three windings UVW. There is still a difference between this alternating current. It is just a simulation of three H bridges being turned on in a certain order, and the essence is still direct current. The motor changes phases in a certain order based on the hall position, and the speed is related to the voltage and current. Remember this point, the faster the change, the faster the rotation. (The position determines the phase change moment, and the voltage determines the speed) Generally, speed regulation is voltage regulation, and the 6-step pwm method is currently commonly used. Of course, there will be better algorithms such as foc in the future. The hardware part is basically mature solutions on the Internet. Three-phase H-bridge, H-bridge generally consists of upper arm MOS and lower arm MOS. If it is just a simple demonstration, the upper arm chooses pmos and the lower arm chooses nmos. The control circuit can be driven directly by the IO of the microcontroller. However, the price of pmos with low internal resistance is high. It is difficult to increase the power.

This is why almost all commercial controllers are nmos.

However, there is a problem with using NMOS for the upper arm. The VGS control voltage must be greater than VCC 4V to be fully turned on. In order to simplify the circuit, a driver IC produced by IR is used, which has a bootstrap boost circuit inside. Only a freewheeling diode and energy storage capacitor are needed externally.

eeefb5f6-8992-11ed-bfe3-dac502259ad0.jpg

ef124ef4-8992-11ed-bfe3-dac502259ad0.jpg

The inductive mode control is relatively simple. The outputs of the three Hall sensors are generally digital signals, which are directly connected to the microcontroller io after voltage division.

ef2ff63e-8992-11ed-bfe3-dac502259ad0.png

Of course, the control method is much simpler. Three Halls are connected to interrupt inputs. In the interrupt handler, the phase is changed according to the combination state. The program is not complicated. The main program always detects the AD value, changes the PWM duty cycle, and current protection. The following is a typical phase change code. STM32 has two advanced timers TIm1 TIm8 that can output 4 sets of complementary PWM, and can also set the dead time, etc., which is very convenient to use.

ef45f0ba-8992-11ed-bfe3-dac502259ad0.png

ef58aa20-8992-11ed-bfe3-dac502259ad0.jpg

ef8347da-8992-11ed-bfe3-dac502259ad0.jpg

The figure below shows the levels detected by the Hall sensors of the three phases uvw and w and the waveform of the w phase.

efbabc56-8992-11ed-bfe3-dac502259ad0.jpg

The following figure shows the uvw three-phase waveform and the w-phase Hall level

efdc47f4-8992-11ed-bfe3-dac502259ad0.jpg

The figure below shows the w-phase level, w-phase upper arm on lower arm pwm, and w-phase hall signal.

efec275a-8992-11ed-bfe3-dac502259ad0.jpg

The following figure shows the output of the W-phase IR2304 chip. The upper arm voltage is obviously higher than VCC, and the lower arm is a PWM signal.

f0091e5a-8992-11ed-bfe3-dac502259ad0.jpg

Let's talk about the sensorless mode. Without the Hall effect, the motor cannot know the current position of the rotor, so it cannot change phases. The induced electromotive force only exists after it starts to rotate, so starting the sensorless mode is a difficult point. The general method is divided into three stages: 1. Pre-positioning 2. Starting 3. Entering closed-loop feedback As netizens say, a layer of paper in the rivers and lakes is worthless if it is pierced. 1. Pre-positioning is to force a certain phase to be energized for a period of time to allow the motor to be positioned at this position. The duty cycle of 30-50% should not be too large, otherwise it may heat up. 2. Starting is to force phase change step by step. Of course, there must be an acceleration process to make the motor rotate. If this process is too slow, it will shake and reverse, and if it is too fast, it will lose steps. The parameters need to be tried a little bit, a bit like controlling a stepper motor. To enable the motor to rotate and generate electromotive force, I also refer to the algorithm of the German MK electronic regulator. Each delay time is 1/25 less than the previous time, forming an acceleration process until the motor is fully rotated to generate enough electromotive force. 3. The closed-loop feedback control commutation is almost the same as the sensory.

f02b0fba-8992-11ed-bfe3-dac502259ad0.png

When it comes to induced electromotive force, many people don't understand. Let's talk about current first. The internal resistance of the motor coil is usually very small, such as 0.2 ohms. The voltage of the motor is, for example, 10v. Logically, why doesn't the motor burn out with a current of 100a? In fact, the motor coil is not completely conductive at the moment of power on, because there is a reverse electromotive force, which may be -9.8v. 10v-9.8v = 0.2v /0.2 = 1A. The current is reasonable in this way. Let's talk about Faraday, who was learned in junior high school. When the coil cuts the magnetic field, an induced electromotive force will be generated. According to the right-hand rule, junior high school physics knowledge.

f05ee88a-8992-11ed-bfe3-dac502259ad0.jpg

As shown in the figure below, when the AC phase is powered by 12V, the neutral point in the middle is theoretically 6V in a static state, but it is not necessarily the case when it rotates, because the b phase is actually cutting the magnetic field, which will generate an electromotive force. The magnitude of the electromotive force depends on the current position of the ns pole in the magnetic field. When cutting ns, it is -1, when cutting sn, it is 1, and when parallel, it is 0.

f07b9f5c-8992-11ed-bfe3-dac502259ad0.jpg

Wouldn't it be possible to obtain the rotor position by using this feature? First of all, the detection circuit is already very mature on the Internet. As shown in the figure below, of course, in many cases, a 100nf capacitor is required to be connected to the 4.7k resistor to ground to make a low-pass filter. You can also do filtering in the software.

f0913b64-8992-11ed-bfe3-dac502259ad0.jpg

What we need to do is to detect the zero point of the electromotive force of the suspended phase. There are two commonly used methods on the Internet: 1. Single chip AD acquisition; 2. Comparator comparison. I chose the comparator LM339, which is already very cheap and has obvious advantages over AD at high speed. The zero point can be obtained by comparing the voltage difference between CIN, BIN, AIN and N points.

f0b1c44c-8992-11ed-bfe3-dac502259ad0.jpg

Ideals are perfect, but reality is cruel. In practice, such a perfect waveform is impossible to obtain.
As shown in the following figure, this is already relatively good, but there are still many burrs. This interrupts the microcontroller, which must be a lot of problems, and seriously replace the wrong phase and burn the MOS tube.

f0d1ea92-8992-11ed-bfe3-dac502259ad0.jpg

f0f68ed8-8992-11ed-bfe3-dac502259ad0.jpg

Why are there these burrs? Some of them are quite regular. According to the introduction on the Internet, there is also something called demagnetization.

f112e4c0-8992-11ed-bfe3-dac502259ad0.png

I won't go into the details of the principle. Anyway, the time is very short, so we can just filter it out in the software. After entering the interrupt function, we do the following processing. I temporarily use 20us for the timer interrupt.

f1200952-8992-11ed-bfe3-dac502259ad0.png

f12b7be8-8992-11ed-bfe3-dac502259ad0.png

f1477fb4-8992-11ed-bfe3-dac502259ad0.png

As for the online saying that after detecting the zero point, delaying the commutation by 30 degrees will affect the power supply efficiency. I tried it and it seems that there is no obvious difference. Some people also say that it is smoother without delay under high-power motors, etc. The truth is waiting for your actual experiment. Finally, show a few photos of it rotating.

f1574d36-8992-11ed-bfe3-dac502259ad0.jpg

f183b826-8992-11ed-bfe3-dac502259ad0.jpg

Hard disk motor non-sensing mode

f1a06f34-8992-11ed-bfe3-dac502259ad0.jpg

Power tool motor sensor mode

f1c7b666-8992-11ed-bfe3-dac502259ad0.jpg

Installing heat sink


Reference address:A DIY design of a brushless motor controller

Previous article:How to wire a relay to a PLC?
Next article:Analysis of two design schemes for motor drive circuit

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号