Shop OBEX P1 Docs P2 Docs Learn Events
Person counter loop — Parallax Forums

Person counter loop

cjolson140cjolson140 Posts: 5
edited 2006-02-03 18:41 in BASIC Stamp
Hi,
I'm still working on that person counter I posted about yesterday. Now I'm trying to figure out how to make the loop detect a person (in9 = 0), record the event (people = people + 1) and wait until the person leaves (in9 = 1). Right now what I have is supposed to do this, but whenever it detects someone in front of the sensor, it starts adding continually to the people varible. I already tried using a time delay, and it works, but I want this to be more advanced than that.
Thanks again.
Caleb

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-03 17:04
    Since this is essentially the same topic you should've probably continued this in your existing thread.· In any event what you need to do for each increment of the counter is to then loop until the sensor is clar before looking again for a new person.· Re-examine your logic and you should be able to hash this out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-03 17:14
    Taking a look at your program it appears you are actually trying to do this, so there must be some changing in the sensor readings that's re-triggering the counter.· It will take som knowledge of what's happening at the sensor to code a work-around.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • NewzedNewzed Posts: 2,503
    edited 2006-02-03 17:17
    Try something like this:

    detect:

    if sensor = low then
    person = person + 1
    go to cont
    endif
    go to detect

    cont:
    if sensor low then cont

    go to detect········· 'if sensor goes HIGH· this will happen



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-03 18:06
    Caleb:

    This is an application where manually debouncing your sensor input will help.· If you think about it, humans don't move particulary fast (relative to micros), so you can use a bit of code to make sure that your person sensor is active or not.· I would do something like this:

    Check_Sensor:
    · sensor = 1
    · FOR idx = 1 TO 10
    ··· sensor = sensor & ~irInput
    ··· PAUSE 25
    · NEXT
    · RETURN

    What this routine does is make sure that the person is present for at least 250 ms before·he/she is flagged as being present.· This will prevent sensor bouncing as a person enters/leaves the sensor zone from disturbing your count.· With sensor·and done being·bit variables, you can simplify you count code like this:

    · peopleCount = peopleCount + (sensor * done)

    With this, the only way peopleCount can be incremented is for both sensor and done to be "1."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-03 18:41
    Here you go, I whipped up a little DEBUG version of your program to show you who you can implement my suggestion above.· I hope this helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.