Offline
Newbie
Karma: 0
Posts: 22
|
 |
« on: October 10, 2012, 05:38:01 pm » |
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
Tesla Member
Karma: 75
Posts: 6970
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #1 on: October 10, 2012, 06:20:36 pm » |
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
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #2 on: October 10, 2012, 06:49:48 pm » |
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
Tesla Member
Karma: 75
Posts: 6970
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #3 on: October 10, 2012, 11:06:47 pm » |
 Or just get bored. ______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 22
|
 |
« Reply #4 on: November 03, 2012, 01:26:09 pm » |
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
Brattain Member
Karma: 143
Posts: 19365
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: November 03, 2012, 01:44:00 pm » |
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.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 22
|
 |
« Reply #6 on: November 30, 2012, 04:46:11 pm » |
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
Edison Member
Karma: 91
Posts: 2233
|
 |
« Reply #7 on: November 30, 2012, 07:16:49 pm » |
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
|
Something different - Kitchen-Sink Arduino-compatible boards
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6970
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #8 on: December 01, 2012, 09:52:07 am » |
Well for starters to count you could do this. 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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 22
|
 |
« Reply #9 on: December 02, 2012, 01:14:29 pm » |
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
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #10 on: December 02, 2012, 01:22:22 pm » |
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
Tesla Member
Karma: 75
Posts: 6970
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #11 on: December 02, 2012, 05:16:08 pm » |
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 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
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #12 on: December 02, 2012, 07:43:21 pm » |
The more I read it, the more I admire my non-blind guy idea. 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 22
|
 |
« Reply #13 on: December 03, 2012, 08:25:15 am » |
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
Tesla Member
Karma: 75
Posts: 6970
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #14 on: December 03, 2012, 08:45:25 am » |
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
|
|
|
|
|
|