1276【毕设课设】基于单片机PID算法控制电机转速设计
作者:互联网
【资源下载】百度网盘下载地址如下:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
#include <reg52.h> #include "lcd1602.h" sfr T2MOD = 0x0c9; #define uchar unsigned char #define uint unsigned int sbit Q0 = P2^4; sbit Q1 = P2^5; sbit Q2 = P2^6; sbit Q3 = P2^7; sbit GORB = P1^6; //换相 sbit PWM = P1^7; sbit UP = P1^0; sbit DOWM = P1^1; sbit ADDSPEED = P1^2; sbit SUBSPEED = P1^3; uint tuint = 65535; uint tpwm = 1; //pwm周期为10000us tpwm变量表示pwm高电平时间,也相当于占空比 (仿真时,频率高时,电机反应慢。在实物上要加大频率) uchar t1_flag = 0; uint pulse = 0; uint t0_flag = 0; uchar t2_flag = 0; bit t2_over = 0; bit Just_Get = 1; #define ZZ { Q0 = 0;Q1 = 0;Q2 = 1;Q3 = 1;} //正转 #define FZ { Q0 = 1;Q1 = 1;Q2 = 0;Q3 = 0;} //反转 #define STOP { Q0 = 1;Q1 = 0;Q2 = 1;Q3 = 0;} //停止 //禁止出现 Q0 = 0;Q1 = 1;Q2 = 0;Q3 = 1; 不然会烧掉mos管
标签:Q1,Q0,Q2,课设,P1,PID,毕设,sbit,define 来源: https://www.cnblogs.com/ythero/p/14501167.html