基于单片机电机编码测速仿真设计-学习笔记

仿真电路:

 程序:

#include <reg51.h>
#include <math.h>
#define uchar unsigned char
#define uint unsigned int
#define ON 0
#define OFF 1
sbit PWM=P3^5;
sbit MP=P3^4;
bit FLAG=0;
uchar code dispbit[6]={0x20,0x10,0x08,0x04,0x02,0x01};
 
uchar code seg[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
					//0,1,2,3,4,5,6,7,8,9
uchar disbuf[6]={0,0,0,0,10,10};
uint temp[6];
uint discount=0;
uint timecount=0;//定时的次数
uint T0count=0;
uint hus=0;
uint k=60;
uint Vc;
uint Vs;
uint tm=3000;
uint x;
void t0_serv() interrupt 1
{ T0count++;
}

 

 

  

 

posted @ 2021-03-11 09:17  MCU创新DIY  阅读(59)  评论(0)    收藏  举报