Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

IR transmitting and Receiving Using pic12f675

Status
Not open for further replies.

nick703

Advanced Member level 1
Joined
Oct 17, 2011
Messages
422
Helped
21
Reputation
44
Reaction score
22
Trophy points
1,298
Location
surat
Activity points
3,987
hello friends ,

i have read this thread to operate relay using Remote .
file:///H:/Proteus%20Project/NEC%20IR%20REMOTE%20ALL/NEC%20IR%20REMOTE%20receiver/Microcontroller%20Projects%20%20IR%28infrared%29%20Remote%20Control%20Relay%20Board%20with%20PIC%2012F675%20Microcontroller.htm

Transmitter code is
Code:
// Global includes
#include <htc.h>

__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF & CPD_OFF);
/*
 * 
 */
#define LED 	GPIObits.GPIO5		// IR port status indicator LED defination
#define RELAY1 	GPIObits.GPIO0		// RELAYS PORT definations 	
#define RELAY2 	GPIObits.GPIO1
#define RELAY3 	GPIObits.GPIO2
#define RELAY4 	GPIObits.GPIO4

#define IRSENSOR GPIObits.GPIO3		// IR PORT defination 



//#define TICKSPERMS  1004      // tick in a milli second 
#define TICKS11ms 	11044      	// ticks in 11ms
#define TICKS5o5ms 	5522 		// ticks in 5.5ms
#define TICKS2o3ms 	2309 		// ticks in 2.3ms
#define TICKS3ms  	3012		// ticks in 3sm
#define TICKS0o2ms	200			// ticks in 0.2ms
#define TICKS8ms 	8032		// Tick

unsigned int TIMEOUT  =   TICKS11ms;       	// the pulse should occur before this time excede Otherwise it is an error 
unsigned int PREPULSE = TICKS8ms;			// the interrupt should occur after this time Otherwise it is an error


static unsigned short long timer;			// varible to keep track of long timeouts  ( it can also be int if you want to save flash memory for some other purpose  ) 
static unsigned char dataready;				// varible to use as flag when data is completly received and  ready it is 1 else 0 

static  unsigned char necpoj=0; 	 				/* (necpoj=NEC position )this varible is used to keep track of the edges of the input singal 
											as decoding of the singal is done by a state machine 
											so this varible acutalley sotores what state we currently are 
							 				and total bits 32 and 2 leading pulse */

 
static unsigned char address=0,notaddress=0;	// these varible are used to store received address
static unsigned char command=0,notcommand=0;	// these varible are used to store received address

void interruptOnChangeIsr(void);  				// interrupt service routine for interrupt on change of input port for IR sensor of mcu 
void timerInterruptIsr(void);					// interrupt service rouine for timer0 


void interrupt t0intr(void)
{
	if(INTCONbits.T0IF)							// check the timer0 over flow interrupt flag 
	{
	timerInterruptIsr();						// timer0 overflow interrupt has been occur call the isr
	INTCONbits.T0IF =0;							// clear the timer0 interrupt flag
	}
	else if (INTCONbits.GPIF)					// check the interrupt on change flag
	{	
		LED=1;									// to blink the LED when IR signal is received 
		interruptOnChangeIsr();					// interrupt on change has been detected call the isr	
		INTCONbits.GPIF =0;						// clear the interrupt on chage flag
		LED=0;									// to blink the LED when IR signal is received 
	}

}

/* THE main source code Start here*/


void main() 
{
	
    CMCON=0x7;				// disable the comparator 
    ANSEL=0x00;				// all pin are Digital
    TRISIO=0x8;   			// Only GP2 is set to input rest are out
	TMR0 = 0;				// clar the timer	
	OPTION_REG = 0x88;		//pullups are disabled	
							//timer0 clock source is internal
							//timer0 perscaller is 1:1 (disabled "assigned to WDT")
	IOC = 0x8;   			//interrupt on change is only to the GPIO3
	INTCONbits.T0IE = 1;	// Timer0 overflow interrupt enable
	INTCONbits.T0IF = 0;    // clar the timer0 intrrupt flags
	INTCONbits.GPIE = 1;	// external interrupt on GPIO3 pin(4) is enabled
	INTCONbits.GPIF = 0;	// clear the external interrrupt flag
	INTCONbits.PEIE = 1;    // peripheral intrrupt enable
	INTCONbits.GIE = 1;     // GLOBL interrupt enable

	
  
	EEADR = 0x00;			// load the state of port from EEPROM 
	EECON1bits.RD = 1;		// Start reding EEPORM
	GPIO = EEDATA; 			// LOAD The readed data form EEPORM to GPIO

	while(1)      			// wait forever for  the data received and ready  
	{
			
	if(dataready)			// data is received and ready to be procssed 
	{
		

		// key1  0x50	to	Toggle relay 1	// these are command of the IR remote control which i have 
		// key2  0xD8	to	Toggle relay 2
		// key3  0xF8	to	Toggle relay 3
		// key4  0x30	to	Toggle relay 4
		// key5  0xB0	to	Turn off all the relays
		
		switch(command)	// swich on 
		{
		case 0x50: RELAY1 = !RELAY1;		//Toggle relay 1	
				   break;
		case 0xD8: RELAY2 = !RELAY2;		//Toggle relay 2
				   break;
		case 0xF8: RELAY3 = !RELAY3;		//Toggle relay 3
				   break;
		case 0x30: RELAY4 = !RELAY4;		//Toggle relay 4
				   break;
		case 0xB0: RELAY1 = 0;				//Turn off all the relay
				   RELAY2 = 0;
				   RELAY3 = 0;
				   RELAY4 = 0;
				   break;
		default : 	
					break;			
		}

		EEADR = 0x00; 			//Write PORT status to EEPROM
		EEDATA = GPIO;			// load the current status of GPIO to EEPROM write register
		EECON1bits.WREN = 1;  	// Enable EEPROM write
		INTCONbits.GIE = 0;		//1	disable the interrupts as it may currupt the EEPROM data
		EECON2 = 0x55;			//2
		EECON2 = 0xAA;			//3	(1,2,3) require sequence 
		EECON1bits.WR = 1;  	// satart writing
		INTCONbits.GIE = 1;  	// Enable the interrupts 
	
		dataready=0;			// data has been processed so clear the dataready flag 
		
	}
	
	}
	
}

void interruptOnChangeIsr(void)
{

unsigned short long tdiff;       
unsigned char pin;
static unsigned long rxbuffer;


tdiff = ((timer<<8)+TMR0) ;     // calculate how much time has been passed since last interrupt 
								// the time shold be less then time out and greater than PREPULSE 
pin = IRSENSOR;					// store the current status of Sensor 
TMR0 = 0;						// reset the timer0 to measure the next edge(interrupt) of input
timer = 0;						// reset the timer varible to




/* state machine is started here and it totally managed and keeps track of its states using the varible necpoj 
here are the details of necpoj ( NEC position ) varible 
if 
necpoj == 1       we just detected the first edge of the input singal it may also mean(if interrupt is not false) that the 9ms leading pulse started 
				  after the first edge THE next pulse is expected to arrive around 9ms so the TIMEOUT is set to 11ms and PREPULSE is set to 8ms
				

necpoj == 2 	  we just detected the second edge of the input signal and we finished the 9ms leding pulse and now 4.5ms space started 
				  after the second edge the next pulse is expected to arrive around 4.5ms so TIMEOUT is set to 5.5ms and PREPULSE is 3ms
		

necpoj == 3  	  we just detected the third edge of the input singal and we finished 4.5ms space and addres lsb is now started 
				  after the third edge the next pulse is expected to arrive around 562.5us so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms (timeout can be much less at this state but to do this i have to add one more if else statemetnt)
		
necpoj == 4 	  we just decected the forth edge and the 562.5 us burt of LSB of address has ended now a little space for '0'562.5us  or for '1' 1.6875ms   
				  after the forth edge the next pulse is expected to arrive for '0' around 562.5us  and for '1' 1.675ms so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms
		
necpoj ==5 to 66  data pulse keep comming  
					TIMOUT and PREPLUSE remain same as above.		   
			
necpoj ==67		  we just fined the command inverse MSB space not the final 562.5us burst has stated  so we fined the receiveing 
				  now we will check the address and command for being correct
*/


if ((tdiff>PREPULSE) && (tdiff<TIMEOUT) )		// the edge (interrupt) occurrence time should be less then the TIMOUT and greater then PREPULESE else it is an fake singal
{												// At the very first edge (necpoj==0)  this conditon will always false and the false block of this if will bring the state machine (necpoj) to position 1(position 1 means 9ms leading pulse has started now we have to wait for 4.5ms start pulse to occur) 
						


				
	if(necpoj==1 || necpoj==2)					// when we are hear it means 9ms leding pulse has ended and now we are necpoj=1 or necpoj=2
	{

			if((pin==1) && (necpoj==1))
			{
			necpoj++;
			TIMEOUT 	= TICKS5o5ms;  			// timeout for 3rd pulse 5.5ms	
			PREPULSE   	= TICKS3ms;				// PREPULSE for 3rd pulse 3ms
			}
			else if((pin==0)&& (necpoj ==2))
			{
			necpoj++;
		
			TIMEOUT 	= TICKS2o3ms;  			// now data starts so timeout is 2.3ms
			PREPULSE   	= TICKS0o2ms;  
	
			}
			else								// this block handle the conditon if any error occur after the completing the pre pulses 
			{
			necpoj = 0;							//reset the state machine 
			TIMEOUT 	=  	TICKS11ms;
			PREPULSE 	= 	TICKS8ms;
			}
	}
	else if(necpoj>2)							//now we are picking the data 	
	{	
				
			necpoj++;					 		//necpoj sill inrement on every edge 	

				if(necpoj&0x01)					// here we check the if necpoj is an odd number because when necpoj goes greater then 3 then 
									    		//necpoj will always be and odd value when a single bit tranmission is over  
				{
					rxbuffer=rxbuffer<<1;		//shift the buffer 
					if(tdiff>1250)				//we are here means we just recevied the edge of finished tranmission of a bit 
												// so if last edge was more than 1.24 ms then the bit which is just over is one else it is zero 
					{
					rxbuffer = rxbuffer | 0x1;
				//	GPIObits.GPIO5 = !GPIObits.GPIO5;    
					}
					else
					{
					rxbuffer = rxbuffer |0x0;
			    //	GPIObits.GPIO4 = !GPIObits.GPIO4;
					}
			
				}
		
			if(necpoj >66)						// we have reached (Leading pulse 2 +address 16+~address16+ command 16+ ~command 16+ last final burst first edge 1)=67th edge of the message frame means the date tranmission is now over 
			{
				
			address 	= (rxbuffer>>24)& 0xFF;			//extract the data from the buffer 
			notaddress 	= (rxbuffer>>16)& 0xFF;
			command 	= (rxbuffer>>8)	& 0xFF;
			notcommand 	= (rxbuffer)	& 0xFF;
			rxbuffer=0;									//clear the buffer	
				
					if((!(address & notaddress)) && (!(command & notcommand)))		// check weather the received data is vaild or not
					{
					dataready =1;
					}
					else
					{
					dataready=0;
					}
			TIMEOUT 	=  	TICKS11ms;					// weather we received the vaild data or not we have to reset the state machine 
			PREPULSE 	= 	TICKS8ms;
			necpoj=0;
			}

	}
	else 
	{	
	
	TIMEOUT 	=	TICKS11ms;							// some error occured reset state machine 
	PREPULSE 	=	TICKS8ms;
	}
	
	


}
else
{
	
	if(pin==0)				//we are here means that after a longtimeout or PREPULSE we just detect a pulse which may be the start of 9ms pulse 
	{
	necpoj = 1;				// yes it could be the start of 9ms pulse 
	}
	else 
	{	
	necpoj = 0;				// no it's not start of 9ms pulse 
	}
	
	address 	= 0xFF;
	notaddress 	= 0xFF;
	command 	= 0xFF;
	notcommand 	= 0xFF;
	dataready 	= 0x000;
	TIMEOUT =  TICKS11ms;		//default timing  
	PREPULSE = TICKS8ms;
}
	
}

void timerInterruptIsr(void)
{
if(timer<0xFFFF)			// this code is to increment the variable timer's value on every over flow but this if conditon will prevent this variable form rollover when a long timeout occurs
timer++;
}

and Receiver code is
Code:
// Global includes
#include <htc.h>

__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF & CPD_OFF);
/*
 * 
 */
#define LED 	GPIObits.GPIO5		// IR port status indicator LED defination
#define RELAY1 	GPIObits.GPIO0		// RELAYS PORT definations 	
#define RELAY2 	GPIObits.GPIO1
#define RELAY3 	GPIObits.GPIO2
#define RELAY4 	GPIObits.GPIO4

#define IRSENSOR GPIObits.GPIO3		// IR PORT defination 



//#define TICKSPERMS  1004      // tick in a milli second 
#define TICKS11ms 	11044      	// ticks in 11ms
#define TICKS5o5ms 	5522 		// ticks in 5.5ms
#define TICKS2o3ms 	2309 		// ticks in 2.3ms
#define TICKS3ms  	3012		// ticks in 3sm
#define TICKS0o2ms	200			// ticks in 0.2ms
#define TICKS8ms 	8032		// Tick

unsigned int TIMEOUT  =   TICKS11ms;       	// the pulse should occur before this time excede Otherwise it is an error 
unsigned int PREPULSE = TICKS8ms;			// the interrupt should occur after this time Otherwise it is an error


static unsigned short long timer;			// varible to keep track of long timeouts  ( it can also be int if you want to save flash memory for some other purpose  ) 
static unsigned char dataready;				// varible to use as flag when data is completly received and  ready it is 1 else 0 

static  unsigned char necpoj=0; 	 				/* (necpoj=NEC position )this varible is used to keep track of the edges of the input singal 
											as decoding of the singal is done by a state machine 
											so this varible acutalley sotores what state we currently are 
							 				and total bits 32 and 2 leading pulse */

 
static unsigned char address=0,notaddress=0;	// these varible are used to store received address
static unsigned char command=0,notcommand=0;	// these varible are used to store received address

void interruptOnChangeIsr(void);  				// interrupt service routine for interrupt on change of input port for IR sensor of mcu 
void timerInterruptIsr(void);					// interrupt service rouine for timer0 


void interrupt t0intr(void)
{
	if(INTCONbits.T0IF)							// check the timer0 over flow interrupt flag 
	{
	timerInterruptIsr();						// timer0 overflow interrupt has been occur call the isr
	INTCONbits.T0IF =0;							// clear the timer0 interrupt flag
	}
	else if (INTCONbits.GPIF)					// check the interrupt on change flag
	{	
		LED=1;									// to blink the LED when IR signal is received 
		interruptOnChangeIsr();					// interrupt on change has been detected call the isr	
		INTCONbits.GPIF =0;						// clear the interrupt on chage flag
		LED=0;									// to blink the LED when IR signal is received 
	}

}

/* THE main source code Start here*/


void main() 
{
	
    CMCON=0x7;				// disable the comparator 
    ANSEL=0x00;				// all pin are Digital
    TRISIO=0x8;   			// Only GP2 is set to input rest are out
	TMR0 = 0;				// clar the timer	
	OPTION_REG = 0x88;		//pullups are disabled	
							//timer0 clock source is internal
							//timer0 perscaller is 1:1 (disabled "assigned to WDT")
	IOC = 0x8;   			//interrupt on change is only to the GPIO3
	INTCONbits.T0IE = 1;	// Timer0 overflow interrupt enable
	INTCONbits.T0IF = 0;    // clar the timer0 intrrupt flags
	INTCONbits.GPIE = 1;	// external interrupt on GPIO3 pin(4) is enabled
	INTCONbits.GPIF = 0;	// clear the external interrrupt flag
	INTCONbits.PEIE = 1;    // peripheral intrrupt enable
	INTCONbits.GIE = 1;     // GLOBL interrupt enable

	
  
	EEADR = 0x00;			// load the state of port from EEPROM 
	EECON1bits.RD = 1;		// Start reding EEPORM
	GPIO = EEDATA; 			// LOAD The readed data form EEPORM to GPIO

	while(1)      			// wait forever for  the data received and ready  
	{
			
	if(dataready)			// data is received and ready to be procssed 
	{
		

		// key1  0x50	to	Toggle relay 1	// these are command of the IR remote control which i have 
		// key2  0xD8	to	Toggle relay 2
		// key3  0xF8	to	Toggle relay 3
		// key4  0x30	to	Toggle relay 4
		// key5  0xB0	to	Turn off all the relays
		
		switch(command)	// swich on 
		{
		case 0x50: RELAY1 = !RELAY1;		//Toggle relay 1	
				   break;
		case 0xD8: RELAY2 = !RELAY2;		//Toggle relay 2
				   break;
		case 0xF8: RELAY3 = !RELAY3;		//Toggle relay 3
				   break;
		case 0x30: RELAY4 = !RELAY4;		//Toggle relay 4
				   break;
		case 0xB0: RELAY1 = 0;				//Turn off all the relay
				   RELAY2 = 0;
				   RELAY3 = 0;
				   RELAY4 = 0;
				   break;
		default : 	
					break;			
		}

		EEADR = 0x00; 			//Write PORT status to EEPROM
		EEDATA = GPIO;			// load the current status of GPIO to EEPROM write register
		EECON1bits.WREN = 1;  	// Enable EEPROM write
		INTCONbits.GIE = 0;		//1	disable the interrupts as it may currupt the EEPROM data
		EECON2 = 0x55;			//2
		EECON2 = 0xAA;			//3	(1,2,3) require sequence 
		EECON1bits.WR = 1;  	// satart writing
		INTCONbits.GIE = 1;  	// Enable the interrupts 
	
		dataready=0;			// data has been processed so clear the dataready flag 
		
	}
	
	}
	
}

void interruptOnChangeIsr(void)
{

unsigned short long tdiff;       
unsigned char pin;
static unsigned long rxbuffer;


tdiff = ((timer<<8)+TMR0) ;     // calculate how much time has been passed since last interrupt 
								// the time shold be less then time out and greater than PREPULSE 
pin = IRSENSOR;					// store the current status of Sensor 
TMR0 = 0;						// reset the timer0 to measure the next edge(interrupt) of input
timer = 0;						// reset the timer varible to




/* state machine is started here and it totally managed and keeps track of its states using the varible necpoj 
here are the details of necpoj ( NEC position ) varible 
if 
necpoj == 1       we just detected the first edge of the input singal it may also mean(if interrupt is not false) that the 9ms leading pulse started 
				  after the first edge THE next pulse is expected to arrive around 9ms so the TIMEOUT is set to 11ms and PREPULSE is set to 8ms
				

necpoj == 2 	  we just detected the second edge of the input signal and we finished the 9ms leding pulse and now 4.5ms space started 
				  after the second edge the next pulse is expected to arrive around 4.5ms so TIMEOUT is set to 5.5ms and PREPULSE is 3ms
		

necpoj == 3  	  we just detected the third edge of the input singal and we finished 4.5ms space and addres lsb is now started 
				  after the third edge the next pulse is expected to arrive around 562.5us so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms (timeout can be much less at this state but to do this i have to add one more if else statemetnt)
		
necpoj == 4 	  we just decected the forth edge and the 562.5 us burt of LSB of address has ended now a little space for '0'562.5us  or for '1' 1.6875ms   
				  after the forth edge the next pulse is expected to arrive for '0' around 562.5us  and for '1' 1.675ms so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms
		
necpoj ==5 to 66  data pulse keep comming  
					TIMOUT and PREPLUSE remain same as above.		   
			
necpoj ==67		  we just fined the command inverse MSB space not the final 562.5us burst has stated  so we fined the receiveing 
				  now we will check the address and command for being correct
*/


if ((tdiff>PREPULSE) && (tdiff<TIMEOUT) )		// the edge (interrupt) occurrence time should be less then the TIMOUT and greater then PREPULESE else it is an fake singal
{												// At the very first edge (necpoj==0)  this conditon will always false and the false block of this if will bring the state machine (necpoj) to position 1(position 1 means 9ms leading pulse has started now we have to wait for 4.5ms start pulse to occur) 
						


				
	if(necpoj==1 || necpoj==2)					// when we are hear it means 9ms leding pulse has ended and now we are necpoj=1 or necpoj=2
	{

			if((pin==1) && (necpoj==1))
			{
			necpoj++;
			TIMEOUT 	= TICKS5o5ms;  			// timeout for 3rd pulse 5.5ms	
			PREPULSE   	= TICKS3ms;				// PREPULSE for 3rd pulse 3ms
			}
			else if((pin==0)&& (necpoj ==2))
			{
			necpoj++;
		
			TIMEOUT 	= TICKS2o3ms;  			// now data starts so timeout is 2.3ms
			PREPULSE   	= TICKS0o2ms;  
	
			}
			else								// this block handle the conditon if any error occur after the completing the pre pulses 
			{
			necpoj = 0;							//reset the state machine 
			TIMEOUT 	=  	TICKS11ms;
			PREPULSE 	= 	TICKS8ms;
			}
	}
	else if(necpoj>2)							//now we are picking the data 	
	{	
				
			necpoj++;					 		//necpoj sill inrement on every edge 	

				if(necpoj&0x01)					// here we check the if necpoj is an odd number because when necpoj goes greater then 3 then 
									    		//necpoj will always be and odd value when a single bit tranmission is over  
				{
					rxbuffer=rxbuffer<<1;		//shift the buffer 
					if(tdiff>1250)				//we are here means we just recevied the edge of finished tranmission of a bit 
												// so if last edge was more than 1.24 ms then the bit which is just over is one else it is zero 
					{
					rxbuffer = rxbuffer | 0x1;
				//	GPIObits.GPIO5 = !GPIObits.GPIO5;    
					}
					else
					{
					rxbuffer = rxbuffer |0x0;
			    //	GPIObits.GPIO4 = !GPIObits.GPIO4;
					}
			
				}
		
			if(necpoj >66)						// we have reached (Leading pulse 2 +address 16+~address16+ command 16+ ~command 16+ last final burst first edge 1)=67th edge of the message frame means the date tranmission is now over 
			{
				
			address 	= (rxbuffer>>24)& 0xFF;			//extract the data from the buffer 
			notaddress 	= (rxbuffer>>16)& 0xFF;
			command 	= (rxbuffer>>8)	& 0xFF;
			notcommand 	= (rxbuffer)	& 0xFF;
			rxbuffer=0;									//clear the buffer	
				
					if((!(address & notaddress)) && (!(command & notcommand)))		// check weather the received data is vaild or not
					{
					dataready =1;
					}
					else
					{
					dataready=0;
					}
			TIMEOUT 	=  	TICKS11ms;					// weather we received the vaild data or not we have to reset the state machine 
			PREPULSE 	= 	TICKS8ms;
			necpoj=0;
			}

	}
	else 
	{	
	
	TIMEOUT 	=	TICKS11ms;							// some error occured reset state machine 
	PREPULSE 	=	TICKS8ms;
	}
	
	


}
else
{
	
	if(pin==0)				//we are here means that after a longtimeout or PREPULSE we just detect a pulse which may be the start of 9ms pulse 
	{
	necpoj = 1;				// yes it could be the start of 9ms pulse 
	}
	else 
	{	
	necpoj = 0;				// no it's not start of 9ms pulse 
	}
	
	address 	= 0xFF;
	notaddress 	= 0xFF;
	command 	= 0xFF;
	notcommand 	= 0xFF;
	dataready 	= 0x000;
	TIMEOUT =  TICKS11ms;		//default timing  
	PREPULSE = TICKS8ms;
}
	
}

void timerInterruptIsr(void)
{
if(timer<0xFFFF)			// this code is to increment the variable timer's value on every over flow but this if conditon will prevent this variable form rollover when a long timeout occurs
timer++;
}

and my proteus file is
View attachment SIMULATION.rar

but simulation not work please help me!!!!

- - - Updated - - -

ok sorry for some change on my circuit design please have look below simulation file . but relay is not trigger ?
 

Attachments

  • test.rar
    34.6 KB · Views: 149

In case someone is motivated to check the simulation design, he'll need the hex files. Or even better the *.cof files together with the sources to perform source level debugging in Proteus.

To take advantage from the simulator, you should think about a systematic test strategy. You already connected an oscilloscope at RX and TX of the IRLINK component, what do you think about the observed signals? Are they as expectable? Is it more likely a transmitter or receiver problem?
 

test1.JPGok now below is the simulation file and remote and receiver hex file
 

Attachments

  • receiver hex.rar
    1 KB · Views: 137
  • remote hex.rar
    757 bytes · Views: 143

The TX signal looks inplausible (14kHz rather than 40 kHz), the IRLINK behavioral model is apparently just a one shot, so it produces a pulse train instead of a receive pulse per burst.

You didn't post the transmitter code, we can't see where it's wrong.
 

hey fvm
i post my transmitter and receiver code in post #1 .
actually i completely transmit and receiving i see in proteus oscilloscope but my relay is not turned on . please help me any thing is wrong in my code?

And by the way my
Transmitting code is 12f615
receiving code is 12f675

- - - Updated - - -

here is oscilloscope view what i get .

Oscilloscope.JPGcircuit.JPG
 

i post my transmitter and receiver code in post #1
The title claims so. But you posted two identical copies of the receiver code...

here is oscilloscope view what i get .
You need to switch to a faster time base to see why the signals are wrong. (As described in my previous post).

Please come back with new facts.
 

hey sorry FVM now below is my transmitting code and receiving code.

Transmitter
Code:
#include <htc.h>

__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF & IOSCFS_8MHZ & BOREN_NSLEEP);

#define _XTAL_FREQ 8000000			// required for delay Routines. 
/*
 * 
 */

#define IR_LED 	GPIObits.GPIO2		//IR LED is conntected to this port
	
#define KEY_1	GPIObits.GPIO0		//Switces pin definition 
#define KEY_2	GPIObits.GPIO1
#define KEY_3	GPIObits.GPIO3
#define KEY_4	GPIObits.GPIO4
#define KEY_5	GPIObits.GPIO5

#define ADDRESS 0x01				//NEC protocol address for the Data Frame (MSB first)
									//if you are planning to use this with http://www.circuitvalley.com/2012/09/infrared-ir-nec-microcontroller-pic-avr.html IR realy borad then this field can be any thing because the Receiver does't look for this. 
									//if you are planning to use the remote with some other target then please put the address here is MSB first order
									//you can have different address for different keys. please modify the GPIO interrrupt on change routine. 

#define DATA_KEY_1	0xF8			//Data For KEY_1 (MSB first)
#define DATA_KEY_2	0x50			//Data For KEY_2 (MSB first)
#define DATA_KEY_3	0xD8			//Data For KEY_3 (MSB first)
#define DATA_KEY_4	0xB0			//Data For KEY_4 (MSB first)
#define DATA_KEY_5	0x30			//Data For KEY_5 (MSB first)

void sendFrame(unsigned char , unsigned char );		//sendFrame(address,data) sends the whole IR frame
void sendByte(unsigned char );						//sendByte(byte) this function is used by the sendFrame to send 4 indivisual btyes
													//SHOULD NOT BE CALL FROM ANY WERE ELSE except the sendFrame Function.
void sendRepeate();									//Sends the Repeate Code after Message Frame.				

void interrupt swInt(void)		
{	
   
	 if (INTCONbits.GPIF)					// check the interrupt on change flag
	{	
		__delay_ms(2);						//check for key debounce			
	
		if(!KEY_1)							//check if the Key_1 is pressed (gpio is low)
		{
			sendFrame(ADDRESS,DATA_KEY_1);	//send the frame
	 		while(!KEY_1)					//if the key is still pressed 
			{
			sendRepeate();					//send Repeate codes. 
			}	
		}else if(!KEY_2)					//check if the Key_2 is pressed
		{
			sendFrame(ADDRESS,DATA_KEY_2);	//send the frame
			while(!KEY_2)					//if the key is still pressed 
			{
			sendRepeate();					//send Repeate codes.
			}
		}else if(!KEY_3)					//check if the Key_3 is pressed
		{
			sendFrame(ADDRESS,DATA_KEY_3);	//send the frame
			while(!KEY_3)					//if the key is still pressed 	
			{
			sendRepeate();					//send Repeate codes.
			}
		}else if(!KEY_4)					//check if the Key_4 is pressed
		{
			sendFrame(ADDRESS,DATA_KEY_4);	//send the frame
			while(!KEY_4)					//if the key is still pressed 	
			{
			sendRepeate();					//send Repeate codes.	
			}
		}else if(!KEY_5)					//check if the Key_5 is pressed
		{
			sendFrame(ADDRESS,DATA_KEY_5);	//send the frame
			while(!KEY_5)					//if the key is still pressed 
			{
			sendRepeate();					//send Repeate codes.
			}
		}
		KEY_1;								//this is requited to end the mismatch condition 
		INTCONbits.GPIF =0;					// clear the interrupt on chage flag
	}
}


void main()
{
	CMCON0bits.CMON	=0;		// disable the comparator 
    ANSEL		= 0x00;		// all pin are Digital
    TRISIO		= 0x3B; 	// Only GP2 is set to output rest are input
	OPTION_REG 	= 0x5F;		//pullups are enabled	
							//timer0 clock source is internal
							//timer0 perscaller is 1:1 (disabled "assigned to WDT")

	WPU 	= 0x3B;			//week pullups are enabled for all switches.
	GPIO 	= 0x3B;			//put hight to the latch value of each gpio
	T2CON 	= 0x04;			// prescaler 1:1 (Timer2 is required BY the ECCP module to generate 38Khz Frequency) 
							// Timer2 is on	
							// postscaller 1:1
			
	CCPR1L			= 0x1A;	//CCP module comprison resistor to set 50% duty for 38KHz signal
	PR2 			= 51;	//CCP module period register to generate 38Khz signal
	CCP1CON 		= 0x20;	//set Two LSB of PWM Duty 8MSB are in CCPR1L the module will turned on later 
	IOC 			= 0x3B; //interrupt on change is assigne to all the port pin.
	INTCONbits.GPIE = 1;	// external interrupt on GPIO3 pin(4) is enabled
	INTCONbits.GPIF = 0;	// clear the external interrrupt flag	
	INTCONbits.PEIE = 1;    // peripheral intrrupt enable
    INTCONbits.GIE 	= 1;    // GLOBL interrupt enable
	while(1)
	{
		SLEEP();			//put the MCU into Sleep mode forever , will wake-up when ever any key press is detected. 
							// the measured current consumption in this mode is ~ 29na ( much lower then the datasheet claim 50na)
	}
}

void sendFrame(unsigned char address, unsigned char command) // this routine send the whole frame including 9ms leading pulse 4.5ms space address ~address command ~command end of message bit.
{	
	TMR2 = 0x00;					//clear the TMR2 register before we start generating 38Khz Signal on the GPIO
	CCP1CONbits.CCP1M = 0xC;		//put The CCP module into PWM mode , the Duty is 50% and freqeucny is 38Khz as allredy set, 
	__delay_us(8999);				//wait for ~9ms this rountine will delay for 8.999 ms + (3*500ns) = ~9ms (500ns is the instruction execution time at 8Mhz) and next instruciton will take 3 ins cycle to execute.
	CCP1CONbits.CCP1M = 0x0;		//turn off the CCP module stop generating 38Khz singal
	__delay_us(4490);				//wait for ~4.5ms  the value 4490 is compensated with the next instrucitons execution timing , it helps to keep precise timing. as described avobe
	
	sendByte(address);				//send address byte. (sendByte functions should not be called independently, only sendFrame should call it)
	sendByte(~address);				//send address logical invert 
	sendByte(command);				//send command
	sendByte(~command);				//send command logical invert
	
									//addres and command is sent now send the end of message bit
	TMR2 = 0x00;					//clear the TMR2 register before we start generating 38Khz Signal on the GPIO
	CCP1CONbits.CCP1M = 0xC;		//Start generating 38Khz singal
	__delay_us(561);				//wait for ~562.5us again value 561 is compensated with the next instrucitons timing
	CCP1CONbits.CCP1M = 0x0;		//stop generating 38Khz singal.
	__delay_ms(40);					// wait for the Data Frame time. 
}

void sendByte(unsigned char byte)	// this function is called only by the sendFrame , to send each byte of data total 4bytes.
{
	unsigned char i;				//variable to hold the counter vlaue
	for(i=8 ;i>0;i--)				//loop to send 8 individual bits.
	{	
		TMR2 = 0x00;				//clear the TMR2 register before we start generating 38Khz Signal on the GPIO
		CCP1CONbits.CCP1M=0xC;		//Start generating 38Khz singal
		__delay_us(561);			//wait for ~562.5us again value 561 is compensated with the next instrucitons timing
		CCP1CONbits.CCP1M=0x0;		//stop generating 38Khz singal
			
		if(byte & 0x80)				// as you have already noticed , this is example we send MSB first order. 
		{							// check for MSB bit if it is 1 then delay for 1.6875ms if it is zero then delay for 562.5us
		__delay_us(1686);			//delay for ~1.6875 ms again value 1686 is compensated with the next instrucitons timing
		}
		else
		{
		__delay_us(558);			//wait for ~562.5us again value 558 is compensated with the next instrucitons timing
		}
		byte = byte <<1;			//get the next lsb into msb (shift left the byte)
	}	
}

void sendRepeate()
{
	TMR2 = 0x00;					//clear the TMR2 register before we start generating 38Khz Signal on the GPIO
	CCP1CONbits.CCP1M = 0xC;		//Start generating 38Khz singal
	__delay_us(8999);				//wait for ~9ms 	
	CCP1CONbits.CCP1M = 0x0;		//stop generating 38Khz singal
	__delay_us(2245);				//wait for 2.25ms

	TMR2 = 0x00;					//clear the TMR2 register before we start generating 38Khz Signal on the GPIO
	CCP1CONbits.CCP1M = 0xC;		//Start generating 38Khz singal
	__delay_us(556);				//wait for ~562.5us
	CCP1CONbits.CCP1M = 0x0;		//stop generating 38Khz singal	
	__delay_us(96187);				//delay for 96.187 ms before sending the next repeate code
	
}

And receiver code
Code:
// Global includes
#include <htc.h>

__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF & CPD_OFF);
/*
 * 
 */
#define LED 	GPIObits.GPIO5		// IR port status indicator LED defination
#define RELAY1 	GPIObits.GPIO0		// RELAYS PORT definations 	
#define RELAY2 	GPIObits.GPIO1
#define RELAY3 	GPIObits.GPIO2
#define RELAY4 	GPIObits.GPIO4

#define IRSENSOR GPIObits.GPIO3		// IR PORT defination 



//#define TICKSPERMS  1004      // tick in a milli second 
#define TICKS11ms 	11044      	// ticks in 11ms
#define TICKS5o5ms 	5522 		// ticks in 5.5ms
#define TICKS2o3ms 	2309 		// ticks in 2.3ms
#define TICKS3ms  	3012		// ticks in 3sm
#define TICKS0o2ms	200			// ticks in 0.2ms
#define TICKS8ms 	8032		// Tick

unsigned int TIMEOUT  =   TICKS11ms;       	// the pulse should occur before this time excede Otherwise it is an error 
unsigned int PREPULSE = TICKS8ms;			// the interrupt should occur after this time Otherwise it is an error


static unsigned short long timer;			// varible to keep track of long timeouts  ( it can also be int if you want to save flash memory for some other purpose  ) 
static unsigned char dataready;				// varible to use as flag when data is completly received and  ready it is 1 else 0 

static  unsigned char necpoj=0; 	 				/* (necpoj=NEC position )this varible is used to keep track of the edges of the input singal 
											as decoding of the singal is done by a state machine 
											so this varible acutalley sotores what state we currently are 
							 				// and total bits 32 and 2 leading pulse */

 
static unsigned char address=0,notaddress=0;	// these varible are used to store received address
static unsigned char command=0,notcommand=0;	// these varible are used to store received address

void interruptOnChangeIsr(void);  				// interrupt service routine for interrupt on change of input port for IR sensor of mcu 
void timerInterruptIsr(void);					// interrupt service rouine for timer0 


void interrupt t0intr(void)
{
	if(INTCONbits.T0IF)							// check the timer0 over flow interrupt flag 
	{
	timerInterruptIsr();						// timer0 overflow interrupt has been occur call the isr
	INTCONbits.T0IF =0;							// clear the timer0 interrupt flag
	}
	else if (INTCONbits.GPIF)					// check the interrupt on change flag
	{	
		LED=1;									// to blink the LED when IR signal is received 
		interruptOnChangeIsr();					// interrupt on change has been detected call the isr	
		INTCONbits.GPIF =0;						// clear the interrupt on chage flag
		LED=0;									// to blink the LED when IR signal is received 
	}

}

/* THE main source code Start here*/


void main() 
{
	
    CMCON=0x7;				// disable the comparator 
    ANSEL=0x00;				// all pin are Digital
    TRISIO=0x8;   			// Only GP2 is set to input rest are out
	TMR0 = 0;				// clar the timer	
	OPTION_REG = 0x88;		//pullups are disabled	
							//timer0 clock source is internal
							//timer0 perscaller is 1:1 (disabled "assigned to WDT")
	IOC = 0x8;   			//interrupt on change is only to the GPIO3
	INTCONbits.T0IE = 1;	// Timer0 overflow interrupt enable
	INTCONbits.T0IF = 0;    // clar the timer0 intrrupt flags
	INTCONbits.GPIE = 1;	// external interrupt on GPIO3 pin(4) is enabled
	INTCONbits.GPIF = 0;	// clear the external interrrupt flag
	INTCONbits.PEIE = 1;    // peripheral intrrupt enable
	INTCONbits.GIE = 1;     // GLOBL interrupt enable

	
  
	EEADR = 0x00;			// load the state of port from EEPROM 
	EECON1bits.RD = 1;		// Start reding EEPORM
	GPIO = EEDATA; 			// LOAD The readed data form EEPORM to GPIO

	while(1)      			// wait forever for  the data received and ready  
	{
			
	if(dataready)			// data is received and ready to be procssed 
	{
		

		// key1  0x50	to	Toggle relay 1	// these are command of the IR remote control which i have 
		// key2  0xD8	to	Toggle relay 2
		// key3  0xF8	to	Toggle relay 3
		// key4  0x30	to	Toggle relay 4
		// key5  0xB0	to	Turn off all the relays
		
		switch(command)	// swich on 
		{
		case 0x50: RELAY1 = !RELAY1;		//Toggle relay 1	
				   break;
		case 0xD8: RELAY2 = !RELAY2;		//Toggle relay 2
				   break;
		case 0xF8: RELAY3 = !RELAY3;		//Toggle relay 3
				   break;
		case 0x30: RELAY4 = !RELAY4;		//Toggle relay 4
				   break;
		case 0xB0: RELAY1 = 0;				//Turn off all the relay
				   RELAY2 = 0;
				   RELAY3 = 0;
				   RELAY4 = 0;
				   break;
		case 0xAF: RELAY1 = !RELAY1;		//Toggle relay 1	
				   break;
		case 0x27: RELAY2 = !RELAY2;		//Toggle relay 2
				   break;
		case 0x07: RELAY3 = !RELAY3;		//Toggle relay 3
				   break;
		case 0xCF: RELAY4 = !RELAY4;		//Toggle relay 4
				   break;
		case 0x4F: RELAY1 = 0;				//Turn off all the relay
				   RELAY2 = 0;
				   RELAY3 = 0;
				   RELAY4 = 0;
				   break;
		default : 	
					break;			
		}

		EEADR = 0x00; 			//Write PORT status to EEPROM
		EEDATA = GPIO;			// load the current status of GPIO to EEPROM write register
		EECON1bits.WREN = 1;  	// Enable EEPROM write
		INTCONbits.GIE = 0;		//1	disable the interrupts as it may currupt the EEPROM data
		EECON2 = 0x55;			//2
		EECON2 = 0xAA;			//3	(1,2,3) require sequence 
		EECON1bits.WR = 1;  	// satart writing
		INTCONbits.GIE = 1;  	// Enable the interrupts 
	
		dataready=0;			// data has been processed so clear the dataready flag 
		
	}
	
	}
	
}

void interruptOnChangeIsr(void)
{

unsigned short long tdiff;       
unsigned char pin;
static unsigned long rxbuffer;


tdiff = ((timer<<8)+TMR0) ;     // calculate how much time has been passed since last interrupt 
								// the time shold be less then time out and greater than PREPULSE 
pin = IRSENSOR;					// store the current status of Sensor 
TMR0 = 0;						// reset the timer0 to measure the next edge(interrupt) of input
timer = 0;						// reset the timer varible to




/* state machine is started here and it totally managed and keeps track of its states using the varible necpoj 
here are the details of necpoj ( NEC position ) varible 
if 
necpoj == 1       we just detected the first edge of the input singal it may also mean(if interrupt is not false) that the 9ms leading pulse started 
				  after the first edge THE next pulse is expected to arrive around 9ms so the TIMEOUT is set to 11ms and PREPULSE is set to 8ms
				

necpoj == 2 	  we just detected the second edge of the input signal and we finished the 9ms leding pulse and now 4.5ms space started 
				  after the second edge the next pulse is expected to arrive around 4.5ms so TIMEOUT is set to 5.5ms and PREPULSE is 3ms
		

necpoj == 3  	  we just detected the third edge of the input singal and we finished 4.5ms space and addres lsb is now started 
				  after the third edge the next pulse is expected to arrive around 562.5us so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms (timeout can be much less at this state but to do this i have to add one more if else statemetnt)
		
necpoj == 4 	  we just decected the forth edge and the 562.5 us burt of LSB of address has ended now a little space for '0'562.5us  or for '1' 1.6875ms   
				  after the forth edge the next pulse is expected to arrive for '0' around 562.5us  and for '1' 1.675ms so TIMEOUT is set to 2.3ms and PREPULSE is 0.2ms
		
necpoj ==5 to 66  data pulse keep comming  
					TIMOUT and PREPLUSE remain same as above.		   
			
necpoj ==67		  we just fined the command inverse MSB space not the final 562.5us burst has stated  so we fined the receiveing 
				  now we will check the address and command for being correct
*/


if ((tdiff>PREPULSE) && (tdiff<TIMEOUT) )		// the edge (interrupt) occurrence time should be less then the TIMOUT and greater then PREPULESE else it is an fake singal
{												// At the very first edge (necpoj==0)  this conditon will always false and the false block of this if will bring the state machine (necpoj) to position 1(position 1 means 9ms leading pulse has started now we have to wait for 4.5ms start pulse to occur) 
						


				
	if(necpoj==1 || necpoj==2)					// when we are hear it means 9ms leding pulse has ended and now we are necpoj=1 or necpoj=2
	{

			if((pin==1) && (necpoj==1))
			{
			necpoj++;
			TIMEOUT 	= TICKS5o5ms;  			// timeout for 3rd pulse 5.5ms	
			PREPULSE   	= TICKS3ms;				// PREPULSE for 3rd pulse 3ms
			}
			else if((pin==0)&& (necpoj ==2))
			{
			necpoj++;
		
			TIMEOUT 	= TICKS2o3ms;  			// now data starts so timeout is 2.3ms
			PREPULSE   	= TICKS0o2ms;  
	
			}
			else								// this block handle the conditon if any error occur after the completing the pre pulses 
			{
			necpoj = 0;							//reset the state machine 
			TIMEOUT 	=  	TICKS11ms;
			PREPULSE 	= 	TICKS8ms;
			}
	}
	else if(necpoj>2)							//now we are picking the data 	
	{	
				
			necpoj++;					 		//necpoj sill inrement on every edge 	

				if(necpoj&0x01)					// here we check the if necpoj is an odd number because when necpoj goes greater then 3 then 
									    		//necpoj will always be and odd value when a single bit tranmission is over  
				{
					rxbuffer=rxbuffer<<1;		//shift the buffer 
					if(tdiff>1250)				//we are here means we just recevied the edge of finished tranmission of a bit 
												// so if last edge was more than 1.24 ms then the bit which is just over is one else it is zero 
					{
					rxbuffer = rxbuffer | 0x1;
				//	GPIObits.GPIO5 = !GPIObits.GPIO5;    
					}
					else
					{
					rxbuffer = rxbuffer |0x0;
			    //	GPIObits.GPIO4 = !GPIObits.GPIO4;
					}
			
				}
		
			if(necpoj >66)						// we have reached (Leading pulse 2 +address 16+~address16+ command 16+ ~command 16+ last final burst first edge 1)=67th edge of the message frame means the date tranmission is now over 
			{
				
			address 	= (rxbuffer>>24)& 0xFF;			//extract the data from the buffer 
			notaddress 	= (rxbuffer>>16)& 0xFF;
			command 	= (rxbuffer>>8)	& 0xFF;
			notcommand 	= (rxbuffer)	& 0xFF;
			rxbuffer=0;									//clear the buffer	
				
					if((!(address & notaddress)) && (!(command & notcommand)))		// check weather the received data is vaild or not
					{
					dataready =1;
					}
					else
					{
					dataready=0;
					}
			TIMEOUT 	=  	TICKS11ms;					// weather we received the vaild data or not we have to reset the state machine 
			PREPULSE 	= 	TICKS8ms;
			necpoj=0;
			}

	}
	else 
	{	
	
	TIMEOUT 	=	TICKS11ms;							// some error occured reset state machine 
	PREPULSE 	=	TICKS8ms;
	}
	
	


}
else
{
	
	if(pin==0)				//we are here means that after a longtimeout or PREPULSE we just detect a pulse which may be the start of 9ms pulse 
	{
	necpoj = 1;				// yes it could be the start of 9ms pulse 
	}
	else 
	{	
	necpoj = 0;				// no it's not start of 9ms pulse 
	}
	
	address 	= 0xFF;
	notaddress 	= 0xFF;
	command 	= 0xFF;
	notcommand 	= 0xFF;
	dataready 	= 0x000;
	TIMEOUT =  TICKS11ms;		//default timing  
	PREPULSE = TICKS8ms;
}
	
}

void timerInterruptIsr(void)
{
if(timer<0xFFFF)			// this code is to increment the variable timer's value on every over flow but this if conditon will prevent this variable form rollover when a long timeout occurs
timer++;
}

and proteus file
 

Attachments

  • circuit.JPG
    circuit.JPG
    73.9 KB · Views: 466
  • Oscilloscope.JPG
    Oscilloscope.JPG
    126.9 KB · Views: 122
  • test.rar
    34.6 KB · Views: 114

Don't know why the PWM period is wrong, may be it's a Proteus bug.
 

Any other solution to resolve my problem ?
 

E.g. adjust the PWM period in trial until you achieve a 38 kHz 50% square wave.
 

hello FVM thanks for reply ,

but i still not get smoother result . and actually my receiver interrupt completely receive bits of 1 and 0 . but problem is didn't detect Address and Command . so how to resolve address and command of NEC decoder to operate my relay ?
 

- Did you achieve a IR send signal with frequency 38 kHz, 50% duty cycle?
- Did you tune the IRLINK paramters to get a continuous low pulse per IR burst? You need to chenge the frequency in the component properties.
 

- Did you achieve a IR send signal with frequency 38 kHz, 50% duty cycle?
YES FVM i send 38khz signal at 50% duty cycle.

- Did you tune the IRLINK paramters to get a continuous low pulse per IR burst? You need to chenge the frequency in the component properties.

and yes i have change the IRLINK parameters to 38khz frequency.

but output of relay is not coming means relay is not triggered.
 

I didn't specifically ask if you changed the IRLINK parameter to 38 kHz, I suggested to check if the received waveform is actually as expected. If so, you gonna debug the receiver software.
 

Last edited:

My problem is i am not able to operate relay using remote.

below is the Hi-Tech C project files + Proteus file + compiled .hex files of transmitter and receiver
 

Attachments

  • Simulation.rar
    178.9 KB · Views: 132
  • Receiver Code.rar
    67 KB · Views: 132
  • Remote Code.rar
    57.1 KB · Views: 126

Just a few observations.

1. Your 12F615 /MCLR is pulled up to 3V but your VDD is still on 5V.

2. On the properties of IRLINK, the default is 40KHz. Are your TX/RX software based on 40KHz or 38KHz?

3. I see that all 4 relays are operating before any button is pressed when simulation starts.

Have you tried connect directly the output of 615 to the input of 675 without going through the IRLINK?

Just my 2 cents

Allen
 

Your finally presented code is still sending IR bursts of about 14 kHz as reported in post #6. That's a bit disapponting.

It seems to me as Proteus bug in simulating the PIC12F timer. As one symptome, PR2 ist reset to FF spontaneously. I fear, there's nothing we can do about. (Or maybe you can try to refresh the timer settings in main loop).

A circuit will hopefully work.
 

Just a few observations.

1. Your 12F615 /MCLR is pulled up to 3V but your VDD is still on 5V.

yes My 12f615 /MCLR is pulled up to 3v and vdd is also 3V.
2. On the properties of IRLINK, the default is 40KHz. Are your TX/RX software based on 40KHz or 38KHz?

yes now i have test with 38kHz but still getting problem to operate relay .
3. I see that all 4 relays are operating before any button is pressed when simulation starts.

Have you tried connect directly the output of 615 to the input of 675 without going through the IRLINK?

yes all relay operate as simulation start . and yes i tried to connect directly 615 and 675 but same problem arise (Relay is not triggered) .


ok FVM i have test and answer here.
 

I tried your simulation but I don't see relay operation initially and also I don't see IR bursts on Oscilloscope when buttons are pressed.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top