Design of Motor Control System Based on AT89S52 Single Chip Microcomputer

Publisher:breakthrough3Latest update time:2010-05-28 Source: 现代电子技术Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction

Motor control is widely used in monitoring equipment, medical equipment, electric valves, electric curtains, household appliances, rotating lamps, etc. Therefore, it is very meaningful to design a motor control system with good controllability and high precision. This article introduces the software and hardware design of the motor control system based on the AT89S52 microcontroller. It sets the time under the operation of the key, controls the rotation of the motor, and displays the working status and time.

1 Design Description

The system first sets the forward and reverse (i.e. clockwise and counterclockwise) rotation time of the motor by pressing buttons, and the time is displayed on the LCD in the format of hours: minutes: seconds (different formats can be selected by changing the program). The countdown method is adopted. When the forward time is completed, the reverse rotation time starts immediately. When the reverse time is completed, it automatically returns to the initial setting time.

After the time setting is completed, press the start button, the forward rotation time starts timing, the motor working indicator light flashes, the forward rotation indicator light is on, and the motor rotates forward at the same time; when the forward time is over, the reverse time starts timing, the forward rotation indicator light goes out, the reverse rotation indicator light is on, and the motor rotates in the reverse direction at the same time.

Press the stop button, the time stops counting, the motor stops working, and the working indicator light goes out.

The motor used in the system is a 60TDY-11 reversible permanent magnet motor, which has two sets of windings inside and uses capacitors to achieve directional rotation. By changing the connection method of the capacitor and the motor output leads, the motor directional rotation can be reliably achieved and the rotation direction can be controlled.

2 Hardware Circuit Design

The hardware structure of the whole system is shown in Figure 1.

The hardware structure of the whole system

2.1 Key input and control circuit design

The key input circuit uses 6 keys connected to the P2.0~P2.5 ports of the microcontroller as the input of the control signal. Press the K0 key, the system enters the time setting mode, and continuously press the K0 key to select different time units to set. Use the K1 and K2 keys to add or subtract 1 to the time. Press the K3 key to exit the time setting mode, and the K4 and K5 keys are the start and stop keys respectively.

The control chip of the motor control circuit adopts AT89S52 of ATMEL Company, which has 8 KB FLASH, 256 B RAM, 32-bit I/O port line, watchdog timer, two data pointers, three 16-bit timer/counters, a 6-vector 2-level interrupt structure, full-duplex serial port, on-chip crystal oscillator and clock circuit. It has rich internal resources and high cost performance, which can meet the design requirements.

P0.0~P0.2 are the control signal outputs of the three working indicator lights, which need to be connected to an external pull-up resistor; P1.0~P1.2 are the control signal outputs of the LCD display; P3.0~P3.1 are the control signal outputs for controlling the forward and reverse rotation of the motor respectively.

2.2 LCD display circuit design

The display part uses 12864 LCD, and the controller is ST7920. This controller has Chinese character library, eliminating the trouble of compiling character library. The LCD of this controller also supports drawing mode. This type of LCD supports 68-bit 8-bit and 4-bit parallel port and serial port. The clock SCLK of ST7920 has independent operation timing. When multiple consecutive instructions need to be sent in, the instruction execution time needs to be considered.

A complete serial transmission cycle consists of the following parts: first, the start byte is sent, and five consecutive "1"s are sent to start a cycle. At this time, the transmission count is reset and the serial transmission is synchronized. The next two bits are to determine the transmission direction (RW, to determine whether it is read or write) and the transmission nature (RS, to determine whether it is a command register or a data register), and the last eighth bit is an "O".

In this design, the PSB pin is grounded, the serial port working mode is selected, the CS high level is valid, and data transmission can be completed using only two wires SID and SCLK.

2.3 Motor and drive circuit design

The operating voltage of the 60TDY-11 motor is 220 V AC, and the output high level of the microcontroller is 5 V. Therefore, the motor requires a drive circuit that uses a relay as an "automatic switch" to control a larger current with a smaller current.

The relay used in this design is HUIGANG HRS2H-S-DC-12V, and SN74LS07N is used as the driving circuit of the relay. The low-level input is effective, and the relay also needs a parallel diode circuit, mainly to protect the SN74LS07N. When the current flowing through the relay coil decreases rapidly, the coil will generate a very high self-induced electromotive force to break down the transistor. After the diode is connected in parallel, the self-induced electromotive force of the coil can be clamped at the forward conduction voltage of the diode. When P3.0 is low, the normally closed contact of relay 1 is disconnected, the normally open contact is closed, the forward circuit of the motor is turned on, and it starts to rotate forward. P3.1 is similar, P3.0 and P3.1 cannot be low at the same time.

3 Software Design

3.1 Program Description

The program is designed and developed in KeilμVision 3 IDE, written in C language. KeilμVision 3 integrated development environment is a microprocessor software development platform based on 80C51 core developed by Keil Soltware. It can complete the complete development process from project establishment to management, compilation, linking, target code generation, software simulation, hardware simulation, etc., especially the C compiler tool has reached a high level in terms of accuracy and efficiency of code generation. It supports all Keil 80C51 tool software, including C51 compiler, macro assembler, linker/locator and target file to Hex format converter. In view of this, it is selected as the program development environment.

The system program consists of the main program, interrupt handling subroutine, key handling program and display subroutine. The timer timing interrupt is used to generate time, and the software delay method is not selected, so as not to occupy CPU time. Timer T0 generates a 50 ms timing interrupt. There is a counter in the interrupt service program. Every 20 interrupts, there is a 1-second count. The key scan uses a single key scan, and there is a corresponding key processing subroutine. The program includes key debounce and key post-processing. Debounce uses the delay debounce method. The display subroutine is called in the main program to display the time in real time.

3.2 Main program flow chart

The main program flow chart is shown in Figure 2, which mainly completes the system initialization, key scanning, display program and other subroutine calls.

Main program flow chart

During initialization, the timing interrupt is turned off, the P0.0~P0.2 ports output a high level, the status indicator light goes out, the P3.0~P3.1 ports output a high level, the motor stops rotating, and the LCD is initialized to display 4 lines of information, 2 lines display time, the format is hour: minute: second, and the other 2 lines are time description text. All initialization functions are written as a subroutine, and the main program only needs to call it to complete the system initialization. After the initialization is completed, scan the keys, and if a key is pressed, call the corresponding processing program. When the time setting key is pressed, the selected time unit will flash continuously, which is different from other time units that have not been set. Use the K1 and K2 keys to change the time, and press the K3 key to exit the time setting. When the start key is pressed, the timing interrupt is turned on, the LCD display time starts to count down, the PO.1 port outputs a low level, the forward rotation indicator light is on, the P3.0 outputs a low level, and the motor starts to rotate forward. In the interrupt service program, the output level of the PO.0 port is controlled to make the normal working indicator flash once every 1 s. When the stop key is pressed, the P3. P0.0~P0.2 output high level, the status indicator light goes out, the timing interrupt is turned off, and the counting stops. When the forward rotation time ends, the reverse rotation countdown starts, P3.0 outputs high level, P3.1 outputs low level, the motor rotates in the reverse direction, P0.1 outputs high level, P0.2 outputs low level, the forward rotation indicator light goes out, and the reverse rotation indicator light turns on. The display program displays the time changes on the LCD in real time.

4 Conclusion

After actual operation, the system can satisfy the requirements of setting time under the operation of function keys, controlling the start, forward and reverse rotation, and stop of the motor, the status indicator light correctly displays the working status, and the LCD displays the time normally.

This system will be applied to an automatic opening and closing device of a valve. The valve opens when it rotates forward and closes when it rotates reversely, thereby controlling the liquid flow. In specific applications, it is also necessary to detect the opening and closing status of the valve.

2010/4/30 20:58:56
Keywords:MCU Reference address:Design of Motor Control System Based on AT89S52 Single Chip Microcomputer

Previous article:Design of multi-function counter based on C8051F020 chip
Next article:Design of DIS acquisition system based on ARM embedded system

Recommended ReadingLatest update time:2024-11-16 22:24

51 MCU-digital tube & LED
1. Light up the conjecture at the same time In the first section of this chapter, we said that if we want to light up the digital tube, then the small LED light we learned in the first chapter will not have a chance to light up. This is indeed the case in terms of hardware. However, we can still make a digital tub
[Microcontroller]
MSP430 MCU USART serial port sends characters and strings
In the official history of the MSP430 microcontroller, there are programs that use serial port interrupts to send characters and strings, but the portability is not high. I have written two functions specifically for sending single characters and strings without the need for interrupts, for your reference. /*********
[Microcontroller]
16-bit single-chip computer for connecting information appliances to the Internet
From the current situation, most access methods still use PC as a gateway to connect. However, this situation is generally used in large-scale industrial distributed control systems. If an additional PC is used for general information appliances, it will inevitably bring high costs to the product, which is not feasi
[Microcontroller]
16-bit single-chip computer for connecting information appliances to the Internet
How to select memory bank 0 or 1 in PIC16C6X microcontroller
The data memory of the intermediate product PIC16C6X of PIC microcontroller is usually divided into two banks, namely, bank 0 (Bank0) and bank 1 (Bank1). Each bank is composed of two parts: dedicated registers and general registers. Some register units in the two banks are actually the same register units, but have dif
[Microcontroller]
C51 MCU Learning - Implementation of Password Lock
I'll say this beforehand: Because my board has an LCD screen and a digital tube, which cannot be used at the same time, I'm using an LCD screen. The following code is easy to understand and has comments. If you don't know how to use some of the controls, you can check out my previous C51 articles. This password lock i
[Microcontroller]
Renesas Electronics Launches RA6T2 MCU for Next-Generation Motor Control
Renesas Electronics Introduces RA6T2 MCU for Next-Generation Motor Control in Inverter Equipment, Building Automation, and Industrial Drive Applications New MCUs enable higher-performance, more cost-effective motor control with high-frequency Arm Cortex®-M33 core, hardware accelerators and specialized
[Industrial Control]
Renesas Electronics Launches RA6T2 MCU for Next-Generation Motor Control
An operation that can immediately jump out of the current MCU program running state without interruption
The circuit diagram is as follows: MCU program source code: #include reg52.h //header file #include intrins.h #define uint unsigned int //macro definition #define uchar unsigned char sbit SW1 =P1^0; //button 1 sbit SW2 =P1^1; //button 2 sbit SW3 =P1^2; //button 3 sbit SW4 =P1^3; //button 4 uint num; uchar huayang1
[Microcontroller]
An operation that can immediately jump out of the current MCU program running state without interruption
Infineon Technologies Launches New High-Performance Microcontroller AURIX™ TC4Dx
On November 6, Infineon Technologies AG announced the launch of the AURIX™ TC4Dx microcontroller (MCU), the first product in the latest AURIX TC4x series. Based on 28nm technology, the AURIX TC4Dx provides higher performance and high-speed connectivity. Image source: Infineon Technologies
[Automotive Electronics]
Infineon Technologies Launches New High-Performance Microcontroller AURIX™ TC4Dx
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号