Brushless Motor Control System Based on Atmel Mega8

Publisher:Lihua1314520Latest update time:2013-10-15 Source: eefocusKeywords:Atmel  Mega8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1 Introduction

  Electric bicycles use the electricity generated by batteries as driving energy and electric motors as power. They have the characteristics of no exhaust pollution, "zero emission", no noise, light and beautiful. However, there are still some imperfections in the electric bicycles on the market, especially in the aspects that need to be further improved. Based on the principle of brushless DC motor, this paper uses a new AVR high-end single-chip motor speed control system launched by Atmel in the United States in 2002. The system has the advantages of simple hardware structure, flexible software design, wide application, low price, etc. It has certain practical value.

  2 ATmega8 chip introduction

  The ATmega series of microcontrollers inherits the features of the AT90 in the AVR series, and adds more interface functions. It is more comprehensive and perfect in terms of power saving, stability, anti-interference and flexibility. ATmega8 is a subset of the ATmega series of microcontrollers (ATmega16/ATmega32/ATmega64/ATmega128). It integrates a large capacity memory and rich hardware interface circuits, and can effectively support C high-level language and assembly language in software.

  ATmega8 is an 8-bit microcontroller based on AVR RISC (Reduced Instruction Set) structure produced by low-power CMOS technology. The core of AVR microcontroller is to connect 32 working registers and rich instruction sets together. All working registers are directly connected to ALU (arithmetic logic unit), and can access (read and write) 2 independent registers at the same time with one instruction in one clock cycle. This structure can improve code efficiency, so that the execution time of most instructions is only one clock cycle, so it can achieve nearly 1MIPS/MHz performance, which is 10 times higher than ordinary microcontrollers. The main performance characteristics of ATmega8 are as follows:

  (1) High-performance, low-power 8-bit AVR microcontroller. It uses an advanced RISC reduced instruction set architecture; it has 130 powerful instructions, most of which are single-cycle instructions; it contains 32 8-bit general-purpose working registers; and its instruction processing speed is 16 MIPS when operating at 16 MHz.

  (2) The chip integrates a large capacity of non-volatile program and data memory. The 8k-byte Flash program memory can be erased and written more than 10,000 times; the 512-byte E2PROM can be erased and written at least 100,000 times; it supports in-circuit programming (ISP) and in-application programming (IAP); and it has a programmable program encryption bit.

  (3) Rich and powerful external interfaces. It has two 8-bit timer/counters with pre-scaling, one 16-bit timer/counter with pre-scaling; three PWM channels that can realize PWM pulse width modulation output with adjustable phase and frequency within 16 bits; six-channel A/D conversion; one I2C serial interface, one programmable USART interface, one SPI synchronous serial interface that supports master/slave and receive/transmit; a programmable watchdog timer with an on-chip RC oscillator; and an on-chip analog comparator.

  (4) It has special microcontroller performance. It contains a controllable power-on reset delay circuit and a programmable undervoltage detection circuit; there are 18 interrupt sources inside and outside the chip; and 5 sleep modes (idle, ADC noise suppression, power saving, power down, standby).

  3 System Hardware Design

  The whole system mainly includes rotor position detection circuit, speed measurement circuit, speed regulation circuit, MOSFET full-bridge circuit, current limiting circuit, etc. Figure 1 shows its principle block diagram. The brushless DC motor consists of three parts: the motor body, the rotor position detector and the electronic switch circuit. The DC power supply supplies power to the stator winding of the motor through the switch circuit. The position detector can detect the position of the rotor at any time and control the conduction and cutoff of the switch tube according to the rotor position signal, thereby realizing electronic commutation.

  3.1 Rotor position detection circuit

  The brushless DC motor in this design has two pairs of poles, the stator winding adopts a three-phase connection method, and the spatial spacing of the three Hall position sensors is 60°, that is, the electrical angle is 120°. The outputs of the three Hall sensors H1, H2, and H3 are directly connected to the 26th, 27th, and 28th pins of ATmega8 respectively. The digital-to-analog conversion function (ADC) of these three pins can be used to sample and convert the Hall signals.

  3.2 Motor speed control circuit

  a. Speed ​​measuring circuit

  To accurately control the speed of a brushless DC motor, its speed must first be accurately measured. This design uses the output pulse signal of the rotor position sensor to reflect the speed of the motor. The position sensor signal is first sent to the PD3 pin of the microcontroller after passing through the sampling and conditioning circuit. This pin can be used as the input port of the external interrupt source. As the motor rotates, PD3 will continue to receive pulse signals. When PD3 receives a rising edge, it will start timer T0 to start timing until the next adjacent rising edge is received. The timing result of timer T0 is the time required for the motor to rotate one circle. Based on this, the speed of the motor can be calculated. [page]

  b. Reversing speed regulation circuit

  The speed control methods of brushless DC motors can be divided into two categories: excitation control method and armature voltage control method.4. Since the former is subject to more restrictions and the excitation coil inductance is larger, the dynamic response is poor. Therefore, the armature voltage control method that changes the armature terminal voltage to achieve speed regulation is commonly used. Assuming the DC power supply voltage is Ud, a resistor R is connected in series with the armature and connected to the power supply Ud, the voltage Ua across the armature is Ua=Ud-IaR. Obviously, adjusting the resistor R can change the terminal voltage, thereby achieving the purpose of speed regulation. However, this traditional voltage regulation and speed control method is less efficient. With the development of power electronics technology, many new armature voltage control methods have emerged. PWM (pulse width modulation) is one of them, and its basic principle is shown in Figure 2.

  Assume that the amplitude voltage of the rectangular wave applied to both ends of the motor armature is Ud? Then the average voltage across the motor armature is

  Ua=(T1-T2)Ud/(T1+T2)=(2T1/T2-1)Ud=(2α-1)Ud

  Among them, α is the duty cycle, and the purpose of voltage regulation can be achieved by changing the value of α. Since 0 ≤α≤1, the range of Ua value is -Ud~+Ud, so the motor can be operated in both forward and reverse directions.

  FIG3 shows a partial schematic diagram of a brushless DC motor speed control system for an electric bicycle. The single-chip microcomputer in the figure can sample the voltage of the adjustable resistor on the handle of the electric bicycle, and then send it to the PWM register after A/D conversion, thereby controlling the PB1 pin of the single-chip microcomputer and outputting a PWM signal with an adjustable duty cycle. This signal is compared with the output signal from the LM358 comparator of the current limiting circuit through software. When the current limiting circuit is not working, a PWM signal is output to cooperate with the PB0, PD5 and PD6 pins controlled by the software to drive the corresponding optocoupler, thereby controlling the MOSFET full-bridge circuit to switch on and realize the commutation of the motor. Therefore, by adjusting the duty cycle of the single-chip microcomputer PWM signal, the voltage applied to the stator winding of the motor can be changed, thereby realizing the speed regulation of the motor.

  4 System software control

  ATmega8 can effectively support C language and assembly language in software. C language has become the standard language for designing embedded systems. It has the characteristics of structured programming, good readability and easy maintenance of ordinary high-level languages, and the characteristics of convenient hardware access and high code efficiency of low-level languages ​​such as assembly. This design is implemented in C language programming and has good portability. Its program flow chart is shown in Figure 4.

  5 Conclusion

  The electric bicycle speed control system designed by this scheme has obtained good dynamic and static characteristics during the experimental operation. The use of cost-effective ATmega8 microcontroller has greatly reduced the cost, improved the flexibility of software design, enriched the hardware interface function, and created good conditions for future system upgrades.

Keywords:Atmel  Mega8 Reference address:Brushless Motor Control System Based on Atmel Mega8

Previous article:Hydrological Test System Based on Atmel Microcontroller
Next article:Design of serial port to FSK communication module based on ATmega48

Latest Microcontroller 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号