Ir beam break sensor

Thread Starter

geoffers

Joined Oct 25, 2010
475
Morning all,
I've a project on the go at the moment that requires a pic to sense if there's milk in a pipe or not, the pipe is clear so I was hoping to use a ir pair as a beam break sensor. I've hunted about the net a bit and seen quite a few examples that modulate the output of the ir led and then use a band pass filter at the sensor end.

From what I understand this is to aviod any stray ir triggering the sensor?
Other examples seem much simpler and use the ir sensor as a switch.

I'm going to have to make a plastic holder for the emitter and sensor so eliminating stray ir shouldn't be to tricky. Are there any other reasons to go for modulation? I have a spare pwm output on the pic but the simple option is attractive!
Cheers Geoff
 

DickCappels

Joined Aug 21, 2008
10,152
There are two reasons for switching the LED on and off. One is that doing so makes it easy to separate the IR signal from any background noise or dark current in the IR detector. The other is that it then becomes easy to amplify the pulses without amplifying any DC offset from the IR detector.

It really makes life a lot easier, especially since it is likely to make sensitivity adjustment unnecessary.
 

wayneh

Joined Sep 9, 2010
17,496
Modulation is also used to get a higher peak output without a higher average output, which is hard on the life of the LED. Useful if you want to drive a signal through a finger, say, to look at a pulse.

Your application could likely be made to work fine without modulation, but it's hard to speculate whether it would save you any time or trouble, for the reasons Dick has noted. More complicated upfront, but far easier when you put it into the field.
 

tracecom

Joined Apr 16, 2010
3,944
I hope this is not considered hi-jacking, but I am wondering if I need to pulse a visible LED that is illuminating a photo transistor less than 1/4" away and will be blocked by a coin passing between them. I intend to measure the time it takes the coin to pass by.
 

Thread Starter

geoffers

Joined Oct 25, 2010
475
Thanks for the quick reply,
That makes good sense, what do folks think of this circuit, I found it on pcbheaven.com

irshorddistancebeamcut_1276410085.png

Hope he doesn't mind me reproducing it!(its a interesting site).

I can do away with the transmitter circuit shown on the site and use the pwm output I have spare to drive the ir led. If I hadn't already used the a/d on my pic I could have used the on board comparator.

Cheers Geoff
 

wayneh

Joined Sep 9, 2010
17,496
...I am wondering if I need to pulse a visible LED that is illuminating a photo transistor less than 1/4" away and will be blocked by a coin passing between them.
I don't think you'd gain much from modulation in this application, unless it's out in direct sunlight or some other "noisy" environment. It's all about signal to noise.
 

Bernard

Joined Aug 7, 2008
5,784
I hope this is not considered hi-jacking, but I am wondering if I need to pulse a visible LED that is illuminating a photo transistor less than 1/4" away and will be blocked by a coin passing between them. I intend to measure the time it takes the coin to pass by.
I've tried unmodulated & modulated IR detection at 17 ft goal- modulated won, but at 1 ft no difference, red or IR, no difference; just reasonable match wavelengths of Rx & Tx. Might use slot aperatures to more define break.
 

Thread Starter

geoffers

Joined Oct 25, 2010
475
Hi all,
Thanks for the help I've had here and in the Embedded controllers section.
Here's what I've come up with;

irsensor.gif

The 12f675 drives the ir led at about 1.5khz, I used the internal voltage ref set to maximum as the +ref for the comparator, the 50k pot adjusts the sensitivity.

Its sensitive enough to be be triggered by the presence of milk in a clear pipe.:)

Here's the code;

Rich (BB code):
#INCLUDE P12F675.INC
	LIST P=12F675
	ORG	 0X00
	GOTO	START

__CONFIG_INTRC_ORC_NOCLKOUT
__CONFIG_WDT_OFF_
__CONFIG_PWRTE_ON
__CONFIG_MCLRE_OFF
__CONFIG_BOREN_OFF
__CONFIG_CP_OFF
__CONFIG_CPD_OFF
	
	COUNT	EQU	0X20
	TIME	EQU	0X21
;#########################################################
DELAYP5	MOVLW	.100
		MOVWF	COUNT
TIMED	CALL	DELAY
		DECFSZ	COUNT
		GOTO	TIMED
		RETLW	0

DELAY	CLRF	TMR0
LOOPA	MOVF	TMR0,W
		SUBLW	.39
		BTFSS	STATUS,Z
		GOTO	LOOPA
		RETLW	0

DELAY1.5	CLRF	TMR0
LOOPB		MOVF	TMR0,W
			SUBLW	.3
			BTFSS	STATUS,Z
			GOTO	LOOPB
			RETLW	0
 

START BSF	STATUS,5	;BANK1

	CLRF	ANSEL

;	CALL	3FFH
;	MOVWF	OSCCAL
	MOVLW	B'00001011'	;GP0, GP1 COMPARATOR INPUT REST OUTPUT
	MOVWF	TRISIO
	MOVLW	B'10001111'
	MOVWF	VRCON		;TURNS ON COMPARATOR VREF, LOW RANGE, ABOUT 3V
	CLRWDT
	MOVLW	B'00000111'
	MOVWF	OPTION_REG
	BCF		STATUS,5	;BANK0

	MOVLW	B'00010011'		;	B'00000011'	;GP0=CIN+ GP1=CIN- GP0=OUTPUT
	MOVWF	CMCON

	CLRF	GPIO

;####################################################


BEGIN	BSF		GPIO,5
		CALL	DELAY1.5
		BCF		GPIO,5
		CALL	DELAY1.5
		GOTO	BEGIN

END
I have had a issue with the configuration bits so set them in mplab.

Cheers Geoff
 
Top