Pages: [1] 2 3 4   Go Down
Author Topic: BI-DIRECTIONAL PEOPLE SENSOR AND COUNTER USING ARDUINO BOARD  (Read 6770 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am building a bi-directional people sensor and counter using an ARDUINO board.
am very new to this and programming as well.

any suggestons for schematics and the code.

thanks
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 128
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How reliable does this have to be? What's the application?

It's notoriously difficult to get reliable people counting unless you install turnstiles or some such.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It's notoriously difficult to get reliable people counting unless you install turnstiles or some such.

That's just not true!

Hire a non-blind guy watching people, and for every person going by bi-directionally, the guy pushes a button on an arduino board.

Dada! Cannot be any simpler or more reliable than that, assuming of course the guy doesn't get drunk.

Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 128
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

smiley

Or just get bored.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

THIS SYSTEM DOESN'T HAVE TO BE VERY RELIABLE BUT AM WONDERING IF ANYONE OUT THERE CAN HELP WITH THE CODE TO RUN A PIC16F8777A OR AN ARDUINO WITH TWO IR SENSORS S1 AND S2 TO PERFORM BIDIRECTIONAL COUNTING IN AND OUT. IN THE FIRST SEQUENCE BREAKING FIRST S1 AND THEN S2 WILL TELL THE MICROCONTROLLER TO INCREMENT THE COUNTER WHILE BREAKING THE SECOND SEQUENCE, FIRST S2 AND THEN S1 WOULD TELL THE MICROCONTROLLER TO DECREMENT THE COUNTER.THE MICROONTROLLER SHOULD ALSO STORE AND TIMESTAMP THE COUNTS AND BE ABLE TO PASS THE TIMESTAMPED DATA TO A REMOTE COMPUTER VIA BLUETOOTH OR WIFI.
ANY HELP WILL BE GREATLY APPRECIATED.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There really is no need to shout.
Have you looked for such code in the forum?
It seems to be a very popular project at the moment - which particular seat of learning is promoting it?
« Last Edit: November 03, 2012, 01:49:16 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have looked in the forum but nothing is forthcoming. The closest have got is the 2 rotary encoder code which I think is applicable to my counter.
In checking the external interrupts occuring sequence.
Any suggestions are welcome.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If the area being measured is fairly narrow, you can just setup a couple of what
used to be called "photoelectric eyes" [IIRC], ie the person going by simply breaks
a lightbeam. You don't need interrupts for this, just a simple polled I/O loop.

You might get by with something as simple as a couple of pulsed Leds, a mirror for
reflection, and CdS cells [photoresistors] for pickup.
 
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 128
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well for starters to count you could do this.

Code:
my_ISR () {

   // we got here because S1 was activated (and debounced in hardware)
   count += digitalRead(S2) == HIGH ? 1 : -1;

}

An interrupt is not really required here but IMO makes life easier as long as the input signal is clean.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the info. I am using pair of infrared sensors on one side facing the transmitter on the other side, and all I want is the same pair of sensors to command a counter to increment by 1 if a person breaks them in one way (IN) or if the other way round that will mean exit and hence decrement the counter.I was thinking of coding the arduino board to check the sequence in which the sensors were tripped and then decide whether to increment or decrement count.

steffano.

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So what happens when some one trips one sensor but then changes her mind an goes back and never trips the second one. Now providing the next person comes in from the opposite it will count backwards and continue to count backwards until some one makes a compleat transit from the original direction.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 128
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was thinking of coding the arduino board to check the sequence in which the sensors were tripped and then decide whether to increment or decrement count.
Which is exactly what my code does. Here's a more verbose version that's possibly clearer to a C beginner

Code:
my_ISR () {

   // we got here because S1 was activated (and debounced in hardware)
   if (digitalRead(S2) == HIGH)
       count++;
   else
       count--;   // should test for < 0 as well

}

But as I alluded to in post #1 and Mike just explained more completely there are many pitfalls to this approach.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The more I read it, the more I admire my non-blind guy idea.

smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Rob,

I am making some good progress with my ISR and to start with am printing the count on the serial monitor.
Have also got a 3 digit common cathode display wired to arduino Mega 2560 and the code to count upto 0-999-0
therefore am wondering how do I call the counting code after the interrupts have occured so as to display the count/counter
(incrementing or decrementing) on the 3 digit seven segment display??

Much appreciated.
Steffano.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 128
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how do I call the counting code after the interrupts have occured so as to display the count/counter
That depends entirely on how you have the displays wired up.

Got a circuit diagram?

And how about posting your current code?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1] 2 3 4   Go Up
Jump to: