[51 microcontroller series] DC motor use

This article is a relevant introduction to the use of DC motors.


Among the applications of 51 microcontroller, there are also many applications in motor control. Before learning about DC motor (PWM), first use GPIO to control the forward, reverse and stop of the motor. However, GPIO cannot be used directly to drive the motor. It needs to be implemented with a corresponding driver chip.

The ULN2003 chip is used here to drive the motor. The function achieved is: the DC motor stops after working for about 5 seconds.

1. Introduction to DC Motor

A DC motor refers to a rotating motor that can convert DC electrical energy into mechanical energy (DC motor) , or convert mechanical energy into DC electrical energy (DC generator). It is a motor that can realize the mutual conversion of DC electrical energy and mechanical energy.

When it is running as a motor, it is a DC motor, which converts electrical energy into mechanical energy; when it is running as a generator, it is a DC generator, which converts mechanical energy into electrical energy.

The structure of a DC motor consists of two parts: the stator and the rotor.

  • The stationary part of the DC motor when it is running is called the stator. The main function of the stator is to generate a magnetic field. It consists of a base, main magnetic pole, commutating pole, end cover, bearing and brush device.
  • The rotating part during operation is called the rotor. Its main function is to generate electromagnetic torque and induced electromotive force. It is the hub for energy conversion of the DC motor, so it is usually also called the armature. It consists of the rotating shaft, armature core, armature winding, and commutator. Composed of deflector and fan.

There is no distinction between positive and negative DC motors, and they can work by adding DC power to both ends . It is necessary to know the rated voltage and rated power of the DC motor so that it cannot be overloaded for a long time. After exchanging the wiring, forward and reverse can be formed.

The parameters of one of the DC motors are as follows:

Shaft length: 8mm; shaft diameter: 2mm; voltage 1-6V; reference current: 0.35-0.4A;

The actual appearance of the DC motor is as follows:

DC motor physical appearance

The internal structure is as follows:

DC motor internal structure diagram

2. Introduction to ULN2003 chip

The 51 microcontroller is mainly used for control rather than driving. If you directly use the GPIO pins of the chip to drive high-power devices, the chip will either be burned out or cannot be driven. Therefore, to drive high-power devices, such as motors, an external drive circuit must be built.

The ULN2003 chip is used here for driving. This chip has been introduced when using the buzzer, and will be introduced again here.

The ULN2003 chip is a monolithic high-voltage, high-current Darlington transistor array integrated circuit that can be used not only to drive DC motors, but also to drive five-wire four-phase stepper motors, such as the 28BYJ-48 stepper motor.

ULN2003 is composed of 7 pairs of NPN Darlington tubes. Its high voltage output characteristics and cathode clamping diodes can convert inductive loads. The collector current of a single Darlington pair is 500mA. Darlington tubes connected in parallel can handle larger currents. This circuit is mainly used in relay drivers, hammer drivers, lamp drivers, display drivers (LED gas discharge), line drivers and logic buffers.

Each pair of Darlington tubes of ULN2003 has a 2.7K series resistor and can be directly connected to TTL or 5V CMOS devices.

Main features of ULN2003:

  • 500mA rated collector current (single output)
  • High voltage output: 50V
  • Input compatible with various logic types
  • Relay driver

The logic block diagram of UL2003N is as follows:

ULN2003 logic block diagram

From the picture above, you can understand how to use this chip. Its interior is equivalent to a NOT gate circuit. When the input is high level, it outputs low level. When the input is low level, the output is cut off.

If this chip is used to drive a DC motor, only one direction control can be achieved. One end of the motor is connected to the positive pole of the power supply, and the other end is connected to the output port of the chip.

If you want to control a five-wire four-phase stepper motor, you can connect the four outputs to the four phases of the stepper motor, and click the other wire to connect the positive pole of the power supply.

3. Simulate the driving of the motor in proteus

Using the ULN2003 chip to control the five-wire four-phase stepper motor, the proteus simulation design is as follows

proteus simulates ULN2003 to control five-wire four-phase stepper motors

The input of the chip is provided through the P1^0 ~ P1^5 IO ports of the microcontroller, and the output is connected to the stepper motor.

The software design is as follows:

/*
	实现功能:ULN2003芯片控制直流电机转动
	[2023-12-13] zoya
*/
#include "reg52.h"
#include "intrins.h"
#include "typedef.h"

sbit moto1 = P1^0;

// 延时函数,i=1时延时10us
void Delay(u16 i)
{
    
    
	while(i--);
}

void main()
{
    
    
	u8 i;
	moto1 = 0;  // 关闭电机
	for(i=0;i<10;i++) {
    
    
		moto1 = 1; // 开启电机
		Delay(5000);  // 延时大约50ms
	}
	moto1 = 0;  // 关闭电机
	
	while(1)
	{
    
    
	}	
}

Simulation results:

ULN2003 controls motor rotation

Guess you like

Origin blog.csdn.net/sinat_41752325/article/details/134973910