Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

IR Reciever Problem

Status
Not open for further replies.

Gayan Soyza

Active Member
IR Reciever Code Problem

I’m making an IR beam beaker. When the IR beam breaks it will trigger the relay.

I’m using TSOP1333 module for the receiver and IR LED for the transmitter.

I’m making a burst of 33 KHz frequency.600uS on time & 600uS off time. Receiver always checks this signal & make action depends on the output of the receiver.

Now the design works fine.

When I focus the IR LED to the receiver it will make low output. When I take the IR LED to another side receiver will make high output that is correct.

The only problem is

When I again focus the IR LED to the receiver it won’t make low it stays as high. So again I have to break the beam (cover) by hand so it will make low as earlier. That is my problem I don’t know what’s happening here.
 
Last edited:
try increasing the off time
 
Last edited:
TSOP1333 IR Module Code Problem

Hi this is the code for the above module.There is a small doubt in my code that I cant see........

Code:
			;Period = (PR2+1)*4*Tosc*PS TMR2
			;Period = 30uS--->33Khz

INIT_PWM		bcf	STATUS,RP0	; B0
			clrf	INTCON
			clrf	CCP1CON
			bsf	STATUS,RP0	; B1
			movlw	.29		; 30uS Period
			movwf	PR2
			bcf	STATUS,RP0	; B0
			movlw	b'00000110'	; 20% duty cycle
			movwf	CCPR1L
			movlw	b'00000100'	; T2 = ON,PS = 1:1
			movwf	T2CON
			movlw	b'00001100'	; PWM Mode,
			movwf	CCP1CON
;			;
INIT_TMR0		bsf	STATUS,RP0	; B1
			movlw	b'00000100'	; PS = 1:32
			movwf	OPTION_REG
			bcf	STATUS,RP0	; B0
			movlw	b'00100000'	; GIE = OFF,T0IE = ON
			movwf	INTCON
			;
			clrf	Flag_Register
			movlw	.40
			movwf	Display_Counter	
;===========================================================
Check_State		btfss	Flag_Register,Input
			goto	Reset_TMR0		
			btfss	INTCON,T0IF
			goto	TX_Loop
			bcf	INTCON,T0IF
			decfsz	Timer_Counter,F		; count 1S time "256 X 32 X 100 = 0.8S"
			goto	TX_Loop
			bsf	GPIO,GP0		; turn on relay
			movlw	.100
			movwf	Timer_Counter
			;
TX_Loop			movlw	b'00000000'		; Off Signal
			movwf	CCPR1L
			call	Del_600uS		; //
			movlw	b'00000110'		; 20% duty cycle
			movwf	CCPR1L
			call	Del_600uS		; //
			bsf	Flag_Register,Input
			movf	GPIO,W
			andlw	b'00100000'		; check GP5 IR module
			btfsc	STATUS,Z
			bcf	Flag_Register,Input	;
			;			
			decfsz	Display_Counter,F
			goto	Check_State
			movlw	.40
			movwf	Display_Counter
Show_Display		btfss	Flag_Register,Input	; show display
			goto	Turn_OFF_LED
Turn_ON_LED		bsf	GPIO,GP1
			goto	Check_State
Turn_OFF_LED		bcf	GPIO,GP1
			goto	Check_State

Reset_TMR0		clrf	TMR0	
			movlw	.100
			movwf	Timer_Counter
			bcf	GPIO,GP0		; turn off relay
			goto	TX_Loop

Del_600uS		movlw	.200
			movwf	Counter
Del_600uS_Loop		decfsz	Counter,F
			goto	$-1
			return
			
			end                       	; directive 'end of program'
 
Last edited:
What is timer0 used for? Infact, what is the code doing? Where does 0.85 seconds come into it?

Mike.
 
Hi mike thanks for your view.

The code continuously checks the TSOP receiver whether its high or low.If its low then it clears the flag bit,if TSOP receiver high it sets the flag bit.

The reason I use TMR0 just to make an time delay for the output relay to turn on.To activate the relay TSOP module must make high output (beam break) & stay the desired delay to turn on the relay.

Pre scaller = 32,TMR0 = 256,Timer_Counter = 100
32 X 256 X 100 = 0.8 S

Summary
------------
TSOP receiver focused on TX IR LED
If correctly align TSOP will make low output & LED OFF.
If beam break TSOP will make high output & LED ON.

The code checks the status of the TSOP receiver output while modulating the signal.If its high then it will turn on the relay after a short delay.There is an LED that is to indicate if the RX & TX focus correctly it will turn off.So the user can look that LED & align the sensor pair.Otherwise he needs to listen to the sound of the relay & align the pair.
 
Last edited:
Well, I would write it slightly different. This is how I would do it without timer0.

Code:
MainLoop		movlw	.8			;repeat 8 times to make
			movwf	PulseCount		;each loop 10mS
			bcf	Flag_Register,broke	;clear input flag
TX_Loop			movlw	b'00000000'		; Off Signal
			movwf	CCPR1L
			call	Del_600uS		; //
			movlw	b'00000110'		; 20% duty cycle
			movwf	CCPR1L
			btfsc	GPIO,5			;signal missing?
			bsf	Flag_Register,broke	;Yes, so set flag
			decfsz	PulseCount,f
			goto	TX_Loop

	;now test if beam broke

			btfsc	Flag_Register,broke	;was beam broken
			goto	TestRelay		;no, so just time out

	;beam was broken so turn on relay

			movlw	.80			;relay time is 80*10mS = 0.8s
			movwf	RelayCount		;set relay time
			bsf	GPIO,GP1		;turn on LED
			bsf	GPIO,GP0		;and relay
			
	;now test if relay is on

TestRelay		movfw	RelayCount		;test count
			btfss	STATUS,Z		;if it's zero
			goto	MainLoop		;just continue as relay is off
			decfsz	RelayCount,f		;time to turn off yet?
			goto	MainLoop		;no, so continue
			bcf	GPIO,GP1		;turn off LED
			bcf	GPIO,GP0		;and relay
			goto	MainLoop		;continue

I haven't tested this code but it should be fairly easy to follow and modify if needed.

Mike.
 
If I understand what you are doing with your code you are sending continuous bursts of the 38khz carrier, 600us On followed by Off, continuously ?

I thought the TSOP detectors needed short breaks in any data transmission for correct operation. From the datasheet I have (a 1738 but they all appear similar even if the values differ slightly)

Burst length should be 10 cycles/burst or longer.
• After each burst which is between 10 cycles and 70
cycles a gap time of at least 14 cycles is neccessary.
• For each burst which is longer than 1.8ms a
corresponding gap time is necessary at some time in
the data stream. This gap time should have at least
same length as the burst.
• Up to 1400 short bursts per second can be received
continuously.

So for correct operation you really should be sending your 600us On/Off packets in groups with gaps between. Of course any gap longer than expected would be someone breaking the beam so you code for that.
 
If I understand what you are doing with your code you are sending continuous bursts of the 38khz carrier, 600us On followed by Off, continuously ?
Yes I'm sending 33Khz burst 600uS on time following 600uS off burst continuously.

Note that I'm using TSOP 1333

So for correct operation you really should be sending your 600us On/Off packets in groups with gaps between. Of course any gap longer than expected would be someone breaking the beam so you code for that.

Can you explain this more
 
Last edited:
After long hours debugging I got this results.

My design works very closely like 2Feet distance it will work nicely.When the Rx & TX are more than 2Feet it won't work.

But I change the receiver to TSOP 1756 & adjusted the period & its working extremely long like 10m & more.

Like this way I need to tune for TSOP 1333.

The duty cycle I used 50% & period 30uS sending burst of 600uS & 600uS off time for the TSOP 1333.For the transmitting IR LED I used a buffer 2N2222 33ohm resistor & one IR LED for 5V supply.

I need more distance by using one IR LED like most remotes do.
 
Last edited:
You need a brighter LED, or there's something wrong with the frequency filtering.
 
When the Rx & TX are more than 2Feet it won't work.
I need more distance by using one IR LED like most remotes do.

I used lens to focus the IR beam (eg from old CD-laser diodes lens) and I managed to get a distance of around 5 metres to detect it in comparator mode. Might work with yours.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top