Shop OBEX P1 Docs P2 Docs Learn Events
BS II counter/totalizer programming ? — Parallax Forums

BS II counter/totalizer programming ?

ArchiverArchiver Posts: 46,084
edited 2000-10-23 01:51 in General Discussion
Hi to all:

I am trying to use a BS II to control a parking garage entry door.
The setup has 6 inputs (card reader, three loop detectors, manual
open/close) and 5 outputs (open door, close door, alarm, red light.
green light). All of the I/O's are dry contact relays.

In this control sequence, it is critical for the controller to
monitor the activity of cars going in and out of the garage to
prevent (1) the door from closing on top of a car, and (2) to prevent
cars from getting stuck behind a closed door while on the garage ramp.
This is done by means of a software counter or "totalizer" in the
program. What I'm trying to do is to setup this software counter so
that it will start at 0, increment by one each time an input relay
for a entry or exit loop detector pulls it's corresponding stamp pin
low, and decrement the counter by one when a car crosses the
nesessary loop detector that indicates that it has entered or left
the garage. The code will then need to prevent the door from closing
anytime the software counter is not "0".

I am a novice BS II porogrammer, but have the code and circuitry done
to read the inputs and control the output relays. I am puzzled
though at how to setup a software counter in PIC basic. The counter
variable does not have to remain in EPROM, but if that's the best way
to do it, it's no problem.

IF anyone has done a similar counter/totalizer in PIC Basic and could
help me, it would be much appreciated !

Thanks,
John Lawson
Anchorage, AK

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-21 22:37

    Original Message
    From: <lawson@g...>
    To: <basicstamps@egroups.com>
    Sent: Saturday, October 21, 2000 10:32 AM
    Subject: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?


    > Hi to all:
    >
    > I am trying to use a BS II to control a parking garage entry door.
    > The setup has 6 inputs (card reader, three loop detectors, manual
    > open/close) and 5 outputs (open door, close door, alarm, red light.
    > green light). All of the I/O's are dry contact relays.
    >
    > In this control sequence, it is critical for the controller to
    > monitor the activity of cars going in and out of the garage to
    > prevent (1) the door from closing on top of a car, and (2) to prevent
    > cars from getting stuck behind a closed door while on the garage ramp.

    Seeing as we have lots of lawyers in this country, I would suggest you
    wire this in hardware to prevent the motor from going down on
    something/someone. If your controller goes south, you still need the
    safety. A relay, either supplemental or in direct control of the motor's
    reversing circuit would prevent you from taking on unnecessary litigation
    should something go wrong, and Murphy says that they will.
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-21 23:06
    At 10/21/2000 -0700 02:37 PM, you wrote:

    >
    Original Message
    >From: <lawson@g...>
    >To: <basicstamps@egroups.com>
    >Sent: Saturday, October 21, 2000 10:32 AM
    >Subject: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?
    >
    >
    > > Hi to all:
    > >
    > > I am trying to use a BS II to control a parking garage entry door.
    > > The setup has 6 inputs (card reader, three loop detectors, manual
    > > open/close) and 5 outputs (open door, close door, alarm, red light.
    > > green light). All of the I/O's are dry contact relays.
    > >
    > > In this control sequence, it is critical for the controller to
    > > monitor the activity of cars going in and out of the garage to
    > > prevent (1) the door from closing on top of a car, and (2) to prevent
    > > cars from getting stuck behind a closed door while on the garage ramp.
    >
    > Seeing as we have lots of lawyers in this country, I would suggest you
    >wire this in hardware to prevent the motor from going down on
    >something/someone.


    FWIW - This is often accomplished by using a closed end "rubber" tube with
    a pressure sensor at one end. If this is for oneself, that's one thing, if
    it is For Sale (commercial product) that is an ENTIRELY different matter.

    Other methods entail detected the stopping of the drive screw or drive
    chain prematurely, and light beam break detectors. No method is "fool
    proof" but one should exercise "due diligence" in conjuring up such a
    device, and in its design.

    Warnings such as that given, ARE VERY appropriate..

    Regards,

    Bruce Bates

    > If your controller goes south, you still need the
    >safety. A relay, either supplemental or in direct control of the motor's
    >reversing circuit would prevent you from taking on unnecessary litigation
    >should something go wrong, and Murphy says that they will.
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-21 23:09
    unsubscribe

    Original Message
    From: Bruce Bates [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Ba7HdsOW__7OGi_a6wx6-wgNcoXgLOzIGlPOZIa5u8lzRYwPECL3Rc6qpiyUmqKD-Pe6cUk54neys-Qs2Lg]bvbates@u...[/url
    Sent: Saturday, October 21, 2000 3:06 PM
    To: basicstamps@egroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?


    At 10/21/2000 -0700 02:37 PM, you wrote:

    >
    Original Message
    >From: <lawson@g...>
    >To: <basicstamps@egroups.com>
    >Sent: Saturday, October 21, 2000 10:32 AM
    >Subject: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?
    >
    >
    > > Hi to all:
    > >
    > > I am trying to use a BS II to control a parking garage entry door.
    > > The setup has 6 inputs (card reader, three loop detectors, manual
    > > open/close) and 5 outputs (open door, close door, alarm, red light.
    > > green light). All of the I/O's are dry contact relays.
    > >
    > > In this control sequence, it is critical for the controller to
    > > monitor the activity of cars going in and out of the garage to
    > > prevent (1) the door from closing on top of a car, and (2) to prevent
    > > cars from getting stuck behind a closed door while on the garage ramp.
    >
    > Seeing as we have lots of lawyers in this country, I would suggest you
    >wire this in hardware to prevent the motor from going down on
    >something/someone.


    FWIW - This is often accomplished by using a closed end "rubber" tube with
    a pressure sensor at one end. If this is for oneself, that's one thing, if
    it is For Sale (commercial product) that is an ENTIRELY different matter.

    Other methods entail detected the stopping of the drive screw or drive
    chain prematurely, and light beam break detectors. No method is "fool
    proof" but one should exercise "due diligence" in conjuring up such a
    device, and in its design.

    Warnings such as that given, ARE VERY appropriate..

    Regards,

    Bruce Bates

    > If your controller goes south, you still need the
    >safety. A relay, either supplemental or in direct control of the motor's
    >reversing circuit would prevent you from taking on unnecessary litigation
    >should something go wrong, and Murphy says that they will.
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-22 02:16
    Bruce:

    The door is fully protected by a safety strip on the bottom of the door
    (which is hard wired to the door operator for instant reverse) and an
    infrared photobeam directly in front of the door 12" above ground level
    (which if the beam is broken will also reverse the door automatically as
    well).

    The software counter/totalizer is necessary because of the length of the
    entry/exit ramp (over 50' long) and the location of the entry and exit loop
    detectors. The BSII application that I'm working on would replace a 23 year
    old Gould PLC that is failing. The existing ladder logic and counter
    program in the PLC has worked well for many years - I'm just trying to
    duplicate it.

    Any ideas for how to implement a counter in PIC Basic ?

    Thanks !
    John Lawson

    Original Message
    From: Bruce Bates [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7iY53cjo7KTu588SBxB9FDL5YpA6ObwJygrs_BCbipR1aAxvQIE7Cmt2Z8sOWsq137vbS9ch5d4rZ5n4z0hXpQE]bvbates@u...[/url
    Sent: Saturday, October 21, 2000 2:06 PM
    To: basicstamps@egroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?


    At 10/21/2000 -0700 02:37 PM, you wrote:

    >
    Original Message
    >From: <lawson@g...>
    >To: <basicstamps@egroups.com>
    >Sent: Saturday, October 21, 2000 10:32 AM
    >Subject: [noparse][[/noparse]basicstamps] BS II counter/totalizer programming ?
    >
    >
    > > Hi to all:
    > >
    > > I am trying to use a BS II to control a parking garage entry door.
    > > The setup has 6 inputs (card reader, three loop detectors, manual
    > > open/close) and 5 outputs (open door, close door, alarm, red light.
    > > green light). All of the I/O's are dry contact relays.
    > >
    > > In this control sequence, it is critical for the controller to
    > > monitor the activity of cars going in and out of the garage to
    > > prevent (1) the door from closing on top of a car, and (2) to prevent
    > > cars from getting stuck behind a closed door while on the garage ramp.
    >
    > Seeing as we have lots of lawyers in this country, I would suggest you
    >wire this in hardware to prevent the motor from going down on
    >something/someone.


    FWIW - This is often accomplished by using a closed end "rubber" tube with
    a pressure sensor at one end. If this is for oneself, that's one thing, if
    it is For Sale (commercial product) that is an ENTIRELY different matter.

    Other methods entail detected the stopping of the drive screw or drive
    chain prematurely, and light beam break detectors. No method is "fool
    proof" but one should exercise "due diligence" in conjuring up such a
    device, and in its design.

    Warnings such as that given, ARE VERY appropriate..

    Regards,

    Bruce Bates

    > If your controller goes south, you still need the
    >safety. A relay, either supplemental or in direct control of the motor's
    >reversing circuit would prevent you from taking on unnecessary litigation
    >should something go wrong, and Murphy says that they will.
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-23 01:51
    >three loop detectors...
    > snip..
    >What I'm trying to do is to setup this software counter so
    >that it will start at 0, increment by one each time an input relay
    >for a entry or exit loop detector pulls it's corresponding stamp pin
    >low, and decrement the counter by one when a car crosses the
    >nesessary loop detector that indicates that it has entered or left
    >the garage. The code will then need to prevent the door from closing
    >anytime the software counter is not "0".

    >The software counter/totalizer is necessary because of the length of the
    >entry/exit ramp (over 50' long) and the location of the entry and exit
    loop
    >detectors.

    >Any ideas for how to implement a counter in PIC Basic ?

    Hi John,

    It's not clear to me from reading, how are the 3 loops set up in relation
    to the gate and the entry and exit?

    But supposing for simplification that there is one "entry" and one "exit",
    and you want to count how many cars are "inside". Here is code for a
    simple state machine to do it:

    ' the entry and exit loops will be connected to P0 and P1
    ' pull low when active
    xcount var word ' how many are inside
    dets var nib ' will hold current state of sensors
    det0 var nib ' will hold previous state of sensors
    detx var nib ' will hold changes in state of sensors
    loop0 var detx.bit0 ' loop 0 state change 1=entry
    loop1 var detx.bit1 ' loop 1 state change 1=exit
    dets0=inA ' initialize
    sensing:
    dets=inA ' read nibble port A, current state
    detx=dets^det0&det0 ' compute change in states
    det0=dets ' previous state=current state
    if loop0+loop1=0 then sensing ' changed?
    xcount=xcount+loop0-loop1 ' new count
    debug dec xcount,cr ' show it
    goto sensing ' repeat

    That's bare bones. You have to be sure that the signals from the loops are
    well debounced in hardware or software. Also, you have to have some means
    of recovery in case something goes wrong. Maybe a car backs stops and
    backs up over the sensor again. Oops. Or you have negative cars. Or it's
    like the San Francisco airport, always under construction, and nobody knows
    where anything is.

    The state machine approach is usually very fast in execution as it treats
    all the sensors in parallel. The present state is XOR'd with the previous
    state to detect a change in state, and that is AND'd with the previous
    state to limit it to changes from 1-->0 in each bit. That change bit stays
    high for one iteration of the loop, to increment or decrement the counter.

    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com/BS2misc.htm#directional <-- more state
    machines
Sign In or Register to comment.