Direct current motor PWM speed regulation system and method

文档序号:424139 发布日期:2021-12-21 浏览:10次 中文

阅读说明:本技术 一种直流电机pwm调速系统及方法 (Direct current motor PWM speed regulation system and method ) 是由 贺颖 董宗慧 于 2021-09-24 设计创作,主要内容包括:本发明属于电子技术领域,针对传统调速方式不能满足一些需要精密转速、快速反应的场合的问题,公开了一种直流电机PWM调速系统及方法。所述系统包括单片机U1、驱动芯片U2、直流电机、电源模块、按键调节模块、使能芯片U3、显示器D1、显示器D2、晶振X1、串口通信模块和其它外围电路;该设计以单片机AT89C52为核心,通过直流电机专用驱动芯片L293D对直流电机进行转向和速度控制,同时用LED数码管显示直流电机的当前转速和期望转速。系统以Proteus作为开发平台,搭建系统模型,并利用Keil 5和Proteus进行联合仿真实现直流电机速度加减调节、转向变换控制和启停运转。本系统的开发为实现直流电机转速精确控制提供了理论基础。(The invention belongs to the technical field of electronics, and discloses a PWM speed regulating system and method for a direct current motor, aiming at the problem that the traditional speed regulating mode cannot meet the requirements of occasions requiring precise rotating speed and quick response. The system comprises a single chip microcomputer U1, a driving chip U2, a direct current motor, a power supply module, a key adjusting module, an enabling chip U3, a display D1, a display D2, a crystal oscillator X1, a serial port communication module and other peripheral circuits; the design takes a single chip microcomputer AT89C52 as a core, the steering and speed control of the direct current motor are carried out through a special driving chip L293D for the direct current motor, and the current rotating speed and the expected rotating speed of the direct current motor are displayed through an LED nixie tube. The system takes Proteus as a development platform, a system model is built, and Keil 5 and Proteus are utilized to carry out combined simulation to realize speed plus-minus adjustment, steering conversion control and start-stop operation of the direct current motor. The development of the system provides a theoretical basis for realizing the accurate control of the rotating speed of the direct current motor.)

1. The utility model provides a direct current motor PWM speed control system, includes singlechip U1, driver chip U2, direct current motor, its characterized in that: the device also comprises a power supply module, a key adjusting module, an enabling chip U3, a display D1, a display D2, a crystal oscillator X1, a serial port communication module and other peripheral circuits;

the pin 1 and the pin 2 of the direct current motor are respectively connected with the pin 3 and the pin 6 of the driving chip U2, and the pin 3 and the pin 4 of the direct current motor are respectively connected with the pin 12 and the pin 13 of the singlechip U1; the pin 1, the pin 7 and the pin 2 of the driving chip U2 are respectively connected with pins 37-39 of a single chip microcomputer U1, the pin 8 and the pin 16 of the driving chip U2 are respectively connected with a power supply VCC1 and a power supply VCC of a power supply module, and the pin 15 and the pin GND of the driving chip U2 are grounded; the pin 2 and the pin 1 of the crystal oscillator X1 are respectively connected with the pin 18 and the pin 19 of the singlechip U1; one ends of five key switches S2-S6 of the key adjusting module are respectively connected with pins 36-32 of a single chip microcomputer U1, and the other ends of the five key switches are grounded after being in short circuit; pin 1, pin 12 and pin 13 of the enable chip U3 are respectively connected with pins 1-3 of the singlechip U1, pin 14, pin 16, pin 20, pin 23, pin 21, pin 15, pin 17 and pin 22 of the enable chip U3 are respectively connected with pins 1-8 of the display D1 and the display D2, pin 2, pin 11, pin 6 and pin 7 of the enable chip U3 are respectively connected with pins 9-12 of the display D1, and pin 3, pin 10, pin 5 and pin 8 of the enable chip U3 are respectively connected with pins 9-12 of the display D2.

2. The PWM speed regulating system of the direct current motor according to claim 1, characterized in that: the single chip microcomputer U1 is an AT89C52 single chip microcomputer; the driving chip U2 is an L293D driving chip, is a four-way high-current double-bridge driver, and is internally provided with four high-current double-bridge circuits which are special enabling chips for the direct-current motor; the direct current motor is a sensor with a working voltage of 12V and a photoelectric speed meter; the key adjusting module comprises a forward rotation key1, a reverse rotation key2, an acceleration key _ add, a deceleration key _ dec and a stop key 3; the enabling chip is an 8-bit nixie tube enabling chip MAX 7221; the display D1 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D1, the display D2 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D2, and the expected rotating speed and the real-time rotating speed of the direct current motor are respectively displayed; the serial port communication module comprises a serial port P1 and an upper computer, the serial port P1 is RS232, a pin 2 and a pin 3 of the serial port P1 are respectively connected with a pin 10 and a pin 11 of a single chip microcomputer U1, and a pair of connected serial ports distributed by a virtual serial port assistant is used for connecting the serial port P1 with the upper computer.

3. The PWM speed regulating system of the direct current motor according to claim 1, characterized in that: when the direct current motor is a high-power direct current motor, the driving chip U2 is replaced by an H-shaped double-bridge circuit built by a power electronic device.

4. The PWM speed regulating system of the direct current motor according to claim 1, characterized in that: the serial port communication module can also be a Bluetooth, WIFI or 5G specific communication device.

5. The PWM speed regulating system of the direct current motor according to claim 1, characterized in that: the photoelectric velometer of the sensor is a photoelectric coded disc, and the photoelectric coded disc is provided with two optical sensors.

6. A PWM speed regulation method of a direct current motor is characterized by comprising the following steps: the speed regulation comprises the regulation and control of the rotation direction, the rotation speed and the stop of the direct current motor; the method specifically comprises the following steps:

step 1, regulating and controlling the rotation direction, the rotation speed and the stop of a direct current motor:

the adjustment control process of the direct current motor steering is as follows: after receiving the instruction of the key adjusting module or the serial port communication module, the single chip microcomputer U1 outputs signals of different combinations on the pin 39 and the pin 38 to control the flowing direction of the current between OUT1 and OUT2 of the driving chip U2, so as to control the current direction of the armature end of the direct current motor and finally adjust the forward and reverse rotation of the direct current motor;

the adjusting and controlling process of the rotating speed of the direct current motor comprises the following steps: after receiving the instruction of the key adjusting module or the serial port communication module, the single chip microcomputer U1 outputs a modulated PWM wave on a pin 37 of the single chip microcomputer U1, and then the EN1 of the driving chip U2 enables and controls the voltage between OUT1 and OUT2, so as to control the rotating speed of the direct current motor;

step 2, collecting the regulation and control signals in the step 1: the external interrupt INT0 of the single chip microcomputer U1 is matched with a timing/counter T0 program to acquire and calculate the rotating speed of the direct current motor, and the external interrupt INT0 and the external interrupt INT1 of the single chip microcomputer U1 are matched to judge the rotation direction of the direct current motor;

and 3, acquiring a regulation signal in the step 2, and displaying:

rotating speed: when an external interrupt INT0 of the single chip microcomputer U1 acquires a high level, adding 1 to the num count value of the global variable; timing one second in a timer/counter T0 program, calculating the real-time rotating speed of the direct current motor according to the num count value of an external interrupt INT0 and sending each bit of data of the rotating speed to a display D2, namely 1-3 bits of the real-time rotating speed display; calculating the specified rotating speed of the direct current motor according to the duty ratio of the PWM wave and sending each bit of data of the rotating speed to a display D1, namely 1-3 bits of the display with the specified rotating speed;

turning: when the external interrupt INT1 of the single chip microcomputer U1 rises, the external interrupt INT0 acquires a high level, TURNs to TURN 0, indicates that the direct current motor rotates forwards, and sends '0' to two highest displayed positions in a program of a timing/counter T0; on the rising edge of the external interrupt INT1, the external interrupt INT0 goes low, TURNs to TURN 10, indicating inversion, and sends "-" to the highest bit of the two displays in the timer/counter T0 routine.

7. The PWM speed regulation method of the direct current motor according to claim 6, characterized in that: the key adjusting module commands comprise forward rotation, reverse rotation, acceleration, deceleration and stop, when the forward rotation key1 is pressed, the pin 39 and the pin 38 of the single chip microcomputer U1 output forward rotation commands, the direction of current output by the driving chip U2 added at two ends of the armature of the direct current motor is positive, and the direct current motor is controlled to rotate forward; when the reverse key2 is pressed, the pin 39 and the pin 38 of the singlechip U1 output reverse instructions, the direction of current output by the chip U2 added at the two ends of the armature of the direct current motor is driven to change, and the direct current motor is controlled to rotate reversely; when the acceleration key _ add or the deceleration key _ dec is pressed, the duty ratio D% of the PWM wave output by the pin 37 of the singlechip U1 is correspondingly increased or decreased, the voltage output by the driving chip U2 applied to two ends of the armature of the direct current motor is changed, the effective voltage at two ends of the armature of the direct current motor is changed, and therefore the rotating speed is changed; when the stop key3 is pressed, the single chip microcomputer pins 37-39 are not output, and the direct current motor stops running.

8. The PWM speed regulation method of the direct current motor according to claim 6, characterized in that: the serial port communication instruction is sent by the upper computer, the upper computer sends 1-5 to respectively indicate forward rotation, reverse rotation, acceleration, deceleration and stop, and the functions of the serial port communication instruction are consistent with the control of the key adjusting module.

9. The PWM speed regulation method of the direct current motor according to claim 6, wherein the output of the PWM wave adopts a program of a timer/counter T1, and the specific steps are as follows:

the global variable count serving as a duty ratio initial value is 50, the global variable time serving as a count value initial value is 0, when the timer T1 finishes timing, the global variable time is increased by 1, the global variable time is compared with the global variable count, if the time is less than or equal to the count, the PWM output is high level, if the time is greater than or equal to the count, the PWM output is low level, and when the global variable time is greater than 100, the global variable time is given with the initial value of 0, so that a complete PWM wave can be output, the value of the duty ratio "count" is assigned by a key, the value of the acceleration key "count" is increased by 10, the value of the deceleration key "count" is decreased by 10, and the PWM wave of which the duty ratio changes along with the value of the "count" is modulated.

Technical Field

The invention belongs to the technical field of electronics, and particularly relates to a direct current motor PWM speed regulation system and a direct current motor PWM speed regulation method.

Background

The direct current motor has good linear characteristics, is widely applied to places such as factories and mines, hospitals, aerospace and aviation and the like, and has great contribution in economic production. The requirements of speed and steering are different in different production and living occasions, so that the speed and steering control is of great importance. The traditional speed regulation mode of the direct current motor mainly comprises two modes: one is to change the exciting current of the direct current motor to change the rotating speed of the direct current motor, the lower the exciting current is, the faster the speed of the direct current motor is, but the exciting current cannot be zero, otherwise, the danger of galloping can occur; the other is to change the armature voltage of the direct current motor to change the rotating speed of the direct current motor, and the higher the armature voltage is, the faster the speed of the direct current motor is. Both methods can realize no-difference regulation, but the weak magnetism and the voltage of the two speed regulation methods cannot be accurately controlled, and the accurate speed regulation cannot be realized. In addition, the direction of the current applied to the two ends of the armature of the direct current motor must be changed when the direction of the direct current motor is changed, the wiring of the traditional mode is very complicated, a switch needs to be manually turned, and rapidity cannot be achieved.

However, in some occasions requiring precise rotating speed and quick response, the traditional speed regulation mode cannot meet the requirement, so the invention provides the direct current motor PWM speed regulation system and the direct current motor PWM speed regulation method suitable for the occasions.

Disclosure of Invention

The invention provides a PWM speed regulating system and method for a direct current motor, aiming at the problem that the traditional speed regulating mode cannot meet the requirements of occasions requiring precise rotating speed and quick response. The invention takes the single chip microcomputer AT89C51 as a core, takes the Proteus as a development platform, builds a system model, designs a direct current motor speed regulating system and realizes the digital accurate regulation of the direct current motor.

In order to achieve the purpose, the invention adopts the following technical scheme:

the PWM speed regulation principle of the direct current motor is as follows:

pulse Width Modulation (PWM), the circuit is switched on and off according to a certain frequency and the switching-on time (t)on) The ratio to the pulse period (T) is referred to as the duty cycle D%. The voltage of the armature end of the DC motor in a plurality of periods is the effective value of the chopping voltage in the period.

When the circuit is always on, the voltage is added to the direct currentThe armature terminal voltage of the motor is U; when the duty ratio is D%, the voltage applied to the armature end of the DC motor is Ud

Ud=U*D% (1)

When the circuit is always on, the rotating speed of the direct current motor is V; when the duty ratio is D%, the rotating speed of the direct current motor is Vd

Vd=V*D% (2)

The duty ratio of the PWM wave is adjusted through the singlechip AT89C52, so that digital accurate output can be realized. Because the output voltage of the single chip microcomputer is 3-5V, PWM waves do not directly control the direct current motor, but indirectly control an H-shaped double-bridge circuit built by power electronic devices to regulate the speed of a large direct current motor, or control a special driving chip of the direct current motor to regulate the speed of a 12-36V small direct current motor. The steering of the direct current motor can be changed by outputting different combined switching signals by the single chip microcomputer, and the direction of armature current input into the direct current motor is changed by the H-shaped double-bridge circuit or the special driving chip according to the signal combination so as to change the steering of the direct current motor. Because the PWM wave duty ratio can realize the output of digital level, and the output speed is the reaction time of power electronic devices and special driving chips, and is about at millisecond level, the speed regulation of the direct current motor is more accurate and faster by the method, and the method can be suitable for the occasions with precise speed regulation and fast reaction.

The invention provides a PWM speed regulating system of a direct current motor, which comprises a singlechip U1, a driving chip U2, the direct current motor, a power module, a key adjusting module, an enabling chip U3, a display D1, a display D2, a crystal oscillator X1, a serial communication module and other peripheral circuits, wherein the power module is connected with the singlechip U1;

the pin 1 and the pin 2 of the direct current motor are respectively connected with the pin 3 and the pin 6 of the driving chip U2, and the pin 3 and the pin 4 of the direct current motor are respectively connected with the pin 12 and the pin 13 of the singlechip U1; the pin 1, the pin 7 and the pin 2 of the driving chip U2 are respectively connected with pins 37-39 of a single chip microcomputer U1, the pin 8 and the pin 16 of the driving chip U2 are respectively connected with a power supply VCC1 and a power supply VCC of a power supply module, and the pin 15 and the pin GND of the driving chip U2 are grounded; the pin 2 and the pin 1 of the crystal oscillator X1 are respectively connected with the pin 18 and the pin 19 of the singlechip U1; one ends of five key switches S2-S6 of the key adjusting module are respectively connected with pins 36-32 of a single chip microcomputer U1, and the other ends of the five key switches are grounded after being in short circuit; pin 1, pin 12 and pin 13 of the enable chip U3 are respectively connected with pins 1-3 of the singlechip U1, pin 14, pin 16, pin 20, pin 23, pin 21, pin 15, pin 17 and pin 22 of the enable chip U3 are respectively connected with pins 1-8 of the display D1 and the display D2, pin 2, pin 11, pin 6 and pin 7 of the enable chip U3 are respectively connected with pins 9-12 of the display D1, and pin 3, pin 10, pin 5 and pin 8 of the enable chip U3 are respectively connected with pins 9-12 of the display D2.

Further, the singlechip U1 is an AT89C52 singlechip; the driving chip U2 is an L293D driving chip, is a four-way high-current double-bridge driver, and is internally provided with four high-current double-bridge circuits which are special enabling chips for the direct-current motor; the direct current motor is a sensor with a working voltage of 12V and a photoelectric speed meter; the key adjusting module comprises a forward rotation key1, a reverse rotation key2, an acceleration key _ add, a deceleration key _ dec and a stop key 3; the enabling chip is an 8-bit nixie tube enabling chip MAX 7221; the display D1 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D1, the display D2 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D2, and the expected rotating speed and the real-time rotating speed of the direct current motor are respectively displayed; the serial port communication module comprises a serial port P1 and an upper computer, a pin 2 and a pin 3 of a serial port P1 are respectively connected with a pin 10 and a pin 11 of a single chip microcomputer U1, and a pair of connected serial ports distributed by a virtual serial port assistant is connected with the serial port P1 and the upper computer. Since the L293D driving chip can provide DC current of up to 600mA at the voltage of 4.5V-36V, the L293D driving chip can supply power and regulate the speed of a 4.4V-36V DC motor, the rated voltage of the DC motor used in the system is 12V, and the speed of the DC motor can be regulated by L293D.

Further, when the direct current motor is a high-power direct current motor, the driving chip U2 is replaced by an H-type double-bridge circuit built by power electronics.

Further, the serial port communication module can also be a specific communication device such as bluetooth, WIFI, 5G.

Furthermore, the photoelectric velometer of the sensor is a photoelectric coded disc, and the photoelectric coded disc is provided with two optical sensors.

The invention also provides a PWM speed regulation method of the direct current motor, wherein the speed regulation comprises regulation control of the steering, the rotating speed and the starting and stopping of the direct current motor; the method specifically comprises the following steps:

step 1, regulating and controlling the rotation direction, the rotation speed and the stop of a direct current motor:

the adjustment and control process of the rotation direction of the direct current motor is that after the single chip microcomputer U1 receives the instruction of the key adjustment module or the serial port communication module, signals of different combinations are output on the pin 39 and the pin 38 to control the flowing direction of the current between OUT1 and OUT2 of the driving chip U2, so that the current direction of the armature end of the direct current motor is controlled, and the forward and reverse rotation of the direct current motor is finally adjusted;

the adjusting and controlling process of the rotating speed of the direct current motor comprises the following steps: after receiving the instruction of the key adjusting module or the serial port communication module, the single chip microcomputer U1 outputs a modulated PWM wave on a pin 37 of the single chip microcomputer U1, and then the EN1 of the driving chip U2 enables and controls the voltage between OUT1 and OUT2, so as to control the rotating speed of the direct current motor;

step 2, collecting the regulation and control signals in the step 1: the external interrupt INT0 of the single chip microcomputer U1 is matched with a timing/counter T0 program to acquire and calculate the rotating speed of the direct current motor, and the external interrupt INT0 and the external interrupt INT1 of the single chip microcomputer U1 are matched to judge the rotation direction of the direct current motor;

and 3, acquiring a regulation signal in the step 2, and displaying:

rotating speed: when an external interrupt INT0 of the single chip microcomputer U1 acquires a high level, adding 1 to the num count value of the global variable; in a program of a timer/counter T0, timing one second, calculating the real-time rotating speed (rad/s) of the direct current motor according to a num count value of an external interrupt INT0, and sending each bit of data of the rotating speed to a display D2, namely 1-3 bits of the real-time rotating speed display; calculating the specified rotating speed (rad/s) of the direct current motor according to the PWM wave duty ratio and sending each bit of data of the rotating speed to a display D1, namely 1-3 bits of the specified rotating speed display;

turning: when the external interrupt INT1 of the single chip microcomputer U1 rises, the external interrupt INT0 acquires a high level, TURNs to TURN 0, indicates that the direct current motor rotates forwards, and sends '0' to two highest displayed positions in a program of a timing/counter T0; on the rising edge of the external interrupt INT1, the external interrupt INT0 goes low, TURNs to TURN 10, indicating inversion, and sends "-" to the highest bit of the two displays in the timer/counter T0 routine.

Further, the key adjusting module commands comprise forward rotation, reverse rotation, acceleration, deceleration and stop, when the forward rotation key1 is pressed, the pin 39 and the pin 38 of the single chip microcomputer U1 output forward rotation commands, the direction of current output by the driving chip U2 added at two ends of the armature of the direct current motor is positive, and the direct current motor is controlled to rotate forward; when the reverse key2 is pressed, the pin 39 and the pin 38 of the singlechip U1 output reverse instructions, the direction of current output by the chip U2 added at the two ends of the armature of the direct current motor is driven to change, and the direct current motor is controlled to rotate reversely; when the acceleration key _ add or the deceleration key _ dec is pressed, the duty ratio D% of the PWM wave output by the pin 37 of the singlechip U1 is correspondingly increased or decreased, the voltage output by the driving chip U2 applied to two ends of the armature of the direct current motor is changed, the effective voltage at two ends of the armature of the direct current motor is changed, and therefore the rotating speed is changed; when the stop key3 is pressed, the single chip microcomputer pins 37-39 are not output, and the direct current motor stops running.

Further, the serial port communication instruction is sent by the upper computer, the upper computer sends 1-5 to respectively indicate forward rotation, reverse rotation, acceleration, deceleration and stop, and the functions of the serial port communication instruction are consistent with the control of the key adjusting module.

The output of the PWM wave adopts a timing/counter T1 program, which is specifically as follows:

the global variable count serving as a duty ratio initial value is 50, the global variable time serving as a count value initial value is 0, when the timer T1 finishes timing, the global variable time is increased by 1, the global variable time is compared with the global variable count, if the time is less than or equal to the count, the PWM output is high level, if the time is greater than or equal to the count, the PWM output is low level, and when the global variable time is greater than 100, the global variable time is given with the initial value of 0, so that a complete PWM wave can be output, the value of the duty ratio "count" is assigned by a key, the value of the acceleration key "count" is increased by 10, the value of the deceleration key "count" is decreased by 10, and the PWM wave of which the duty ratio changes along with the value of the "count" is modulated.

Compared with the prior art, the invention has the following advantages:

1. the invention adopts an AT89C52 singlechip to interrupt the external INT0 to generate PWM (pulse-width modulation) waves to control the L293D driving chip to drive the DC motor to regulate the speed, and converts the rotating speed of the DC motor from analog quantity to digital quantity by using a photoelectric code disc so as to realize the digitization of the speed regulation of the DC motor. Because the PWM wave duty ratio can realize the output of digital level, and the output speed is the reaction time of power electronic devices and special driving chips, and is about at millisecond level, the speed regulation of the direct current motor is more accurate and faster by the method, and the method can be suitable for the occasions with precise speed regulation and fast reaction.

2. Besides the traditional button control, the invention can also utilize the serial port function to regulate the speed of the direct current motor by accessing communication technologies such as Bluetooth, WIFI, 5G and the like and using a PC, a mobile terminal and the like. The direct current motor is connected into the Internet of things pair through the serial port function, and the direct current motor can be remotely controlled.

3. The system adopts the MAX7221 chip to control two four-digit LED digital displays for displaying the specified rotating speed and the real-time rotating speed, thereby saving the interfaces of a single chip microcomputer; the external interrupt INT0 of the AT89C52 singlechip is matched with the external interrupt INT1 to collect and calculate the rotating speed and the rotating direction of the direct current motor, and the speed of the direct current motor is output to a four-digit digital display.

4. The system of the invention reserves an upgrade window, can transplant different communication technologies according to requirements, and selects different terminals to regulate the speed of the direct current motor. And a DC motor with higher power can be controlled by replacing the DC motor driving chip.

Drawings

FIG. 1 is a schematic circuit diagram of the system of the present invention.

FIG. 2 is a flow chart of the key adjustment module.

Fig. 3 shows a timing/counter T1 routine for the PWM wave output.

Fig. 4 is a flowchart of the program of the timer/counter T1 used for outputting the PWM wave.

Fig. 5 is an external interrupt INT0 program diagram.

Fig. 6 is a timer/counter T0 routine.

FIG. 7 is an external interrupt INT1 routine.

FIG. 8 is a flow chart of the control signal display.

Fig. 9 is a dc motor parameter set.

FIG. 10 shows the crystal frequency setting in Keil 5.

FIG. 11 shows the crystal frequency setting in Proteus.

Fig. 12 is a serial port arrangement.

Fig. 13 is a schematic diagram of the forward rotation operation of the dc motor.

Fig. 14 is a schematic view of the reverse operation of the dc motor.

Fig. 15 is a schematic view of the dc motor stopping operation.

Fig. 16 is a schematic diagram of the rotational speed control of the dc motor. Wherein (a) represents a forward rotation acceleration schematic diagram of a direct current motor; (b) the schematic diagram of the reverse rotation acceleration of the direct current motor is shown; (c) the schematic diagram of forward rotation and deceleration of the direct current motor is shown; (d) the reverse speed reduction schematic diagram of the direct current motor is shown.

FIG. 17 is a schematic diagram of the setup of a host computer and its human-computer interaction.

Detailed Description

The technical solution in the embodiments of the present invention will be specifically and specifically described below with reference to the embodiments of the present invention and the accompanying drawings. It should be noted that variations and modifications can be made by those skilled in the art without departing from the principle of the present invention, and these should also be construed as falling within the scope of the present invention.

Example 1

Designing a PWM speed regulating system of the direct current motor:

as shown in fig. 1, the PWM speed control system of the dc motor of the present invention includes a single chip microcomputer U1, a driving chip U2, a dc motor, a power module, a key adjustment module, an enable chip U3, a display D1, a display D2, a crystal oscillator X1, a serial communication module, a potentiometer RP1, resistors R1 to R6, R8, capacitors CI to C3, and a switch S1;

the pin 1 and the pin 2 of the direct current motor are respectively connected with the pin 3 and the pin 6 of the driving chip U2, and the pin 3 and the pin 4 of the direct current motor are respectively connected with the pin 12 and the pin 13 of the singlechip U1; the pin 1, the pin 7 and the pin 2 of the driving chip U2 are respectively connected with pins 37-39 of a single chip microcomputer U1, the pin 8 and the pin 16 of the driving chip U2 are respectively connected with a power supply VCC1 and a power supply VCC of a power supply module, the voltage value of the power supply VCC1 is 12V, and the pin 15 and the pin GND of the driving chip U2 are grounded; the pin 2 and the pin 1 of the crystal oscillator X1 are respectively connected with the pin 18 and the pin 19 of the singlechip U1; one ends of five key switches S2-S6 of the key adjusting module are respectively connected with pins 36-32 of a single chip microcomputer U1 and are respectively connected with one sections of pull-up resistors S1-S5, the other ends of the five key switches S2-S6 are grounded after being in short circuit, and the other ends of the pull-up resistors S1-S5 are connected with a power supply VCC; the pin 1, the pin 12 and the pin 13 of the enable chip U3 are respectively connected with pins 1-3 of a single chip microcomputer U1, the pin 14, the pin 16, the pin 20, the pin 23, the pin 21, the pin 15, the pin 17 and the pin 22 of the enable chip U3 are respectively connected with pins 1-8 of a display D1 and a display D2, the pin 2, the pin 11, the pin 6 and the pin 7 of the enable chip U3 are respectively connected with pins 9-12 of a display D1, and the pin 3, the pin 10, the pin 5 and the pin 8 of the enable chip U3 are respectively connected with pins 9-12 of the display D2; pin 1 of the potentiometer RP1 is connected with a power supply VCC, and pins 2 and 3 are respectively connected with pin 39 and pin 38 of the singlechip U1; one end of a capacitor C1 is connected with a pin 1 of a crystal oscillator X1, one end of a capacitor C2 is connected with a pin 2 of the crystal oscillator X1, the other end of the capacitor C1 is grounded after being short-circuited with the other end of the capacitor C2, one end of a capacitor C3 is connected with a pin 9 of a singlechip U1 and then connected with one end of a capacitor R8, the other end of a resistor R8 is grounded, and the other end of the resistor C3 is connected with a power supply VCC; the switch S1 is connected in parallel to two ends of the resistor C3; one end of the resistor R6 is connected to the pin 18 of the enable chip U3, and the other end is connected to the power supply VCC.

The single chip microcomputer U1 is an AT89C52 single chip microcomputer; the driving chip U2 is an L293D driving chip, is a four-way high-current double-bridge driver, and is internally provided with four high-current double-bridge circuits which are special enabling chips for the direct-current motor; the direct current motor is a sensor (a photoelectric code disc, and the photoelectric code disc is provided with two optical sensors) with the working voltage of 12V and a photoelectric speed meter; the key adjusting module comprises a forward rotation key1, a reverse rotation key2, an acceleration key _ add, a deceleration key _ dec and a stop key 3; the enabling chip is an 8-bit nixie tube enabling chip MAX 7221; the display D1 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D1, the display D2 is a 7SEG-MPX4-CC four-position eight-segment common-cathode nixie tube D2, and the expected rotating speed and the real-time rotating speed of the direct current motor are respectively displayed; the serial port communication module comprises a serial port P1 and an upper computer, the serial port P1 is RS232, a pin 2 and a pin 3 of the serial port P1 are respectively connected with a pin 10 and a pin 11 of a single chip microcomputer U1, and a pair of connected serial ports distributed by a virtual serial port assistant is used for connecting the serial port P1 with the upper computer.

Example 2

The speed regulation comprises regulation control of the rotation direction, the rotation speed and the stop of the direct current motor; the method specifically comprises the following steps:

1. regulating and controlling the rotation direction, the rotation speed and the stop of the direct current motor:

the adjustment control process of the direct current motor steering is as follows: after receiving the instruction of the key adjusting module or the serial port communication module, the single chip microcomputer U1 outputs signals of different combinations on the pin 39 and the pin 38 to control the flowing direction of the current between OUT1 and OUT2 of the driving chip U2, so as to control the current direction of the armature end of the direct current motor and finally adjust the forward and reverse rotation of the direct current motor;

the adjusting and controlling process of the rotating speed of the direct current motor comprises the following steps: after receiving the instruction of the key adjusting module or the serial port communication module, the single chip microcomputer U1 outputs a modulated PWM wave on a pin 37 of the single chip microcomputer U1, and then the EN1 of the driving chip U2 enables and controls the voltage between OUT1 and OUT2, so as to control the rotating speed of the direct current motor;

the key adjusting module commands comprise forward rotation, reverse rotation, acceleration, deceleration and stop, when the forward rotation key1 is pressed, the pin 39 and the pin 38 of the single chip microcomputer U1 output forward rotation commands, the direction of current output by the driving chip U2 added at two ends of the armature of the direct current motor is positive, and the direct current motor is controlled to rotate forward; when the reverse key2 is pressed, the pin 39 and the pin 38 of the singlechip U1 output reverse instructions, the direction of current output by the chip U2 added at the two ends of the armature of the direct current motor is driven to change, and the direct current motor is controlled to rotate reversely; when the acceleration key _ add or the deceleration key _ dec is pressed, the duty ratio D% of the PWM wave output by the pin 37 of the singlechip U1 is correspondingly increased or decreased, the voltage output by the driving chip U2 applied to two ends of the armature of the direct current motor is changed, the effective voltage at two ends of the armature of the direct current motor is changed, and therefore the rotating speed is changed; when the stop key3 is pressed, the single chip microcomputer pins 37-39 are not output, and the direct current motor stops running. The flow is shown in fig. 2.

The serial port communication instruction is sent by the upper computer, the upper computer sends 1-5 to respectively indicate forward rotation, reverse rotation, acceleration, deceleration and stop, and the functions of the serial port communication instruction are consistent with the control of the key adjusting module.

The output of the PWM wave adopts a timing/counter T1 program, which is specifically as follows:

the global variable count serving as a duty ratio initial value is 50, the global variable time serving as a count value initial value is 0, when the timer T1 finishes timing, the global variable time is increased by 1, the global variable time is compared with the global variable count, if the time is less than or equal to the count, the PWM output is high level, if the time is greater than or equal to the count, the PWM output is low level, and when the global variable time is greater than 100, the global variable time is given with the initial value of 0, so that a complete PWM wave can be output, the value of the duty ratio "count" is assigned by a key, the value of the acceleration key "count" is increased by 10, the value of the deceleration key "count" is decreased by 10, and the PWM wave of which the duty ratio changes along with the value of the "count" is modulated. The PWM wave output routine is shown in fig. 3. The PWM wave output program flow is shown in fig. 4.

2. Collecting the regulation and control signals in the step 1: the external interrupt INT0 of the single chip microcomputer U1 is matched with a timing/counter T0 program to acquire and calculate the rotating speed of the direct current motor, and the external interrupt INT0 and the external interrupt INT1 of the single chip microcomputer U1 are matched to judge the rotation direction of the direct current motor;

3. and 2, acquiring a regulation signal to display:

rotating speed: when the external interrupt INT0 of the single chip microcomputer U1 acquires a high level, the count value of the global variable num is added with 1 (figure 5); in a program of a timer/counter T0, timing one second, calculating the real-time rotating speed (rad/s) of the direct current motor according to a num count value of an external interrupt INT0, and sending each bit of data of the rotating speed to a display D2, namely 1-3 bits of the real-time rotating speed display; calculating the specified rotating speed (rad/s) of the direct current motor according to the PWM wave duty ratio and sending each bit of data of the rotating speed to a display D1, namely 1-3 bits of the specified rotating speed display (figure 6);

turning: when the external interrupt INT1 of the single chip microcomputer U1 rises, the external interrupt INT0 acquires a high level, TURNs to TURN 0, indicates that the direct current motor rotates forwards, and sends '0' to two highest displayed positions in a program of a timing/counter T0; on the rising edge of the external interrupt INT1, the external interrupt INT0 goes low, TURNs to TURN 10, indicating inversion, and sends "-" to the highest bit of the two displays in the timer/counter T0 routine. The external interrupt INT1 routine is shown in fig. 7 and the flow chart is shown in fig. 8.

Example 3

And (3) system testing:

and (3) taking the Proteus as a development platform, building a system model, and carrying out combined simulation by using Keil 5 and the Proteus to realize speed plus-minus adjustment, steering conversion control and start-stop operation of the direct current motor.

The voltage of the direct current motor is 12V, the driving current is 100mA, and the maximum rotating speed is 500r/min when the photoelectric code disc rotates 48 pulses. The dc motor parameters are shown in fig. 9. The crystal frequency was set to 11.0592MHz, and the crystal frequency setting of the chip set in Keil 5 and Proteus software is shown in fig. 10 and 11. The serial port bit rate is set to 9800, the virtual serial port debugging software allocates a pair of connected serial ports (com2, com3), the serial ports use com3, and the upper computer uses com2, as shown in fig. 12.

Start/stop control: clicking a forward rotation key1 key to control the forward rotation of the direct current motor, wherein the duty ratio of a PWM wave is 50%, the initial speed of the direct current motor is 250r/min, the designated speed display immediately shows '0250', the rotating speed of the direct current motor is 250r/min, the real-time speed display follows the speed change of the direct current motor, and three bits after the real-time rotating speed gradually approach the expected rotating speed from 0 (figure 13). If the reverse key2 is pressed, the DC motor will rotate in reverse, and the speed will be displayed as if it is rotating in forward direction (FIG. 14). Pressing the stop key3 key starts the deceleration of the dc motor and finally stops the rotation (fig. 15).

Acceleration/deceleration control: when the direct current motor starts to rotate by clicking the forward rotation key1 key or the reverse rotation key2 key, the acceleration key _ add key is clicked at the moment, the duty ratio of the PWM wave is increased, and the speed of the direct current motor starts to rise. And pressing a deceleration key _ dec key to perform direct current, reducing the duty ratio of the PWM wave, starting to reduce the speed of the direct current motor, and changing a rotating speed display system of the direct current motor along with the change of the rotating speed of the direct current motor. The speed threshold of each speed ascending or descending gear is 25r/min, and positive and negative rotation adjustment can be carried out or stop after acceleration and deceleration are finished. As shown in fig. 16.

Controlling by an upper computer: the upper computer sends a "1", the simulated forward key1 is pressed, the upper computer sends a "2", the simulated reverse key2 is pressed, the upper computer sends a "3", the simulated acceleration key _ add is pressed, the upper computer sends a "4", the simulated deceleration key _ dec is pressed, the upper computer sends a "5", and the simulated stop key3 is pressed. The setting of the upper computer and the man-machine interaction thereof are shown in fig. 17.

20页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:分数阶永磁同步发电机的模糊有限时间最优同步控制方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!