You are on page 1of 32

Sensors Setup

THREE (+1) SENSORS ARE USED FOR A TYPICAL SETUP

On the frame

This sensor will be present on the frame to the outside of the door. Itll be an IR sensor placed at a height of 3 ft. from ground

PIR Sensor
Range is restricted to detect changes only in specific prism area.

Hall Sensor
To sense if Door is open/close

Algorithm for Counting

Basic IN

Idle

Door Opened

IR Detected

PIR

Count ++

Door Closes

Basic Out

Idle

PIR

Door Opened

IR detected

Count --

Door Closed

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Cumulative Flow Chart

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

This works for Multiple persons entry/exit. Left half if for Person going out. Right half shows a person coming in.

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Fail Case 1

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

Unintended PIR interrupt by person moving in the room

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

Door opened by a person who wants to get into the room

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR interrupted by the entering person

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

Algorithm considers this to be a person Out. And hence, decreases the count.

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

The entered person interrupts PIR. Now, algo sees this as a second person going out of the room. So, it keeps checking for IR interrupt.

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

Which doesnt occur. If only one person gets in.

PIR/IR

Door Closed IDLE

Error Correction

Hence, in this case. We can eliminate the error if only a single person enters. We have a incomplete cycle, and we eventually reach idle State when the door closes. This situation can be handled by introducing an artificial variable.

Fail Case 2

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Algos Behavior
The algorithm Senses it as many persons out and makes the count zero. Another possibility is increasing count indefinitely .

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

Inside person who intends to open the door interrupts PIR

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

This person

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR is continuously interrupted

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

Person is still being detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Person Detected?

IDLE

Door Opened? No
Door Opened and Person Did not enter still

Yes No

Yes

Infinite Loop

Person Detected

Door Opened?

IR?

No

Yes

No

Yes No Person Detected

IR?

Yes

Yes

Count --

Door Closed?

Count ++

Person Detected

IR

PIR/IR

Door Closed IDLE

Error Correction

Here, the problem comes as the algo continuously increases/decreases the count indefinitely.

To limit that, we can add two variables t+ and t- .


These variables will be updated each time a Count ++ or Count occurs. Now, before updating the Count well check when was the last time it was updated.

Well put a limit, say 0.1 sec before updating it again.