当前位置:网站首页>Simulation of infrared wireless communication based on 51 single chip microcomputer

Simulation of infrared wireless communication based on 51 single chip microcomputer

2022-04-23 17:09:00 Xiao ~ Xiaoyan

Catalog

One 、 Project functions

Two 、 Simulation

​  3、 ... and 、 Program


Download address : be based on 51 MCU infrared wireless communication simulation

One 、 Project functions

The project is divided into master and slave , The host collects the temperature and light intensity IRLINK The infrared wireless transmitter transmits it to the slave , And in 12864 On the LCD screen .

Two 、 Simulation

temperature 83、 No brightness

temperature 65、 Have brightness

  3、 ... and 、 Program

Partial procedure

#include <REG51.h>
#include <intrins.h>
#include "hongwaifashe.h"

 void hongwaifashe(void)
{ 

  TMOD = 0x01;         //T0 16 Bit working mode 
  IR=1;				   // The transmitting port is normally at high level 

ZZ(setdata[0]);
ZZ(setdata[1]);
}


  void ZZ(uchar x)
{ 
  TT0(1,m9);		   // High level 9mS
  TT0(0,m4_5);	       // Low level 4.5mS

  /*┈  send out 4 The frame data  ┈*/
  Z0(SBM);													                               
  Z0(~SBM);
  Z0(x);
  Z0(~x);

  /*┈┈  End code  ┈┈*/
  TT0(1,m_56);
  TT0(0,m40);
}/*┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
 The functionality : Single frame sending program 
 Entrance parameters :1 The frame data 
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈*/
void Z0(uchar temp)
{ 
  uchar v;
  for (v=0;v<8;v++)                     // loop 8 Secondary shift  
       {     
	         TT0(1,m_56);		        // High level 0.65mS         
			 if(temp&0x01) TT0(0,m1_68); // Send the lowest bit 
			 else          TT0(0,m_56);     
			 temp >>= 1;                // Moves to the right one  
        }    
}

/*┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
 The functionality :38KHz Pulse emission  +  Delay program 
 Entrance parameters :( Whether to transmit pulse , Delay time  x (uS))
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈*/
void TT0(bit BT,uint x)
{
  TH0 = x>>8;	            // Input T0 Initial value 
  TL0 = x;
  TF0=0;			        // clear 0
  TR0=1;			        // Start timer 0
  if(BT == 0) while(!TF0);	//BT=0 When not fired 38KHz The pulse only delays ;BT=1 launch 38KHz Pulse and delay ;
  else while(1)			    //38KHz pulse , Duty cycle 5:26
         {
		  IR = 0;
		  if(TF0)break;
 	      if(TF0)break;
		  IR = 1;
  	      if(TF0)break;
   	      if(TF0)break;
   	      if(TF0)break;
		  if(TF0)break;
   	      if(TF0)break;
   	      if(TF0)break;
   	      if(TF0)break;
   	      if(TF0)break;
   	      if(TF0)break;
		  if(TF0)break;
		 }
  TR0=0;			        // off timer 0
  TF0=0;			        // Clear if the flag bit overflows 0

  IR =1;			        // After the pulse stops , The transmitting port is normally at high level 
}





版权声明
本文为[Xiao ~ Xiaoyan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231707173345.html