Design of DC motor speed control system based on single chip microcomputer - complete course design materials

[Resource download] The download address is as follows 1550:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl

Design a DC servo motor control system. The control function requires the realization of six functions of motor start, stop control, forward rotation, reverse rotation, acceleration, and deceleration. In order to realize human-computer interaction, buttons and digital tubes are needed.

The specific requirements are as follows: K0 is start/stop control, K1 forward rotation, K2 reverse rotation; K3 accelerates, K4 decelerates, and uses 3 light-emitting diodes to display the status: the red light is on when it is rotating forward, the yellow light is on when it is reversed, and the green light is on when it is not rotating Bright. And use 4-bit LED digital tube to display the motor speed.

Analysis required:

The button K1 is used to control the reverse rotation of the motor. If the motor is in the stop or forward rotation state, when pressing k1, the motor starts to reverse; if the motor is in the reverse rotation state, the motor does not respond to the button command.

The button K2 is used to control the forward rotation of the motor. If the motor is in the stop or reverse state, when pressing k2, the motor will start to rotate forward; if the motor is in the forward rotation state, the motor will not respond to the button command.

Button K3 is used to control the acceleration of the motor. When the motor is running, if the motor has not reached the maximum speed, when the button K3 is pressed, the motor will accelerate. Each time you press the button, the motor will accelerate by one beat. Press the button K3 for the second time, when the motor reaches the maximum speed, the motor will keep running at the maximum speed and will no longer respond to the button command.

The button K4 is used to control the deceleration of the motor. When the motor is running, if the motor has not reached the minimum speed, that is, it is in the stop state. When the button K4 is pressed, the motor will decelerate. Each time you press the motor, the motor will decelerate by one beat. If you need to keep decelerating , you need to press the button K4 several times. When the motor reaches the minimum speed, that is, the motor is in a stopped state, the motor will keep stopping and will no longer respond to the button command.

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit IN1=P1^6;
sbit IN2=P1^7;
sbit ENA=P1^5;
sbit KEY0=P2^0;
sbit KEY1=P2^1;
sbit KEY2=P2^2;
sbit KEY3=P2^3;
sbit KEY4=P2^4;
sbit R=P2^5;
sbit Y=P2^6;
sbit G=P2^7;
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
sbit led=P1^4;

bit flag=0;
bit sign=1;
uint num=0;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};



void delay(uint n)
{
	 uint i,j;
	for(i=n;i>0;i--)
	for(j=0;j<110;j++);
}


void initial()
{
	IN1=0;
	IN2=0;
	ENA=0;
	num=0;
	TMOD=0X01;
	TL0=0XFF;
	TH0=0XFF;
	EA=1;
	EX0=1;
	ET0=1;
	IT0=1;
	TR0=1;
}

Guess you like

Origin blog.csdn.net/AuroraFaye/article/details/115053055