Go Down

Topic: BI-DIRECTIONAL PEOPLE SENSOR AND COUNTER USING ARDUINO BOARD (Read 7795 times) previous topic - next topic

stefanoGizz

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

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

dhenry

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.


Graynomad

Rob Gray aka the GRAYnomad www.robgray.com

stefanoGizz

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.

AWOL

#5
Nov 03, 2012, 07:44 pm Last Edit: Nov 03, 2012, 07:49 pm by AWOL Reason: 1
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?
"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.

stefanoGizz

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.

oric_dan

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.

Graynomad

Well for starters to count you could do this.

Code: [Select]
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
Rob Gray aka the GRAYnomad www.robgray.com

stefanoGizz

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.


Grumpy_Mike

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.

Graynomad

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: [Select]
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
Rob Gray aka the GRAYnomad www.robgray.com

dhenry

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

:)

stefanoGizz

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.

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

Go Up