[
Abstract
]
:
Taking C8051F020 as an example, this article introduces the application of C8051F MCU in rotate speed Control of direct current and brushless motor, realization method, hardware structure and software structure.
[
Keywords
]
:
MCU
,
direct current and brushless motor,
rotate
speed Control
The article introduces application of C8051F020 in rotate speed Control of direct current and brushless motor, realization method
Reference address:A DC brushless motor speed control system based on C8051F single chip microcomputer
Introduction:
Permanent magnet synchronous motors with trapezoidal back electromotive force are usually called brushless DC motors. They have simple structure, small size, light weight, high efficiency, high power density, large starting torque, small inertia and fast response, which are unmatched by other types of DC motors. The electronic commutator replaces the mechanical commutation device of the traditional DC motor, thus overcoming a series of disadvantages caused by brushes and commutators, such as noise, sparks, electromagnetic interference, and short life. Since brushless DC motors have a series of advantages of AC motors such as simple structure, reliable operation, and convenient maintenance, and have many advantages of DC motors such as high operating efficiency, no excitation loss, and good speed regulation performance, they are widely used in household consumer products (air conditioners, refrigerators, washing machines) and IT peripheral products (printers, floppy drives, hard drives). The C8051F
microcontroller is a microcontroller compatible with the 51 series microcontroller core launched by Silabs Corporation of the United States, with high speed, high performance, and high integration. Taking C8051F020 as an example, it has the following features:
C8051F020 system-on-chip microcomputer on-chip resources:
1. Module peripherals
(1) Successive approximation type 8-channel 12-bit ADC0
conversion rate maximum 100ksps
programmable gain amplifier PGA
temperature sensor
(2) 8-channel 8-bit ADC1 input multiplexed with P1 port
Conversion rate 500ksps
programmable gain amplifier PGA
(3) Two 12-bit DACs
(4) Two analog voltage comparators
(5) Internal voltage reference provides 2.43V
external reference can be input
(6) Accurate VDD monitor
2. High-speed 8051 microcontroller core
Pipeline instruction structure speed can reach 25MIPS
22 vector interrupt sources
3. Memory
On-chip 4352 bytes of data RAM
64KBFlash program memory can be used as non-volatile storage
Externally expandable 64KB data memory interface
4. Digital peripherals
8 8-bit port I/O
I2CSPI 2 enhanced UART
serial ports Programmable 16-bit counter/timer array (PCA)
5 general-purpose 16-bit counter/timers
Dedicated watchdog WDT
5. JTAG debugging and boundary scan interface, which can realize online real-time dynamic debugging.
From the above characteristics, it can be seen that the C8051F microcontroller has rich on-chip hardware resources and high computing speed, which provides a guarantee for the realization of complex control algorithms, and almost no system expansion is required to meet the control system's demand for hardware resources, greatly improving the system reliability.
Hardware part:
The hardware part is mainly composed of motor, motor drive circuit, microcontroller and display block. Its functional block diagram is as follows:
The motor drive adopts the high-performance second-generation unit brushless DC motor controller MC33035 developed by ON Semiconductor of the United States. The chip has a fixed frequency and width modulation PWM circuit inside, which integrates many functions such as decoding, overheating, overcurrent, undervoltage protection, forward and reverse control, and is a full-featured motor controller.
Speed regulation can be achieved by controlling the armature voltage of the motor through pulse width modulation PWM. Under normal circumstances, the error amplifier output is compared with the sawtooth wave signal output by the oscillator to generate a pulse width modulation (PWM) signal as shown in the figure below. Changing the output pulse width is equivalent to changing the average voltage supplied to the motor winding, thereby controlling its speed. Therefore, we can control the output of DAC0 through the microcontroller, control the voltage input to the DC brushless motor, and then control the duty cycle of the PWM wave to achieve the purpose of controlling the motor speed.
MC33035 pulse width regulation schematic diagram
Software part
:
The brushless DC motor has three built-in Hall effect sensors to detect the position of the rotor, which also determines the phase change of the motor, and the motor speed can be calculated based on the signal. When the motor is running normally, the Hall sensor can obtain three overlapping signals with a pulse width of 180 degrees electrical angle, and the change in motor speed can be reflected from the change in the output pulse frequency of the position sensor. Therefore, the microcontroller can be used to monitor this pulse signal to obtain the motor speed. Because the frequency and speed are measured in direct proportion, the speed can be calculated by measuring the frequency of the output pulse. In addition, in order to improve the accuracy, the frequency measurement method is used for high speed (>/1000HZ), and the cycle measurement method is used for low speed (<1000HZ).
The pulse signal output is connected to INT0, and the INT0 interrupt is used to count the speed pulses. The count value is read every 1s, and this value is compared with the preset speed value. If it is greater than the preset speed value, the value of DAC0 is reduced; if it is less than the preset speed value, the value of DAC0 is increased, and the speed of the motor is adjusted until the speed value is equal to the preset value. The current speed value of the motor can be displayed on the seven-segment digital tube, and the motor speed is controlled to be equal to the preset value within the controllable range of the motor.
Program flowchart:
The microcontroller program is completed using C51, and some source programs are as follows:
1. System clock initialization, using 18.432MHZ external crystal oscillator:
void SYSCLK_Init (void)
{
int i; //Delay counter
OSCXCN=0x67; //Turn on external oscillator 18.432MHz crystal
for(i=0;i<256;i++); //Wait for oscillator to start
while(!(OSCXCN&0x80)); //Wait for crystal oscillator to stabilize
OSCICN=0x88; //Select external oscillator as system clock source and allow lost clock detector
}
2. IO port initialization
void PORT_Init (void)
{
XBR0 =0x07; //Enable SMBus, SPI0, and UART0
XBR1 = 0x04; //P1.0<---int0
XBR2 = 0x40; //Enable data crossbar switch and weak pull-up
EMI0CF = 0x27;
EMI0TC = 0x21;
P74OUT = 0xFF;
P0MDOUT = 0x15;
P1MDOUT |= 0x3C; //P1.2-P1.5 push-pull output
P1 &= 0xc3; //P1.2-P1.5=0
}
3. Timer 0 initialization, timing time is 1ms
void Timer0_Init (void)
{
CKCON|= 0x8;
TMOD|= 0x1; //16-bit
Count1ms=10;
TR0 = 0; //Stop Timer 0
TH0 = (-SYSCLK/1000) >> 8; //Set initial value, overflow at 1ms
TL0 = -SYSCLK/1000;
TR0 = 1; //Start Timer 0
IE|= 0x2;
}
4. Timer0 interrupt:
void Timer0_ISR (void) interrupt 1
{
TH0 = (-SYSCLK/1000) >> 8;
TL0 = -SYSCLK/1000;
if (Count1ms) Count1ms--;
if (Count1s) Count1s--; //The initial value of Count1s is 1000
else
{
Count1s=1000;
SaveMotorCount=MotorCount; //MotorCount is the number of pulses per second
MotorCount=0;
SD=SaveMotorCount/2-SetSpeed; //The value of the constant SetSpeed is the preset value of the speed, in rpm
SaveMotorCount*=30; //rpm
if (SD)
{
if ((SD>5)||(SD<-5))
iDAC0-=SD*4;
else
iDAC0-=SD;
DAC0=iDAC0; }
}
}
5. External 0 interrupt:
void Int0_ISR (void) interrupt 0
{ MotorCount++;}
Software simulation debugging method:
(1) Observe the DAC0 window, change the value of DAC0 to observe the change of motor speed
(2) Use an oscilloscope to observe the frequency of CKMOT and calculate the motor speed and compare it with the value displayed by the seven-segment digital tube to compare the accuracy of speed measurement
(3) Change the value of the constant SetSpeed (the preset value of the speed) and observe the value of the seven-segment digital tube after the speed stabilizes
(4) You can set breakpoints at the entrance of the external interrupt INT0 and the entrance of the T0 interrupt to run the program and observe whether the program runs normally.
Conclusion:
Due to the high integration of C8051F020, only a small amount of peripheral circuits are required. In addition, the C8051F020 core is compatible with the ordinary 51 series, and the instructions are simple and easy to learn, which can shorten the system development cycle. Practice has proved that this control system has high accuracy, good stability, simple hardware and reliable operation, and has good promotion value.
XBR1 = 0x04; //P1.0<---int0
XBR2 = 0x40; //Enable data crossbar switch and weak pull-up
EMI0CF = 0x27;
EMI0TC = 0x21;
P74OUT = 0xFF;
P0MDOUT = 0x15;
P1MDOUT |= 0x3C; //P1.2-P1.5 push-pull output
P1 &= 0xc3; //P1.2-P1.5=0
}
3. Timer 0 initialization, timing time is 1ms
void Timer0_Init (void)
{
CKCON|= 0x8;
TMOD|= 0x1; //16-bit
Count1ms=10;
TR0 = 0; //Stop Timer 0
TH0 = (-SYSCLK/1000) >> 8; //Set initial value, overflow at 1ms
TL0 = -SYSCLK/1000;
TR0 = 1; //Start Timer 0
IE|= 0x2;
}
4. Timer0 interrupt:
void Timer0_ISR (void) interrupt 1
{
TH0 = (-SYSCLK/1000) >> 8;
TL0 = -SYSCLK/1000;
if (Count1ms) Count1ms--;
if (Count1s) Count1s--; //The initial value of Count1s is 1000
else
{
Count1s=1000;
SaveMotorCount=MotorCount; //MotorCount is the number of pulses per second
MotorCount=0;
SD=SaveMotorCount/2-SetSpeed; //The value of the constant SetSpeed is the preset value of the speed, in rpm
SaveMotorCount*=30; //rpm
if (SD)
{
if ((SD>5)||(SD<-5))
iDAC0-=SD*4;
else
iDAC0-=SD;
DAC0=iDAC0; }
}
}
5. External 0 interrupt:
void Int0_ISR (void) interrupt 0
{ MotorCount++;}
Software simulation debugging method:
(1) Observe the DAC0 window, change the value of DAC0 to observe the change of motor speed
(2) Use an oscilloscope to observe the frequency of CKMOT and calculate the motor speed and compare it with the value displayed by the seven-segment digital tube to compare the accuracy of speed measurement
(3) Change the value of the constant SetSpeed (the preset value of the speed) and observe the value of the seven-segment digital tube after the speed stabilizes
(4) You can set breakpoints at the entrance of the external interrupt INT0 and the entrance of the T0 interrupt to run the program and observe whether the program runs normally.
Conclusion:
Due to the high integration of C8051F020, only a small amount of peripheral circuits are required. In addition, the C8051F020 core is compatible with the ordinary 51 series, and the instructions are simple and easy to learn, which can shorten the system development cycle. Practice has proved that this control system has high accuracy, good stability, simple hardware and reliable operation, and has good promotion value.
Keywords:
single chip microcomputer, brushless DC motor, speed control
Previous article:Analysis of the Problem of Program Loss in C8051Fxxx
Next article:ADC Application Elements in C8051F020
- Popular Resources
- Popular amplifiers
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
Guess you like
- JFET Tube Principle
- TI uses LLC resonant controller to speed up device operation
- Satellite communication and ground reception are the same thing
- [Ended] Limited-time benefit for new users: e-Network Mall welcomes the new season, free shipping + discounts for all items ~ Free shipping even if you buy a resistor!
- How is the main program of the microcontroller executed?
- Application of RFID in schools
- Did you know? EEWorld's "Device Search" applet has released a new feature~
- STM32F767 PWM wave problem
- GPIO module of C6000 series DSP
- 【NUCLEO-L552ZE Review】+ Based on FREERTOS transplantation