Beam Break with Direction Detection

RustyH

Senior Member
Hi All,

Im looking for some suggestions on ways to measure the passing of an object through a gap of say 1m. However, I want to so that it can tell which direction that object has traveled. The gap between the sensors is to be no more than 110mm apart, but ideally would be 30mm aprat.

My current idea is to use two IR sensors, mounted in tubes to limit their angle of detection. Then using a picaxe to measure which IR is set off first, that way determining which direction the object has traveled.

I was just wondering if this is the most efficient and accurate method (that doesn't cost the earth)

Many thanks

Russ
 

nick12ab

Senior Member
I can't think of anything that would be cheaper.

Just beware that if you are just going to have two IR LEDs on constantly, those three-legged 38KHz IR receivers won't work - you need two-legged ones and these look exactly like LEDs.
 

hippy

Ex-Staff (retired)
Two beams and which activated first seems to be the way forward.

In fact you may only need to know which of the two beams has activated, as one activated and not the other implies the second will be activated later. That would likely avoid complexity related to how quickly an object is moving through the sensors.

How quickly an object is likely to move through the beams will dictate how quickly the PICAXE has to work and/or how far the sensors have to be spaced.

Some details on the application and what's being detected would help.
 

nick12ab

Senior Member
Just out of interest, how come the 3 legged ones wont work?
Because they have internal circuitry to demodulate the modulted IR signal from a remote control and filter out unmodulated signals which come from lighting.

However some three-legged ones are actually photodiodes which should work - but your three-legged IR receivers are much more likely to be the ones described above, and so is the one sold at Techsupplies.
 

hippy

Ex-Staff (retired)
Three-legged IR receivers are perhaps the easiest to use and what I'd choose. That does however require the IR LED to be modulated at 38kHz but that's easy enough with a PWMOUT.

For some IR receivers it is required / recommended not to have a modulated input permanently present but that's also easy to do; turn PWMOUT on, pause, check if the beam is present, turn PWMOUT off, pause, repeat. Just need to make sure all that can be done quickly enough that a beam break is not missed, and that depends on the size and speed of object being detected.
 

RustyH

Senior Member
Ok,

Its going to be used on a doorway, so Im looking for it to detect which way a person travels through that doorway. It will operate at both day and night, under daylight conditions and standard home lighting

Ideall, I would like the transmitting and Receiving IR on the same side of the door way. Maybe I could use one Transmitting IR and two receiving IR's??
 

Jamster

Senior Member
This should work with basic ADCs, you could probably do better if you used op-amps and interrupts.
Code:
SYMBOL leftSensor = B.1   'The pin with the left sensor connected
SYMBOL rightSensor = B.2  'The pin with the right sensor connected
SYMBOL triggerValue = 50  'The value the ADC musst reach to trigger it.
main: readADC leftSensor,b0  'read sensors
 readADC rightSensor,b1  ' "
 if b0 > triggerValue then 'See which was triggered
  sertxd( "Going right" ) 'Respond
 endif
 if b1 > triggerValue then
  sertxd( "Going left" ) 'Respond
 endif
 goto main
Dont forget to change the SYMBOL definitions to suit.

Jamster

To clarify: This wont work with the 38khz receivers...
 
Last edited:

hippy

Ex-Staff (retired)
Ideall, I would like the transmitting and Receiving IR on the same side of the door way. Maybe I could use one Transmitting IR and two receiving IR's??
Should work and that's often the way I've seen it done with a mirror bouncing the beam back. If the wall / skirting board is IR reflective enough you probably won't even need the mirror.

If it's a security application then you have to consider someone may step over / duck under the beam. Also a low-level beam may get broken twice as legs pass.
 

JimPerry

Senior Member
If you work on reflected IR , with transmitter in centre, then you may get 3 signals as someone moves through - say 1 off both off then other off. But if body is reflective then no signal interuption? You may need to experiment:)

Another way is to use 2 Passive IR detectors - like used in motion sensors.
such as
http://www.ebay.co.uk/itm/Mini-Portable-Pyroelectric-Infrared-PIR-Motion-Sensor-Detector-Module-/270941043100?pt=UK_BOI_Industrial_Supply_Security_Equipment_ET&hash=item3f1558399c#ht_3266wt_1000
 
Last edited:

RustyH

Senior Member
thanks everyone,

Its not a security application

It will probably have different height of people walking through it though, although Ideally I dont want it set off by the dog!! lol

so if the movement of legs could cause a problem, would the IRs be quick enough to determine which one was set off first. Such as someone running through it............I dont plan to invite Usain bolt around for dinner though!!


In regards to the motions sensors, I have some of these, and thought about trying them, but I need the "on" time to be as minimal as possible, in case someone walks in to a room and then walks out again. It will need to detect the person coming out of the room as well and entering
 

JimPerry

Senior Member
Hiya

The PIR modules have a 2.5 second latch time - so one each side of door would allow you to measure one person about every 3 seconds - no double counting with waving arms or legs then. :rolleyes:

Another advantage would be if two people carry a ladder through you only get 2 counts as opposed to counting rungs with a beam break system.
 

RustyH

Senior Member
Oh just to add,

I would like the device to be as small as possible, and I would also like to add a wireless transmitter, that can switch on a remote device.
 

RustyH

Senior Member
If Im understanding you correctly. You mean to turn the IRs on and off so that quick exit could be detected.

I had thought about that and my plan was to use the motion sensors modules you posted and switch them off as soon as they were activated to reset them, but they latch on the minute you apply power to them, so you cant control them by power.

I also thought about mounting them in the ceiling, that way you have a wall separating the two sensors, but then it would detect animals (IE dog), passing through. Where as on the doorway you could set its height to higher than the dog.
 

RustyH

Senior Member
OK

What Im trying to achieve is a sensor system then will detect entry and exit to a room. The picaxe will work so that it keeps a count of how many people are in that room, so say three people enter the room, it will record 3 activations of the sensors. If 1 person leaves the room, the picaxe will record there is still 3 people remaining. If the final 2 leave the room, the picaxe will know the room it empty.

Therefore the sensor method must be able to determine the direction, to therefore determine if its an exit or entry.
 

eclectic

Moderator
OK

What Im trying to achieve is a sensor system then will detect entry and exit to a room. The picaxe will work so that it keeps a count of how many people are in that room, so say three people enter the room, it will record 3 activations of the sensors. If 1 person leaves the room, the picaxe will record there is still 3 people remaining. If the final 2 leave the room, the picaxe will know the room it empty.

Therefore the sensor method must be able to determine the direction, to therefore determine if its an exit or entry.
Playing silly beggars and using the windows? :)
 

JimPerry

Senior Member
And presumably turns the lights(or similar) on then off? Problem occurs if people enter in pairs/groups - telling the difference might get complicated.

A third sensor over the room could be used to detect any remaining person to account for missed counts?

Conventional PIRs used in alarms rely on movement through a zone (defined by the fresnel lens) but a simple PIR just detects body heat.
 

RustyH

Senior Member
yeah, there maybe be times when there is no movement, so I cant rely on movement sensing with in the room
 

boriz

Senior Member
"Maybe I could use one Transmitting IR and two receiving IR's?? " - Exactly what I'd do.

"I would like the transmitting and Receiving IR on the same side of the door way" - Problematic.

As was hinted by Jim, if your subject is wearing (or carrying) something that reflects IR, then there will be no signal interruption. And what if they rotate slightly while mid-doorway, so they don't interrupt the first sensor, but do interrupt the second. That would count as them moving the wrong way?

If you insist on 'same side' beam-break sensors, you need something that definitely will not detect reflection from person. IE: LASER. The beam can be reflected from a mirror and received by a photo-diode/photo-transistor that's in a shielding tube. The LASER will produce a very strong signal from the reflector and a week signal from the passing person. This would be the most reliable beam break system, but still has the ability to produce false readings. What if the person is carrying a mirror/piece of glass/flashy purse?

You could rely on the IR reflection of the person instead. IE: Tune the system to reject reflection from the other side of the doorway and only trigger when something reflects the IR more strongly. But that would also be problematic/unreliable for similar reasons.

Even if you use a more reliable both-side system (prolly what I'd do), there could be issues. What if the dog jumps up? What if a spider crawls across the sensor? What if two people move through close together in the same direction or pass each other in the doorway? What if someone moves only halfway through the doorway, then changes their mind and returns from the direction they came? What if ... etc...

It just takes one event like this and your count is spoiled. Room occupancy detection has been discussed here before, it's very hard!. Do a search.

Just for kicks, take a look at this: http://www.dealextreme.com/p/obstacle-avoidance-ir-robotic-sensor-yellow-black-dc-5v-148556

If it works as advertised, you should be able to tune it to detect people but not the opposite doorframe. And it has a simple HIGH/LOW output.
 

hippy

Ex-Staff (retired)
It just takes one event like this and your count is spoiled. Room occupancy detection has been discussed here before, it's very hard!.
I'd agree. Without guaranteed absolute accuracy you have to rely on probably is / is not occupied and possibly is / is not determinations and then come to a decision. To complicate things, "Probably is" is not a logical inverse of "probably is not" etc.

Each may be pretty hard determinations with risk of false positives and false negatives.
 

RustyH

Senior Member
Is there a way of putting in safety nets. Maybe have room motion sensors so if the system thinks there is no one in the room, and it detects motion, then it would revert to possibly 1 occupying the room. Then maybe set the lights on a timer for say 10 mins, if not further activity is detected then turn them off and reset count
 

vttom

Senior Member
Can you issue all your visitors RFID tags before they get to the doorway? Then it's a matter of surveying the room with an RFID reader. If you get any response, at least one person is there. If you get no response, the room is empty.

You could always install a pair of turnstiles (1 in-bound and 1 out-bound).
 

AllyCat

Senior Member
Hi Russ,

Yes, if you want "good" reliability (you will never get perfection) then an additional "presence detector" such as PIR or ultrasonic field seems best (to "reset" the system in the event of an error). But either method has the potential of false triggering by pets, mice or perhaps even spiders.

For the basic optical sensor, the two optical paths only need to be a few cms apart (at a suitable height above the floor) to detect direction of movement. I would definitely modulate the LED transmitter to eliminate background illumination and to save power, perhaps even quite a low duty cycle (say a 10us pulse every 1ms) if power consumption is an issue. Many IR LEDs and Transistors have built in lenses (IMO sometimes rather too narrow a beam for decent Remote Control operation). Transmitter and receiver on the same side of the entrance should be no particular problem using a mirror. Recently I was looking for a cheap/available plastic mirror that could be easily cut to size, so my solution was an old CD(ROM). Actually their surface is quite complex, but still usable as a simple mirror.

Cheers, Alan.
 

JimPerry

Senior Member
Try and keep it simple - let Picaxe make best guess at occupancy but have an indicator LED showing "Occupied" and a simple push button outside that resets to Empty and switches off lights after delay ("Will the last person out - press if lit?") and maybe a beeper that sounds before auto shut off to alert anyone left in to press button on other side to increment count? :rolleyes:
 

hippy

Ex-Staff (retired)
Safety nets can help. Motion detected increases confidence that the room is occupied ( but could be a dog or a flapping curtain ), it may also decreases confidence that the room is unoccupied. Lack of motion for some time can likewise do the opposite.

You can count people in and out with a beam break detector but ultimately it's the confused state which is the problem; what when there's no one counted in but a high confidence the room is occupied, or a low confidence but one or more counted ? Which do you choose to believe ?

You could opt for break plus motion indicates occupied, lack of motion with a timer to trigger unoccupied, the break count affecting what the timeout will be, motion resetting timeout. But you will probably find there's still some case like the room being considered unoccupied when it isn't, and fixing that aspect shifts to cases where it's considered occupied when it isn't. You can bat that back and forwards all day long.

There are probably technologies that can more reliably determine occupancy - load cells, CO2 level monitoring, CCTV analysis - but those are likely not options. So the best one can have is a system that works well enough most times.
 

RustyH

Senior Member
Got you, thanks everyone

So ultimately, a system with a break beam and motion sensor is as close an accuracy I will get, then maybe have an external reset button to reset the system if it was to get out of accuracy.

As hippy says, a system that works most of the time, but carry the risk of possible error
 

hippy

Ex-Staff (retired)
Or just go for the basics; push a button on the way in and push another on the way out.

Ultimately all you are trying to do is automate those button pushes so you can start with a working system that controls whatever it is meant to and then add that automation. You may find button pushes are good enough.
 

geoff07

Senior Member
Assuming people can't be going in as others are coming out, you only need one beam to break to detect direction: two beams, using 38khz for noise immunity, if the inside one breaks they are going out, if the outside one breaks, they are going in. You could have a little traffic light to stop incoming while outgoing was in progress and vv.

Or tread mat sensors on the inside and outside with similar logic?
 

Bill.b

Senior Member
Hi Russ

This may be of some help. This schematic is to control a head that follows anyone that moves into its range.
I use the sharp GP2YOA21 (GP2D12) IR distance mesuring unit View attachment sharp 2Y0A21[1].pdf
This unit has a range of 80cm, depending on the door width, should be OK
I have an other program for the same project using the SRF005 ultrasonic sensor if a greater
range is required.

movinghead2.jpg

Code:
'program Scanner14m2a.bas
'picaxe 14m2
'30/7/12   WB (Bill.B)
' follow object until 
'object moves out of range.


#picaxe 14m2
#No_Data
pause 1000
setfreq m8

symbol LeftOffSet		= b0		'positive Offset
symbol counter1 		= b1		'counter
symbol TempCount		= b2		'Temperary Counter
symbol RightOffSet	             = b3		'Negstive Offset
symbol LoopCount		= b4
Symbol range                    = w3		'Left range sensor register
SYMBOL range2		= w4		'Right range sesor register
symbol TempRange		= w8
symbol TempRange2	= w9
symbol LED2		= b.2		'animation LED 2
Symbol trig 		= b.3		'Left range sensor ADC input	
symbol trig2		= b.4		'Right range sensor ADC input
Symbol SERVO1                  = b.1		'Servo Output
symbol Bell 		= b.5		'bell output
symbol LED3		= c.0

dirsB=%11111111
dirsC=%00000001

high led3
servo servo1,75
RightOffSet = 40		'set Right max position
LeftOffSet = 90		'Set Left max position
tempcount = 75

main:
	ServoPos SERVO1,off
	gosub distance
	if range > 20 or range2 > 20 then 'if object found goto follow object routine
		gosub follow
	endif
	pause 150


goto main  


follow:			'Follow object subroutine. 
	servo servo1,55
	tempcount = 55	'preset servo position
	low led3		'Turn on LED sequence
	high led2		'Turn on found LED
	high bell		'Ring Bell - operate motor for 600ms
	counter1 = 0
	pause 600
	low bell
	do
		gosub distance
		if range < 20 and range2 > 20 then  'follow object if it moves to the right
			TempCount = TempCount + 2
			counter1 = 0		
		endif
		if range > 20 and range2 < 20 then	'follow object if it moves to the left
			TempCount = TempCount - 2
			counter1 = 0
		endif
		if TempCount < RightOffSet then			'do not pass end limits.
			TempCount = RightOffSet
		endif
		if TempCount > LeftOffSet then
		  	TempCount = LeftOffSet
		endif
'	debug 
		pause 200
		 ServoPos SERVO1, TempCount			'servo position
  		counter1 = counter1 + 1
	loop until range < 20 and range2 < 20 and counter1 > 20	'Loop until object moves out of range
	TempCount = 60
	ServoPos SERVO1, TempCount
	high led3				'Turn off LED sequencer
	low led2				'Turn off found LED
	pause 200
	return
	
	
distance:			'Routine to average 5 readings from the IR sensors.
	TempRange2=0
	TempRange=0

	for LoopCount = 1 to 5   
		readadc trig,Range 	'
   		TempRange = TempRange + range
  		pause 20
   		readadc trig2,Range2 	 
    		TempRange2 = TempRange2 + range2
    		pause 40
    	next LoopCount
    	TempRange2 = TempRange2/5
   	TempRange = TempRange/5
    	range = TempRange
    	range2 = TempRange2
  	' debug

	pause 100
    	return
Bill
 
Last edited:

JimPerry

Senior Member
http://www.ebay.co.uk/itm/Mini-Human-Sensor-Detector-Module-IR-Pyroelectric-Infrared-PIR-Motion-/320899981899?pt=UK_BOI_Industrial_Supply_Security_Equipment_ET&hash=item4ab721224b#ht_3536wt_977

looks like it would do the job - it has a 22uF cap on board which I bet gives the delay - unsolder it and replace with 2.2uF to get a .25 second delay? I'm ordering a couple for the fun of it! ;)
They arrived - and work -- still trying to figure out the delay - email reply from manufacturer is in Chinese :confused:
 

mrburnette

Senior Member
They arrived - and work -- still trying to figure out the delay - email reply from manufacturer is in Chinese :confused:
The eBay link had these specs...
Electronic level output: High 3.3V/Low 0V
Trigger mode: Repeated triggering
Blockade time: 2.5S
PCB size: 10 * 23mm
Detective angle: <100°
Induction distance: less than 3m​

My guess is that "blockade" time is the minimum cycle time.
 

Haku

Senior Member
A while ago Ben Heck got a request for modifying a hand sanitiser for hospital use that would alert people if they walked past it and didn't use it, and it would only alert if the person walked past the sanitiser in one direction and not if they were walking past the other direction (out of the building/room/corridor)

He used a couple of tiny PIR sensors to detect what direction the person was walking past the sanitiser.

http://www.youtube.com/watch?v=uJkTpq0kW0g
 
Top