此次直流稳压电源设计我主要通过51单片机控制输出来控制电源的电压和显示。
加减置数部分,通过对4X4矩阵键盘的设置,可任意置数,加减, 自动步进,输出波形。
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar aa,bb,cc,dd,jj,ii,jjj,iii,key,j;
uchar time1=0;
sbit led1=P2^0;
sbit led2=P2^1;
sbit ce=P2^4;
#define timer0_count 0xfc18//定时器初值,设置time0 1/1000秒中断一次
const seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//数码管的显示
const seg_point[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//有小数点的数码管显示
uchar scan1;//用来分别显示2个数码管
uchar scan2;
uchar counter[2]={0xf1,0xf2};
uchar vout=0; //j_片选,vout_电压输出
static void timer0_initialize(void)//timer0的初始化
//定时器的初始化程序
{
EA=0; //中断控制器IE--停止接受中断
TR0=0; //停止计时
TMOD=0x01; //设置工作方式为1
TL0=(timer0_count & 0x00ff);
TH0=(timer0_count>>8); //设置time0 初值
PT0=1; //设置timer0高优先级
ET0=1; //允许timer0中断