A DC brushless motor speed control system based on C8051F single chip microcomputer

Publisher:耿高良Latest update time:2011-02-28 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
[ 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


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.

Keywords: single chip microcomputer, brushless DC motor, speed control
Reference address:A DC brushless motor speed control system based on C8051F single chip microcomputer

Previous article:Analysis of the Problem of Program Loss in C8051Fxxx
Next article:ADC Application Elements in C8051F020

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号