07、基于ADC0808/ADC0809的多通道电压采集程序设计

一、Proteus仿真电路图如下07、基于ADC0808/ADC0809的多通道电压采集程序设计_第1张图片07、基于ADC0808/ADC0809的多通道电压采集程序设计_第2张图片

二、部分程序

#include 
#include 
#define uint  unsigned int
#define uchar unsigned char
#define ulong unsigned long
/*74HC595所有引脚定义*/
sbit HC595_DAT  = P2^0;
sbit HC595_CLK  = P2^1;
sbit HC595_STC  = P2^2;
/*ADC0809所有引脚定义*/
sbit OE  = P1^0;
sbit EOC = P1^1;
sbit ST  = P1^2;
sbit CLK = P1^3;
sbit CC  = P1^6;
sbit BB  = P1^5;
sbit AA  = P1^4;
/*数码管段选(带小数点)*/
uchar LEDData[10]=
{
  0x03,	/*0*/
  0x9F, /*1*/
  0x25, /*2*/
  0x0D, /*3*/
  0x99, /*4*/
  0x49,	/*5*/
  0x41,	/*6*/
  0x1F,	/*7*/
  0x01,	/*8*/
  0x09	/*9*/
};
/*数码管段选(不带小数点)*/
uchar LEDData1[10]=
{
  0x02,	/*0*/
  0x9E, /*1*/
  0x24, /*2*/
  0x0C, /*3*/
  0x98, /*4*/
  0x48,	/*5*/
  0x40,	/*6*/
  0x1E,	/*7*/
  0x00,	/*8*/
  0x08	/*9*/
};
/*毫秒延时函数*/
//void DelayMS(uint ms)
//{
// 	uchar i;
//	while(ms--)
//	{
//	 	for(i=0;i<120;i++);
//	}
//}
/*74HC595显示函数*/
uchar v1[3] = {0x03,0x03,0x03};
uchar v2[3] = {0x03,0x03,0x03};
uchar v3[3] = {0x03,0x03,0x03};
void Send_HC595_Byte(uchar temp8)
{
   uchar i;
   for(i = 0; i < 8; i++)
   {
       HC595_DAT = temp8&0x01;//´Ó¸ßλ¿ªÊ¼´«Êä
       HC595_CLK = 0;
       _nop_();
       _nop_();
       HC595_CLK = 1;
       temp8=temp8>>1; 
   }
}
void Display(uchar v1[3],uchar v2[3],uchar v3[3])
{
   HC595_STC = 0;
   Send_HC595_Byte(v1[0]);
   Send_HC595_Byte(v1[1]);
   Send_HC595_Byte(v1[2]);

   Send_HC595_Byte(v2[0]);
   Send_HC595_Byte(v2[1]);
   Send_HC595_Byte(v2[2]);

   Send_HC595_Byte(v3[0]);
   Send_HC595_Byte(v3[1]);
   Send_HC595_Byte(v3[2]);
   HC595_STC = 1;
}
void main()
{
	TMOD = 0x02;
	TH0  = 0xFB;
	TL0  = 0xFB; //500KHZ
	TR0  = 1;
	ET0  = 1;
	EA   = 1;
	while(1)
	{  
		/*通道0转换*/	
		CC = 0;BB = 0;AA = 0;
		ST = 0;
		ST = 1;
		ST = 0;
		_nop_();_nop_();_nop_();
		while(EOC == 0);
		OE = 1;
		v3[2] = LEDData1[P3/100];
		v3[1] = LEDData[P3%100/10];
		v3[0] = LEDData[P3%10]; 
		OE = 0;
		/**************************/
		//1、联系QQ下载:1661727532
		//2、QQ相关交流群:649692007
		//3、增、改程序同1
		//4、学上党下载只要一杯奶茶哦
		//5、文章末尾资源下载也可以
		_nop_();_nop_();_nop_();
		while(EOC == 0);
		OE = 1;
		v1[2] = LEDData[P3/100];
		v1[1] = LEDData[P3%100/10];
		v1[0] = LEDData[P3%10]; 
		OE = 0;
		/*595显示ADC值*/
		Display(v1,v2,v3);
	}
}
void Timer0_INT() interrupt 1
{
	/**************************/
	//1、联-系-Q-Q-下-载-:1661727532
	//2、Q-Q-相-关-交-流-群:649692007
	//3、增、改程序同1
	//4、学生党下载只要一杯奶茶哦
	//5、文章末尾资源下载也可以
}

三、完整程序链接

https://download.csdn.net/download/BaoTTing/12289324

	//1、扣扣下-载:1661727532
	//2、扣扣交流qun:649692007
	//3、增、改程序同上(接毕设,课程设计)
	//4、学生党下载只要一杯奶茶哦
	//5、文章末尾资源下载也可以

你可能感兴趣的:(软件,计算机,单片机,深度学习)