⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sucessfull.c

📁 我做的测试超小阻值的仪器
💻 C
📖 第 1 页 / 共 2 页
字号:
		  	{
			  	goto lab3;
		  	}
		  if ( ulTmp >= 0 )
		  		goto lab4;

			}
	else
		{

		  if ( ulTmp >= 1000 )
		  		{
		  			lab1:	ul1000=mod_1000(&ulTmp);
								  chucun_ch(ul1000,ucT);
								  ucT ++;
						lab2:	ul100=mod_100(&ulTmp);
								  chucun_ch(ul100,ucT);
								  ucT ++;
						lab3:	ul10=mod_10(&ulTmp);
								  chucun_ch(ul10,ucT);
								  ucT ++;
						lab4:	chucun_ch(ulTmp,ucT);
						      return;
		  		}
		 if ( ulTmp >= 100 )

			  	goto lab2;

		  if ( ulTmp >= 10 )

			  	goto lab3;

		  if ( ulTmp >= 0 )

		  		goto lab4;

		}
}

//接线错误函数
void showjiexian()
{
	uchar * cc;
	cc = chucuo;
	SelectScreen(1);

	showhz(3,32,cc);
	cc = cc + 32;
	showhz(3,48,cc);
	cc = cc + 32;
	SelectScreen(2);

	showhz(3,0,cc);
	cc = cc + 32;
	showhz(3,16,cc);


}


void fudianfenli(float fftmp)
{
	bit fg;         /*判断转换数字是整数部分还是小数部分*/
	div_zhengshu_xiaoshu(fftmp);
	fg = 1;
	number_char(iZHENGSHU,fg );
	if ( iZHENGSHU < 1000 )
		{
			iXIAOSHU = iXIAOSHU / 100;
      uczTable[3] = iXIAOSHU;
		}
}

//电流电阻显示函数
void showTable(uchar lin , uchar cole )
{
	uchar i=0, j=0,uctm=0;
	uchar  *sz;
  sz = shuzi;
  uctm = cole ;
	SelectScreen(1);
	if ( iZHENGSHU < 1000 )
		{
			for ( i = 0; i < 2; i++ )
			   {
			   	  for ( j = 0; j <= 9; j++)
			   	    if ( uczTable[i] == j )
			   	    	{
                  sz = sz + 16 * ( j + 2 );
			   	    		ShowChar(lin,uctm,sz);
			   	    		uctm = uctm +8;
                  sz = shuzi;
			   	    	}
			   }
			 SelectScreen(2);
			 uctm = 0;
			 if (iZHENGSHU >= 100 )
			 	{
					 for ( j = 0; j <= 9; j++)
					   	    if ( uczTable[2] == j )
					   	    	{
		                  sz = sz + 16 * ( j + 2 );
					   	    		ShowChar(lin,uctm,sz);
		                  sz = shuzi;
		                  uctm = uctm +8;
		                }
         }
       sz = sz + 16 * 12;
			 ShowChar(lin,uctm,sz);
			 uctm = uctm +8;
        sz = shuzi;

			 for ( j = 0; j <= 9; j++)
			   	    if ( uczTable[3] == j )
			   	    	{
                  sz = sz + 16 * ( j + 2 );
			   	    		ShowChar(lin,uctm,sz);
                  uctm = uctm +8;
                }
		}
	else
		{
			SelectScreen(1);
			for ( i = 0; i < 2; i++)
				for ( j = 0; j <= 9; j++)
			   	    if ( uczTable[i] == j )
			   	    	{
                  sz = sz + 16 * ( j + 2 );
			   	    		ShowChar(lin,uctm,sz);
			   	    		uctm = uctm +8;
                  sz = shuzi;
			   	    	}
			 SelectScreen(2);
			 uctm = 0;
			 for ( i = 2; i < 4; i++)
				for ( j = 0; j <= 9; j++)
			   	    if ( uczTable[i] == j )
			   	    	{
                  sz = sz + 16 * ( j + 2 );
			   	    		ShowChar(lin,uctm,sz);
			   	    		uctm = uctm +8;
                  sz = shuzi;
			   	    	}

		}


}

void showdianliu(uchar uctmp)
{
	uchar i=0, j=0, uctm=48, *sz;
 	float fTmp = 0.0;
	if ( selc == 0 )
		fTmp = 100.0;
	else
		fTmp = 200.0;
   if ( fTmp < 1.0 )
   	{
   	  showjiexian();
   	  while (1);
   	}
  fudianfenli(fTmp);
	SelectScreen(1);
	sz = shuzi;
	sz = sz + 272;
	ShowChar(3,32,sz);
	sz = shuzi;
	sz = sz + 16;
	ShowChar(3,40,sz);
	sz = shuzi;
	showTable(3,uctm);
	SelectScreen(2); //  显示 " A "
	sz = xiaoxiea;
  if ( iZHENGSHU < 1000 )
    uctm =  24;
   else
   	uctm = 16;
  ShowChar(3,uctm,sz);

}


void test(uchar *star)      //测试过程  显示  “正在测试中”
{
     unsigned char   coltmp , i ,*starttmp;
       if (!bfdayin)                 //判断为第一次调用
       	  {
           ClearScreen(1);
           ClearScreen(2);
           kstr = 1 ;   //启动恒流源
           bfdayin = ~bfdayin;
          }

           starttmp = star;
           SelectScreen( 1 );
	   coltmp = 0;

	   for ( i =0; i < 4; i++)
	    {
		showhz(0,coltmp,starttmp);
		coltmp = coltmp + 16;
		starttmp = starttmp + 32;

	     }
	   SelectScreen( 2 );
	   coltmp = 0;
	   for ( i =0; i < 2; i++)
	    {
				showhz(0,coltmp,starttmp);
				coltmp = coltmp + 16;
				starttmp = starttmp + 32;
			}

}
void senddata(uchar datatmp)
{
	  while(BUSY);
		SBUF = datatmp; //发送数据
		while (!TI);
		TI=0;
}

void dayin()
{
  uchar i;
  uchar data day1[]={0x1b,0x36,0x49,0x3D,0x31,0x30,0x30,0x41,0x32,0x30,0x30,0x41};
	uchar data dayr[]={0x52,0x3D,0xA9,0xB9};
	uchar code day[]={0x1b,0x38,0x00,0x1b,0x6c,0x10,0xB2,0xE2,0xCA,0xD4,0xBD,0xE1,0xB9,0xFB};
	uchar udata[]={0,0,0,0};
	TH1  = 244;
	TL1  = 244;
	TMOD = 0x20 ;
	SCON = 0xd0;
  TR1= 1;
	ES = 1;
	TI = 0;

 for ( i = 0; i < 4; i++)
   uczTable[i] = uczTable[i] | 0x30 ;
 for ( i = 0; i < 4; i++)
	senddata(day1[i]); //发送数据
 if ( !selc)
		{
			for ( i = 4; i < 8; i++)
				senddata(day1[i]);
    }
		else
		{
			for ( i = 8; i < 12; i++)
				senddata(day1[i]);
		}
  senddata(0x0D);
  senddata(0x1b);
  senddata(0x4A);
  senddata(6);
for ( i = 0; i < 2; i++)
	senddata(dayr[i]); //发送数据
for ( i = 0; i < 3; i++)
	senddata(uczTable[i]);
  senddata(0x2E);      //.
  senddata(uczTable[3]);
for ( i = 2; i < 4; i++)
	senddata(dayr[i]); //发送数据
  senddata(0x0D);
  senddata(0x1b);
  senddata(0x4A);
  senddata(6);
  senddata(0x1b);
  senddata(0x20);
  senddata(2);
for ( i = 0; i < 16; i++)
  senddata(day[i]);  //发送数据
	senddata(0x0D);
	senddata(0x1b); //设定空走纸行
  senddata(0x66);
  senddata(1);
  senddata(3);

senddata(0x00);
}

void kszkey()   //测试设置键 函数
{
  uchar i =0 , ucflag=1  ;

	ksz = 1;
	ktest = 1;
	if (!bfdayin)
			{
				while (1)
				{
					 while (!ksz)
					 	{
					 		Lcd12864delay(1);      //延时去抖动
					      if ( ksz == 1 )      //判断键是否释放
					    		{
					    			if ( ucflag == 1)
					    				{
								    		lcderbai();
								    		ucflag=0;
								    		selc = 1;

								    	}
								    else
								    	{
								    		lcdyibai();
								    		ucflag=1;
								    		selc = 0;

								    	}
					    		}

					   }
					 if ( !ktest)
					 	{
					 		Lcd12864delay(1);
					    if ( ktest == 1 )
					    		//启动测试程序
					    		{
			               test(start);

			               adDushu(&ucItmp, 0);

			               // 显示测试的 电流数据
			    					 showdianliu(ucItmp);
						    	  return;
					    	 	}
					  }
				}
			}
  if (bfdayin)
  	{
            while ( 1 )
              {
  		while (!ksz)
					 	{
					 		Lcd12864delay(1);      //延时去抖动
					      if ( ksz == 1 )      //判断键是否释放
					    		{
					    			dayin();
  									bfdayin = ~ bfdayin;
  									return;
					    		}

  	                                       }
                }
         }
}

// 测试电压,选择合适的电压量程
void ceshidianya()
{
	  uchar ucp20 = 0x01 ,ucutmp=0 ;

			    adinit(1);
			zl:	adDushu(&ucutmp,1);
				if ( (ucutmp > 0xCC ) && ( ucp20 == 0x01 ) )
					{
					   showjiexian();
					   while(1);
					 }
				else if ( ucutmp < 0xCC )
									{
										ucp20 = ucp20 << 1;
										P2 = P2 & 0xf0 ;
										P2 = P2 | ucp20;
								    delay1ms(900);
									  goto zl;
								  }
								  ucp20 = ucp20 >> 1;
								  P2 = P2 & 0xf0 ;
									P2 = P2 | ucp20;
				if ( ucp20 == 1 )  VX = 11.0;
				if ( ucp20 == 2 )  VX = 33.638;
				if ( ucp20 == 4 )  VX = 124.74;
				if ( ucp20 == 8 )  VX = 401.81;
}

void showdianzu(float fRxt)
{
	uchar *sz , uctm=48;
	fRxt = fRxt * 1000*1000;
	fudianfenli(fRxt);
	SelectScreen(1);
	sz = shuzi;
	ShowChar(5,32,sz);
	sz = sz + 16;
	ShowChar(5,40,sz);
	sz = shuzi;
	showTable(5,uctm);
	SelectScreen(2);
	sz = shuzi;
  sz = sz +208;
  if ( iZHENGSHU < 1000 )
    uctm =  24;
   else
   	uctm = 16;
  showhz(5,uctm,sz);
  uctm = uctm + 16;
  sz = sz +32;
 showhz(5,uctm,sz);
}

//测试电阻
void ceshidianzu()
{

	uchar ucmp=30;
	float fRx=0.0 , K=0.0,fv=0.0, fi=0.0 ,ucceshi=0.0 , rtmp=0.0;
	K = VB*RB/VX ;
  ucceshi=30.0;
	while ( ucmp--)
	{

	  adDushu(&ucItmp,1);
		fv= (float)ucItmp;
		rtmp = fv  ;
		adDushu(&ucItmp,0);
		fi= (float)ucItmp ;
		rtmp = rtmp / fi ;
		rtmp = rtmp * K;
		fRx = fRx + rtmp;
  }
  fRx = fRx / ucceshi ;
  test(secjieguo);
	showdianzu( fRx );

}


//显示第一屏
void xiandiyip()
{

	uchar *ucptmp , coltm,coltmp,i ,j,ucItotal;


	coltmp = 24;
	ucptmp = ASC;
	SelectScreen( 1 );
 	Lcd12864delay();

  for ( i = 0; i < 5; i++)
	  {

	  	ShowChar(0,coltmp,ucptmp);
	  	ucptmp = ucptmp + 16;

	  	coltmp = coltmp + 8;
	  }
	coltmp = 0;
  SelectScreen( 2 );
  for ( i = 0; i < 3; i++)
		{

	  	ShowChar(0,coltmp,ucptmp);
	  	ucptmp = ucptmp + 16;
	  	coltmp = coltmp + 8;
	  }
	  showhz(0,coltmp,ucptmp );
	  //显示 “回路测试仪”
	  ucptmp = hui;
	  SelectScreen( 1 );
	  coltmp = 8;
	  for ( i = 0; i < 3; i++ )
	  {
	  	showhz(2,coltmp,ucptmp);
	  	ucptmp = ucptmp + 32;
	  	coltmp = coltmp + 16;
		}
		//显示 阻
		coltm = coltmp;
	  Show88(2,coltmp,ucptmp);
	  ucptmp = ucptmp + 8;
	  SelectScreen(2);
	  coltmp = 0;
	  Show88(2,coltmp,ucptmp);
	 ucptmp = ucptmp + 8;
	  SelectScreen(1);
	  coltmp = coltm;
	  Show88(3,coltmp,ucptmp);
	  ucptmp = ucptmp + 8;
	  SelectScreen(2);
	  coltmp = 0;
	  Show88(3,coltmp,ucptmp);


	 // 显示 “测试仪”
		ucptmp = ucptmp + 8;
	  coltmp = coltmp + 8;
	  for ( i = 0; i < 3; i++ )
	  {
	  	showhz(2,coltmp,ucptmp);
	  	ucptmp = ucptmp + 32;
	  	coltmp = coltmp + 16;
		}
		// 显示 “扬州科发电气”
		SelectScreen( 1 );
		coltmp = 16;
		ucptmp = yang;
		for ( i = 0; i < 3; i++ )
	  {
	  	showhz(5,coltmp,ucptmp);
	  	ucptmp = ucptmp + 32;
	  	coltmp = coltmp + 16;
		}
		SelectScreen( 2 );
		coltmp = 0;
		for ( i = 0; i < 3; i++ )
	  {
	  	showhz(5,coltmp,ucptmp);
	  	ucptmp = ucptmp + 32;
	  	coltmp = coltmp + 16;
		}
}

// 显示第二屏
void xiandierp()
{
	uchar *ucptmp , coltm,coltmp , i;
	//显示 “请设置测试电流:”
	ClearScreen(1);
	ClearScreen(2);
	SelectScreen( 1 );
	ucptmp = dier;
	coltmp = 0;
	for ( i =0; i < 4; i++)
	{
		showhz(0,coltmp,ucptmp);
		coltmp = coltmp + 16;
		ucptmp = ucptmp + 32;

	}
	SelectScreen( 2 );
	coltmp = 0;
	for ( i =0; i < 4; i++)
	{
		showhz(0,coltmp,ucptmp);
		coltmp = coltmp + 16;
		ucptmp = ucptmp + 32;

	}

}
void main()
{

  uchar   *yibaitmp ,*starttmp ;


  //初始化区域
  selc = 0;
  jav0 = 1;
  jav1 = 0;
  jav2 = 0;
  jav3 = 0;
  kstr  = 0;
  adi = 1;
  ado = 0;
  adi = 0;
  adclk = 0;
  adi = 1;
  adclk = 1;

  yibaitmp = yibai;
  starttmp =start;
  adinit(0);
	InitLCD();

   xiandiyip();  //显示第一屏

	Lcd12864delay(60000);

	xiandierp();  //显示第二屏
	lcdyibai();
  kszkey();      //设置测试电流源
  delay1ms(30) ;
  ceshidianya(); //测试电压,选择合适的量程
  delay1ms(20);
  ceshidianzu();
  kszkey();       //打印测试结果
  kstr =0;

 while ( 1) ;


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -