Design based on single-chip PID motor speed control design-based on single-chip LED bar screen display temperature and time design-based on single-chip PM2.

1273 Based on single-chip microcomputer PID motor speed control design - complete course design materials

/*****************************************************************************************
*文件名:pid.c
*文件描述:PID控制电机转速

*****************************************************************************************/

#include <reg51.h>
#include <intrins.h>

sbit plus_10=P1^3; 			   //对各个按钮进行位定义
sbit minus_10=P1^4;
sbit plus=P1^5;
sbit minus=P1^6;
sbit enter=P1^7;
sbit PWM_OUT1=P1^1;
sbit PWM_OUT2=P1^0;
sbit dir=P1^2;

struct PID         				//定义PID结构体
{
	int SetValue;   			//设定值
//	long SumError; 				//误差
	double Proportion; 			//比例系数
	double Integral; 			//积分系数
	double Derivative; 			//微分系数
	int LastError;
	int PrevError;
}sPID,*sptr= &sPID;

int PWM,PWM_temp=1,count0=0,Speed_Set,Seep_Measure,counter_100ms,counter_10ms;
bit flag_100ms,flag_10ms,start,plus_10_lock=1,minus_10_lock=1,plus_lock=1,
    minus_lock=1,enter_lock=1;
char num[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};//0~9 对应数码

/*****************************************************************************************
*函数名:void delayms(unsigned char x)
*函数功能:简单延时 支持0~255ms

1272 is based on the single-chip microcomputer LED bar screen display temperature and time design - complete course design information

#include "..\INCLUDE\config.h"
#include "..\FONT\FONT.H"
uint8 Temp_Value;
void TEMP_Delay(uint16 i)
{
	while(i--);
}
void TEMP_INITIALIZE()
{
	DQ=1;
	TEMP_Delay(8);
	DQ=0;
	TEMP_Delay(80);
	DQ=1;
	TEMP_Delay(14);
	TEMP_Delay(20);
}

uint8 TEMP_Read_Char()
{
	uint8 i;
	uint8 dat;
	for(i=0;i<8;i++)
	{
		DQ=0;
		dat>>=1;
		DQ=1;
		if(DQ)
		dat|=0x80;
		TEMP_Delay(4);
	}
	return dat;
}

void TEMP_Write_Char(uint8 dat)
{
	uint8 i;
	for(i=0;i<8;i++)
	{
		DQ=0;
		DQ=dat&0x01;
		TEMP_Delay(5);
		DQ=1;
		dat>>=1;
	}
}


void TEMP_Read()
{
	uint8 a,b;
	TEMP_INITIALIZE();
	TEMP_Write_Char(0xcc);
	TEMP_Write_Char(0x44);
	TEMP_Delay(100);

1279 PM2.5 haze detection and processing control design based on single-chip microcomputer - complete course design information

#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD P0 	                             //
sbit PM2_5 = P2^1;  //PM2.5模块PWM输入口
sbit busy=P0^7;     // "忙"标志位
sbit add=P1^0;
sbit jian=P1^1;
sbit ledred=P1^2;
sbit ledgreen=P1^3;
sbit sanji=P2^2;
sbit erji=P2^3;
sbit yiji=P2^4;
sbit guolvwang=P2^0;
sbit warning=P1^7;  
uint ji=120;  
uint LowPulseTime_30s = 0; //30秒内低电平的时间,单位为ms
uint LowPulseTime_3s = 0; //3秒内低电平的时间,单位为ms
uint TotalTime_3s = 0;//总时间,3秒计数器
uint TotalTime_30s = 0;//总时间,30秒计数器*
uint LowperTotal = 0; //30秒内的低脉冲率,就是30秒内的低脉冲时间除以30秒的总时间,范围为5%~25%
uint Concen = 0;//浓度值,整数
uint pulseTime[10] = {0};  //每隔3秒的低电平时间数组,10项刚好就是30秒
uchar Index = 0; //上述数组的索引
bit bFreshDis = 0; //显示值刷新标志位,每隔3秒刷新一次显示
bit bStartDis = 0; //开始显示浓度值标志位,因为上电后要等30秒的预热时间才能计算浓度值
#define INT_CLOCK 1 //INT_CLOCK为定时值,单位为ms ,此处定义为1ms
#define CRY_FREQUENCY 11059200 //CRY_FREQUENCY为晶振频率,单位为,Hz
uchar TL0_temp;	 //暂存TL0的初值 中断值
uchar TH0_temp;	 //暂存TH0的初值
unsigned char fuhao;	
//代码表

1258 based on single-chip 8155 stopwatch timer system design - complete course design information

/***********************基于8155的8LED显示电子表设计************************************************/
#include<reg52.h>
#include<absacc.h>

/*******************************************宏定义***************************************************/
#define uint unsigned int
#define uchar unsigned char

/*******************************************定义8155地址***********************************************/
#define COM8155  XBYTE[0X7FF8]		  //8155的命令口
#define PA8155   XBYTE[0X7FF9]		  //8155的PA
#define PB8155   XBYTE[0X7FFA]		  //8155的PB
#define PC8155   XBYTE[0X7FFB]		  //8155的PC

/*******************************************定义数码管显示的码值**************************************/
uchar code du_code[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; 	//8段共阴极数码管显示码值	  
uchar  dis_buf[]={0x3f,0x3f,0x40,0x3f,0x3f,0x40,0x3f,0x3f}; 			   //数码管显示缓存,格式为MM-NN-SS
uchar code bit_code[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};		   //数码管显示的位值
	
/*******************************************定义系统变量***************************************************/
bit flag=0;													 //计时状态标志位
bit flag1=0,flag2=0,flag3=0,flag4=0;						 //按键状态标志位
uchar num,second,minute,hour;									//秒表变量
uchar count=0,count1=0;		                    			//计数器变量

Design of 1285 temperature and humidity acquisition and alarm system based on single-chip microcomputer SHT11 - a complete set of information

#include<reg51.h> 
#include <intrins.h>  
#include <math.h>   
#include <stdio.h>    
#define LCD_DB        P0 
sbit         LCD_RS=P2^0;   
sbit         LCD_RW=P2^1;  
sbit         LCD_E=P2^2;     
sbit         beep = P1^7;
sbit         key1 = P3^0;
sbit         key2 = P3^1;
sbit		     key3 = P3^2;
sbit		     key4 = P3^3;

unsigned char Time;		  //用来存放定时时间
unsigned char Second;
unsigned char w;  //标志位
unsigned char wendumode = 0;
unsigned char shidumode = 0;
unsigned char  wenduCB = 40;
unsigned char  shiduCB = 100;
unsigned int wendu,shidu;     

/******定义函数****************/ 
#define uchar unsigned char 
#define uint unsigned int 
void LCD_init(void);                          //初始化函数 
void LCD_write_command(uchar command);        //写指令函数 
void LCD_write_data(uchar dat);               //写数据函数  
void LCD_disp_char(uchar x,uchar y,uchar dat);//在某个屏幕位置上显示一个字符,X(0-15),y(1-2)  
void LCD_disp_str(uchar x,uchar y,uchar *str); //LCD1602显示字符串函数 
void delay_n10us(uint n);                     //延时函数


The article is transferred from Dianshewu, and the download address of the data Baidu network disk  is https://www.aiesst.cn/share.html

Table of contents

1273 Based on single-chip microcomputer PID motor speed control design - complete course design materials

1272 is based on the single-chip microcomputer LED bar screen display temperature and time design - complete course design information

1279 PM2.5 haze detection and processing control design based on single-chip microcomputer - complete course design information

1258 based on single-chip 8155 stopwatch timer system design - complete course design information

Design of 1285 temperature and humidity acquisition and alarm system based on single-chip microcomputer SHT11 - a complete set of information


Guess you like

Origin blog.csdn.net/u014683833/article/details/123385534