Shop OBEX P1 Docs P2 Docs Learn Events
Need Pbasic for Dummies! Help — Parallax Forums

Need Pbasic for Dummies! Help

ArchiverArchiver Posts: 46,084
edited 2004-01-30 18:16 in General Discussion
T.O.-

Can you state your requirements in terms of a truth table? I'm
getting lost in the description. Sounds like the truth table may
need to include former switch settings, current switch settings,
current output states, desired new output states. Also, are the
inputs sampled and the outputs updated continuously, or at specific
intervals?

Cheer up, sounds like something the Stamp can do with just a few
lines of code.

Regards,

Steve

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-01-20 19:57
    Going bald

    For the life of me I can't seem to get the hang of writing a program
    for the stamp! At first it appeared as though it would be simple to
    control two relays with three switches right ! ( have very few hairs
    left to pullout ). Was easier to build a logic circuit with a couple
    of JK flip-flops, and a few AND gates yet would like to see just
    what a stamp can do to save parts and a lot of wiring. 20 plus years
    ago enjoyed playing around with the old basic on a VIC 20 now trying
    to relearn all this Greek or Latin ( Pbasic ) What I would like to do
    is simply toggle the state of two outputs depending on, the on or off
    state of the same 2 outputs and 3 inputs ( switches ), with the
    following rules.

    Must start with outputs =0

    Output X and Y can never be toggled on at the same time

    Output X can never go on if switch 1 is already on, but can toggle
    X on if first was off

    Same applies to to output Y and switch 2

    Switch 3 toggles off X or Y first if X or Y =on
    or allow X on only if switch 3 is on
    or allow Y on only if switch 1 is on

    Can anyone help?

    P.S.
    Will purchase the first Pbasic ( Greek ) for Dummies!

    Looking for software that will convert a logic circuit to stamp
    program ( Un-Greek-tified ) or similar.

    Thanks T.O.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-20 23:19
    im working on your program but we have a flaw in the logic.

    First OUTPUT X AND Y = 0

    At startup if switch1 is on and switch2 is on then Output X and Output Y
    cannot be turned on from switch1 and switch2 because there aready on
    therefore switch3 would turn on Output X because it initialized in the
    output x = 0 state but if switch1 is on at the same time switch3 is on that
    would indicate output X and output Y to be on at the same time

    basically stating that

    Output x = 0
    Output y = 0
    if switch1 = 1 and switch2 = 1 and switch3 = 1 then

    How is this statement true if they cannot be on at the same time?

    Switch 3 toggles off X or Y first if X or Y =on
    or allow X on only if switch 3 is on
    or allow Y on only if switch 1 is on




    At 07:57 PM 1/20/2004 +0000, you wrote:
    >Going bald
    >
    >For the life of me I can't seem to get the hang of writing a program
    >for the stamp! At first it appeared as though it would be simple to
    >control two relays with three switches right ! ( have very few hairs
    >left to pullout ). Was easier to build a logic circuit with a couple
    >of JK flip-flops, and a few AND gates yet would like to see just
    >what a stamp can do to save parts and a lot of wiring. 20 plus years
    >ago enjoyed playing around with the old basic on a VIC 20 now trying
    >to relearn all this Greek or Latin ( Pbasic ) What I would like to do
    >is simply toggle the state of two outputs depending on, the on or off
    >state of the same 2 outputs and 3 inputs ( switches ), with the
    >following rules.
    >
    > Must start with outputs =0
    >
    >Output X and Y can never be toggled on at the same time
    >
    >Output X can never go on if switch 1 is already on, but can toggle
    >X on if first was off
    >
    >Same applies to to output Y and switch 2
    >
    >Switch 3 toggles off X or Y first if X or Y =on
    > or allow X on only if switch 3 is on
    > or allow Y on only if switch 1 is on
    >
    >Can anyone help?
    >
    > P.S.
    >Will purchase the first Pbasic ( Greek ) for Dummies!
    >
    >Looking for software that will convert a logic circuit to stamp
    >program ( Un-Greek-tified ) or similar.
    >
    >Thanks T.O.
    >
    >
    >
    >
    >To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    >from the same email address that you subscribed. Text in the Subject and
    >Body of the message will be ignored.
    >
    >
    >Yahoo! Groups Links
    >
    >To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    >To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    >Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/



    "Why am i fighting to live, if im just living to fight"
    "Why am i trying to see, when there aint nothing in sight"
    "Why am i trying to give when no one gives me a try"
    "Why am i dying to live if im just living to die"
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-27 00:36
    I apologize for not providing enough info the first time, the few
    hairs I had on top are now gone and I'm still unable program my stamp
    II to work the way I'd like and replace my logic circuit.
    The present logic circuit I've created controls a 3 level elevator.
    The top and bottom levels each have two switches with two additional
    switch in the elevator wired in series ( see below ) with first and
    third level input. All are normally closed type switches. The center
    floor has 2 switches wired in series connected to a third input. The
    two outputs control a pair of opt-triac that provide up down action.
    On start-up one of any single (b.) switch will normally be open
    depending on location of elevator. Both outputs must be off on power
    up. F3(b.) and F1(b.) prohibits elevator from going beyond that
    level. Please not, the (a) switches toggle its correspond outputs on
    as long as both outputs are off , and what other (b) switch is open
    determines what direction (output to turn on ). Once elevator is in
    motion the (b.) switch it was stopped on automatically closes before
    the next floor allowing the (b) switch to open and toggles elevator
    to stop if output is on. Please note, based on what floor elevator is
    on, Y input is the only input that can allow one or the other outputs
    to go on but never at the same time.
    My logic circuit allows the following:
    U=0 and D=0 ` when first turned on
    If X input =1 and Y =1 and elevator is stopped outputs =0, elevator
    is at Z (Z=0), with input Z open, X or Y must not allow Doutput on
    ever.
    If X input =1 and Y=0 and Z=1, elevator is at Y (level 2). Note
    with Y input open X(a) or Z(a) can still page elevator when one or
    the other opens then closes starting elevator in that direction. When
    that input again opens, elevator stops on that floor.

    Paging Elevator
    with input Y open, X (a) or Z (a)inputs when one or the other is
    toggled allow elevator back on, X input toggled for Up, Z input
    toggled for Down. When elevator reaches the corresponding (b) switch
    opens turning output off.
    No output can ever be on at same time.
    Also note once elevator is toggled in the correct direction and in
    motion that level it was on closes leaving all inputs closed until
    the next input is opened at the level it reaches.
    .
    . Elevator All Switches Normally closed
    . Up
    .5v
    .____.
    >f3 in series with F3
    .
    . Down
    .5v
    .____.
    >f1 ( in series with F1
    ................................................
    . Floor 3
    . Toggles elev. up Stop
    . ( a.) ( b. )
    . (F3)>----.___.
    .___.
    > input X
    .......................................
    . Floor 2 If X=0 Toggles down
    . If Z=0 toggles up stop
    . (a.) ( b. )
    . 5v >----.___.
    .___.
    > input Y
    .......................................
    . Floor 1
    . Toggle down Stop
    . ( a.) ( b. )
    . (F1) >----.___.
    .___.
    > input Z

    I hope this isn't to confusing, any help would be gratefully
    appreciated. Terry O.


    --- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...> wrote:
    > Going bald
    >
    > For the life of me I can't seem to get the hang of writing a
    program
    > for the stamp! At first it appeared as though it would be simple to
    > control two relays with three switches right ! ( have very few
    hairs
    > left to pullout ). Was easier to build a logic circuit with a
    couple
    > of JK flip-flops, and a few AND gates yet would like to see just
    > what a stamp can do to save parts and a lot of wiring. 20 plus
    years
    > ago enjoyed playing around with the old basic on a VIC 20 now
    trying
    > to relearn all this Greek or Latin ( Pbasic ) What I would like to
    do
    > is simply toggle the state of two outputs depending on, the on or
    off
    > state of the same 2 outputs and 3 inputs ( switches ), with the
    > following rules.
    >
    > Must start with outputs =0
    >
    > Output X and Y can never be toggled on at the same time
    >
    > Output X can never go on if switch 1 is already on, but can
    toggle
    > X on if first was off
    >
    > Same applies to to output Y and switch 2
    >
    > Switch 3 toggles off X or Y first if X or Y =on
    > or allow X on only if switch 3 is on
    > or allow Y on only if switch 1 is on
    >
    > Can anyone help?
    >
    > P.S.
    > Will purchase the first Pbasic ( Greek ) for Dummies!
    >
    > Looking for software that will convert a logic circuit to stamp
    > program ( Un-Greek-tified ) or similar.
    >
    > Thanks T.O.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-27 18:26
    Yes, I Now have No Hair Reading this !!

    At 12:36 AM 1/27/2004 +0000, you wrote:
    >I apologize for not providing enough info the first time, the few
    >hairs I had on top are now gone and I'm still unable program my stamp
    >II to work the way I'd like and replace my logic circuit.
    >The present logic circuit I've created controls a 3 level elevator.
    >The top and bottom levels each have two switches with two additional
    >switch in the elevator wired in series ( see below ) with first and
    >third level input. All are normally closed type switches. The center
    >floor has 2 switches wired in series connected to a third input. The
    >two outputs control a pair of opt-triac that provide up down action.
    >On start-up one of any single (b.) switch will normally be open
    >depending on location of elevator. Both outputs must be off on power
    >up. F3(b.) and F1(b.) prohibits elevator from going beyond that
    >level. Please not, the (a) switches toggle its correspond outputs on
    >as long as both outputs are off , and what other (b) switch is open
    >determines what direction (output to turn on ). Once elevator is in
    >motion the (b.) switch it was stopped on automatically closes before
    >the next floor allowing the (b) switch to open and toggles elevator
    >to stop if output is on. Please note, based on what floor elevator is
    >on, Y input is the only input that can allow one or the other outputs
    >to go on but never at the same time.
    > My logic circuit allows the following:
    >U=0 and D=0 ` when first turned on
    >If X input =1 and Y =1 and elevator is stopped outputs =0, elevator
    >is at Z (Z=0), with input Z open, X or Y must not allow Doutput on
    >ever.
    >If X input =1 and Y=0 and Z=1, elevator is at Y (level 2). Note
    >with Y input open X(a) or Z(a) can still page elevator when one or
    >the other opens then closes starting elevator in that direction. When
    >that input again opens, elevator stops on that floor.
    >
    >Paging Elevator
    > with input Y open, X (a) or Z (a)inputs when one or the other is
    >toggled allow elevator back on, X input toggled for Up, Z input
    >toggled for Down. When elevator reaches the corresponding (b) switch
    >opens turning output off.
    > No output can ever be on at same time.
    > Also note once elevator is toggled in the correct direction and in
    >motion that level it was on closes leaving all inputs closed until
    >the next input is opened at the level it reaches.
    >.
    >. Elevator All Switches Normally closed
    >. Up
    >.5v
    .____.
    >f3 in series with F3
    >.
    >. Down
    >.5v
    .____.
    >f1 ( in series with F1
    >................................................
    >. Floor 3
    >. Toggles elev. up Stop
    >. ( a.) ( b. )
    >. (F3)>----.___.
    .___.
    > input X
    >.......................................
    >. Floor 2 If X=0 Toggles down
    >. If Z=0 toggles up stop
    >. (a.) ( b. )
    >. 5v >----.___.
    .___.
    > input Y
    >.......................................
    >. Floor 1
    >. Toggle down Stop
    >. ( a.) ( b. )
    >. (F1) >----.___.
    .___.
    > input Z
    >
    >I hope this isn't to confusing, any help would be gratefully
    >appreciated. Terry O.
    >
    >
    >--- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...> wrote:
    > > Going bald
    > >
    > > For the life of me I can't seem to get the hang of writing a
    >program
    > > for the stamp! At first it appeared as though it would be simple to
    > > control two relays with three switches right ! ( have very few
    >hairs
    > > left to pullout ). Was easier to build a logic circuit with a
    >couple
    > > of JK flip-flops, and a few AND gates yet would like to see just
    > > what a stamp can do to save parts and a lot of wiring. 20 plus
    >years
    > > ago enjoyed playing around with the old basic on a VIC 20 now
    >trying
    > > to relearn all this Greek or Latin ( Pbasic ) What I would like to
    >do
    > > is simply toggle the state of two outputs depending on, the on or
    >off
    > > state of the same 2 outputs and 3 inputs ( switches ), with the
    > > following rules.
    > >
    > > Must start with outputs =0
    > >
    > > Output X and Y can never be toggled on at the same time
    > >
    > > Output X can never go on if switch 1 is already on, but can
    >toggle
    > > X on if first was off
    > >
    > > Same applies to to output Y and switch 2
    > >
    > > Switch 3 toggles off X or Y first if X or Y =on
    > > or allow X on only if switch 3 is on
    > > or allow Y on only if switch 1 is on
    > >
    > > Can anyone help?
    > >
    > > P.S.
    > > Will purchase the first Pbasic ( Greek ) for Dummies!
    > >
    > > Looking for software that will convert a logic circuit to stamp
    > > program ( Un-Greek-tified ) or similar.
    > >
    > > Thanks T.O.
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-28 04:21
    Reading this my hair starts to grow again.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-28 17:48
    Hey Terry, Hows it going. I designed one these elevator systems way back
    when i was programming the Allen Bradley PLC at ITT Tech. it was fun if you
    ever played with one of those (Ladder Logic). However Things have changed
    since the STAMP. its no longer necessary to have switches in series
    anymore. your a logic thinker and if you think you have no hair now just
    wait until you read the program. first of all the BS2 has 16 I/O lines and
    we should utilize this! the elevator system i designed has 9 inputs and 2
    outputs. read the program and notes in the program for details. hope its
    PBasic Legible !! email if you need assistance. and to those you are
    experts in Pbasic you probably know of a way to shrink my variables but
    this is how i understand the program. Thanks and good luck

    Gary Denison
    Kyocera Wireless Corp.

    PROGRAM
    \



    '{$STAMP BS2}


    'IN0 = Floor 1 Sensor
    'IN1 = floor 2 sensor
    'IN2 = Floor 3 sensor
    'IN3 = Floor 1 Call Button 'Table so you dont get a headache !!!!
    'IN4 = Floor 2 Call Button
    'IN5 = Floor 3 Call Button
    'IN6 = Elevator Floor Select (Floor 1)
    'IN7 = Elevator Floor Select (Floor 2)
    'IN8 = Elevator Floor Select (Floor 3)
    'IN9 = down Output control
    'IN10 = up Output control

    'Basically this program is designed to work like an elevator system. the
    elevator will start at
    'floor 1 by default on power up. In This System There are a total of 9
    inputs and 2 outputs.
    'There is a call button on each floor (3). inside the elevator there are
    three inputs to select
    'the floor you want. Note: you cannot select the floor your already on. and
    there are 3 sensors
    'to indicate what floor the elevator is positioned at. the call BUTTON only
    calls the elevator,
    'once you get in the elevator you can select any floor you want. Example,
    if your on floor 3 and
    'press the call button, you get in the elevator and press floor 1 button
    you will go to floor 1,
    'FURTHERMORE, If someone on floor 2 presses the call button while the
    elevator is going down and
    'the elevator has NOT passed the floor 2 sensor it will stop on floor 2 for
    5 sec and continue
    'until floor 1 sensor goes LOW(0)

    'All Switches are Normally high, see the
    'command BUTTON in the help menu for wiring.

    'Caution !! the program below uses EXTENSIVE
    ' INPUT and OUPUT commands
    ' refer To the table above before you GET A HEADACHE

    Initialize
    LOW 10
    HIGH 9
    loop1 ' Gets elevator to floor 1
    start point
    IF IN0 = 1 THEN loop1
    LOW 9

    get_position
    IF IN0 = 0 THEN floor_1
    IF IN1 = 0 THEN floor_2
    IF IN2 = 0 THEN floor_3
    GOTO get_position

    floor_1
    IF IN4 = 0 OR IN7 = 0 THEN upfloor2
    IF IN5 = 0 OR IN8 = 0 THEN upfloor3
    GOTO floor_1

    floor_2
    IF IN3 = 0 OR IN6 = 0 THEN dwnfloor1
    IF IN5 = 0 OR IN8 = 0 THEN upfloor3
    GOTO floor_2

    floor_3
    IF IN3 = 0 OR IN6 = 0 THEN dwnfloor1
    IF IN4 = 0 OR IN7 = 0 THEN dwnfloor2
    GOTO floor_3

    dwnfloor1
    LOW 10
    HIGH 9
    loop2
    IF IN4 = 0 THEN interupt2
    IF IN0 = 1 THEN loop2
    LOW 9
    GOTO get_position

    dwnfloor2
    LOW 10
    HIGH 9
    loop3
    IF IN1 = 0 THEN loop3
    LOW 9
    GOTO get_position

    upfloor3
    LOW 9
    HIGH 10
    loop4
    IF IN4 = 0 THEN interupt1
    IF IN2 = 1 THEN loop4
    LOW 10
    GOTO get_position

    upfloor2
    LOW 9
    HIGH 10
    loop5
    IF IN1 = 1 THEN loop5
    LOW 10
    GOTO get_position

    Interupt1
    IF in2 = 0 THEN upfloor3
    IF IN1 = 1 THEN interupt1 'this will stop on floor 2
    LOW 9 'on its way up to floor 3
    LOW 10
    PAUSE 5000
    GOTO upfloor3

    interupt2
    IF = 0 THEN dwnfloor1
    IF IN1 = 1 THEN interupt2 'this will stop on floor 2 on its
    LOW 9 'way down to floor 1
    LOW 10
    PAUSE 5000
    GOTO dwnfloor1


    End Of Program


    --- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...> wrote:
    > I apologize for not providing enough info the first time, the few
    > hairs I had on top are now gone and I'm still unable program my stamp
    > II to work the way I'd like and replace my logic circuit.
    > The present logic circuit I've created controls a 3 level elevator.
    > The top and bottom levels each have two switches with two additional
    > switch in the elevator wired in series ( see below ) with first and
    > third level input. All are normally closed type switches. The center
    > floor has 2 switches wired in series connected to a third input. The
    > two outputs control a pair of opt-triac that provide up down action.
    > On start-up one of any single (b.) switch will normally be open
    > depending on location of elevator. Both outputs must be off on power
    > up. F3(b.) and F1(b.) prohibits elevator from going beyond that
    > level. Please not, the (a) switches toggle its correspond outputs on
    > as long as both outputs are off , and what other (b) switch is open
    > determines what direction (output to turn on ). Once elevator is in
    > motion the (b.) switch it was stopped on automatically closes before
    > the next floor allowing the (b) switch to open and toggles elevator
    > to stop if output is on. Please note, based on what floor elevator is
    > on, Y input is the only input that can allow one or the other outputs
    > to go on but never at the same time.
    > My logic circuit allows the following:
    > U=0 and D=0 ` when first turned on
    > If X input =1 and Y =1 and elevator is stopped outputs =0, elevator
    > is at Z (Z=0), with input Z open, X or Y must not allow Doutput on
    > ever.
    > If X input =1 and Y=0 and Z=1, elevator is at Y (level 2). Note
    > with Y input open X(a) or Z(a) can still page elevator when one or
    > the other opens then closes starting elevator in that direction. When
    > that input again opens, elevator stops on that floor.
    >
    > Paging Elevator
    > with input Y open, X (a) or Z (a)inputs when one or the other is
    > toggled allow elevator back on, X input toggled for Up, Z input
    > toggled for Down. When elevator reaches the corresponding (b) switch
    > opens turning output off.
    > No output can ever be on at same time.
    > Also note once elevator is toggled in the correct direction and in
    > motion that level it was on closes leaving all inputs closed until
    > the next input is opened at the level it reaches.
    > .
    > . Elevator All Switches Normally closed
    > . Up
    > .5v
    .____.
    >f3 in series with F3
    > .
    > . Down
    > .5v
    .____.
    >f1 ( in series with F1
    > ................................................
    > . Floor 3
    > . Toggles elev. up Stop
    > . ( a.) ( b. )
    > . (F3)>----.___.
    .___.
    > input X
    > .......................................
    > . Floor 2 If X=0 Toggles down
    > . If Z=0 toggles up stop
    > . (a.) ( b. )
    > . 5v >----.___.
    .___.
    > input Y
    > .......................................
    > . Floor 1
    > . Toggle down Stop
    > . ( a.) ( b. )
    > . (F1) >----.___.
    .___.
    > input Z
    >
    > I hope this isn't to confusing, any help would be gratefully
    > appreciated. Terry O.
    >
    >
    > --- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...> wrote:
    > > Going bald
    > >
    > > For the life of me I can't seem to get the hang of writing a
    > program
    > > for the stamp! At first it appeared as though it would be simple to
    > > control two relays with three switches right ! ( have very few
    > hairs
    > > left to pullout ). Was easier to build a logic circuit with a
    > couple
    > > of JK flip-flops, and a few AND gates yet would like to see just
    > > what a stamp can do to save parts and a lot of wiring. 20 plus
    > years
    > > ago enjoyed playing around with the old basic on a VIC 20 now
    > trying
    > > to relearn all this Greek or Latin ( Pbasic ) What I would like to
    > do
    > > is simply toggle the state of two outputs depending on, the on or
    > off
    > > state of the same 2 outputs and 3 inputs ( switches ), with the
    > > following rules.
    > >
    > > Must start with outputs =0
    > >
    > > Output X and Y can never be toggled on at the same time
    > >
    > > Output X can never go on if switch 1 is already on, but can
    > toggle
    > > X on if first was off
    > >
    > > Same applies to to output Y and switch 2
    > >
    > > Switch 3 toggles off X or Y first if X or Y =on
    > > or allow X on only if switch 3 is on
    > > or allow Y on only if switch 1 is on
    > >
    > > Can anyone help?
    > >
    > > P.S.
    > > Will purchase the first Pbasic ( Greek ) for Dummies!
    > >
    > > Looking for software that will convert a logic circuit to stamp
    > > program ( Un-Greek-tified ) or similar.
    > >
    > > Thanks T.O.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-30 18:16
    Thanks Gary

    This will be a big help to me now trying to learn this pbasic
    language. To save chips and wiring with my first logic circuit, my
    goal, became a challenge to cut down on switches and wiring. ( 28 IC
    chips with 9 inputs 2 outputs). My present logic circuit consists of
    a total of only 5 IC with only 3 inputs 2 outputs needed. I still
    hope someday to incorporate a smaller circuit with the least amount
    switches and wiring. Any additional input as always will be greatly
    appreciated .

    Terry O.


    --- In basicstamps@yahoogroups.com, Gary Denison <gdii@c...> wrote:

    > Hey Terry, Hows it going. I designed one these elevator systems way
    back when i was programming the Allen Bradley PLC at ITT Tech. it was
    fun if you ever played with one of those (Ladder Logic). However
    Things have changed since the STAMP. its no longer necessary to have
    switches in series anymore. your a logic thinker and if you think you
    have no hair now just wait until you read the program. first of all
    the BS2 has 16 I/O lines and we should utilize this! the elevator
    system i designed has 9 inputs and 2 outputs. read the program and
    notes in the program for details. hope its PBasic Legible !! email if
    you need assistance. and to those you are experts in Pbasic you
    probably know of a way to shrink my variables but this is how i
    understand the program. Thanks and good luck
    >
    > Gary Denison
    > Kyocera Wireless Corp.
    >
    >
    PROGRAM

    > '{$STAMP BS2}

    >
    > 'IN0 = Floor 1 Sensor
    > 'IN1 = floor 2 sensor
    > 'IN2 = Floor 3 sensor
    > 'IN3 = Floor 1 Call Button 'Table so you dont get a headache !!!!
    > 'IN4 = Floor 2 Call Button
    > 'IN5 = Floor 3 Call Button
    > 'IN6 = Elevator Floor Select (Floor 1)
    > 'IN7 = Elevator Floor Select (Floor 2)
    > 'IN8 = Elevator Floor Select (Floor 3)
    > 'IN9 = down Output control
    > 'IN10 = up Output control
    >
    > 'Basically this program is designed to work like an elevator
    system. the elevator will start at
    > 'floor 1 by default on power up. In This System There are a total
    of 9 inputs and 2 outputs.
    > 'There is a call button on each floor (3). inside the elevator
    there are three inputs to select
    > 'the floor you want. Note: you cannot select the floor your already
    on. and there are 3 sensors
    > 'to indicate what floor the elevator is positioned at. the call
    BUTTON only
    > calls the elevator,
    > 'once you get in the elevator you can select any floor you want.
    Example,
    > if your on floor 3 and
    > 'press the call button, you get in the elevator and press floor 1
    button you will go to floor 1,
    > 'FURTHERMORE, If someone on floor 2 presses the call button while
    the elevator is going down and
    > 'the elevator has NOT passed the floor 2 sensor it will stop on
    floor 2 for 5 sec and continue
    > 'until floor 1 sensor goes LOW(0)
    >
    > 'All Switches are Normally high, see the
    > 'command BUTTON in the help menu for wiring.
    >
    > 'Caution !! the program below uses EXTENSIVE
    > ' INPUT and OUPUT commands
    > ' refer To the table above before you GET A
    HEADACHE
    >
    > Initialize
    > LOW 10
    > HIGH 9
    > loop1 ' Gets elevator to floor 1
    > start point
    > IF IN0 = 1 THEN loop1
    > LOW 9
    >
    > get_position
    > IF IN0 = 0 THEN floor_1
    > IF IN1 = 0 THEN floor_2
    > IF IN2 = 0 THEN floor_3
    > GOTO get_position
    >
    > floor_1
    > IF IN4 = 0 OR IN7 = 0 THEN upfloor2
    > IF IN5 = 0 OR IN8 = 0 THEN upfloor3
    > GOTO floor_1
    >
    > floor_2
    > IF IN3 = 0 OR IN6 = 0 THEN dwnfloor1
    > IF IN5 = 0 OR IN8 = 0 THEN upfloor3
    > GOTO floor_2
    >
    > floor_3
    > IF IN3 = 0 OR IN6 = 0 THEN dwnfloor1
    > IF IN4 = 0 OR IN7 = 0 THEN dwnfloor2
    > GOTO floor_3
    >
    > dwnfloor1
    > LOW 10
    > HIGH 9
    > loop2
    > IF IN4 = 0 THEN interupt2
    > IF IN0 = 1 THEN loop2
    > LOW 9
    > GOTO get_position
    >
    > dwnfloor2
    > LOW 10
    > HIGH 9
    > loop3
    > IF IN1 = 0 THEN loop3
    > LOW 9
    > GOTO get_position
    >
    > upfloor3
    > LOW 9
    > HIGH 10
    > loop4
    > IF IN4 = 0 THEN interupt1
    > IF IN2 = 1 THEN loop4
    > LOW 10
    > GOTO get_position
    >
    > upfloor2
    > LOW 9
    > HIGH 10
    > loop5
    > IF IN1 = 1 THEN loop5
    > LOW 10
    > GOTO get_position
    >
    > Interupt1
    > IF in2 = 0 THEN upfloor3
    > IF IN1 = 1 THEN interupt1 'this will stop on floor 2
    > LOW 9 'on its way up to floor 3
    > LOW 10
    > PAUSE 5000
    > GOTO upfloor3
    >
    > interupt2
    > IF = 0 THEN dwnfloor1
    > IF IN1 = 1 THEN interupt2 'this will stop on floor 2 on its
    > LOW 9 'way down to floor 1
    > LOW 10
    > PAUSE 5000
    > GOTO dwnfloor1
    >
    >
    >
    End Of Program
    >
    >
    > --- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...>
    wrote:
    > > I apologize for not providing enough info the first time, the few
    > > hairs I had on top are now gone and I'm still unable program my
    stamp
    > > II to work the way I'd like and replace my logic circuit.
    > > The present logic circuit I've created controls a 3 level
    elevator.
    > > The top and bottom levels each have two switches with two
    additional
    > > switch in the elevator wired in series ( see below ) with first
    and
    > > third level input. All are normally closed type switches. The
    center
    > > floor has 2 switches wired in series connected to a third input.
    The
    > > two outputs control a pair of opt-triac that provide up down
    action.
    > > On start-up one of any single (b.) switch will normally be open
    > > depending on location of elevator. Both outputs must be off on
    power
    > > up. F3(b.) and F1(b.) prohibits elevator from going beyond that
    > > level. Please not, the (a) switches toggle its correspond
    outputs on
    > > as long as both outputs are off , and what other (b) switch is
    open
    > > determines what direction (output to turn on ). Once elevator is
    in
    > > motion the (b.) switch it was stopped on automatically closes
    before
    > > the next floor allowing the (b) switch to open and toggles
    elevator
    > > to stop if output is on. Please note, based on what floor
    elevator is
    > > on, Y input is the only input that can allow one or the other
    outputs
    > > to go on but never at the same time.
    > > My logic circuit allows the following:
    > > U=0 and D=0 ` when first turned on
    > > If X input =1 and Y =1 and elevator is stopped outputs =0,
    elevator
    > > is at Z (Z=0), with input Z open, X or Y must not allow Doutput
    on
    > > ever.
    > > If X input =1 and Y=0 and Z=1, elevator is at Y (level 2). Note
    > > with Y input open X(a) or Z(a) can still page elevator when one
    or
    > > the other opens then closes starting elevator in that direction.
    When
    > > that input again opens, elevator stops on that floor.
    > >
    > > Paging Elevator
    > > with input Y open, X (a) or Z (a)inputs when one or the other
    is
    > > toggled allow elevator back on, X input toggled for Up, Z input
    > > toggled for Down. When elevator reaches the corresponding (b)
    switch
    > > opens turning output off.
    > > No output can ever be on at same time.
    > > Also note once elevator is toggled in the correct direction
    and in
    > > motion that level it was on closes leaving all inputs closed
    until
    > > the next input is opened at the level it reaches.
    > > .
    > > . Elevator All Switches Normally closed
    > > . Up
    > > .5v
    .____.
    >f3 in series with F3
    > > .
    > > . Down
    > > .5v
    .____.
    >f1 ( in series with F1
    > > ................................................
    > > . Floor 3
    > > . Toggles elev. up Stop
    > > . ( a.) ( b. )
    > > . (F3)>----.___.
    .___.
    > input X
    > > .......................................
    > > . Floor 2 If X=0 Toggles down
    > > . If Z=0 toggles up stop
    > > . (a.) ( b. )
    > > . 5v >----.___.
    .___.
    > input Y
    > > .......................................
    > > . Floor 1
    > > . Toggle down Stop
    > > . ( a.) ( b. )
    > > . (F1) >----.___.
    .___.
    > input Z
    > >
    > > I hope this isn't to confusing, any help would be gratefully
    > > appreciated. Terry O.
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "tloleksy" <tloleksy@y...>
    wrote:
    > > > Going bald
    > > >
    > > > For the life of me I can't seem to get the hang of writing a
    > > program
    > > > for the stamp! At first it appeared as though it would be
    simple to
    > > > control two relays with three switches right ! ( have very few
    > > hairs
    > > > left to pullout ). Was easier to build a logic circuit with a
    > > couple
    > > > of JK flip-flops, and a few AND gates yet would like to see
    just
    > > > what a stamp can do to save parts and a lot of wiring. 20 plus
    > > years
    > > > ago enjoyed playing around with the old basic on a VIC 20 now
    > > trying
    > > > to relearn all this Greek or Latin ( Pbasic ) What I would
    like to
    > > do
    > > > is simply toggle the state of two outputs depending on, the on
    or
    > > off
    > > > state of the same 2 outputs and 3 inputs ( switches ), with the
    > > > following rules.
    > > >
    > > > Must start with outputs =0
    > > >
    > > > Output X and Y can never be toggled on at the same time
    > > >
    > > > Output X can never go on if switch 1 is already on, but can
    > > toggle
    > > > X on if first was off
    > > >
    > > > Same applies to to output Y and switch 2
    > > >
    > > > Switch 3 toggles off X or Y first if X or Y =on
    > > > or allow X on only if switch 3 is on
    > > > or allow Y on only if switch 1 is on
    > > >
    > > > Can anyone help?
    > > >
    > > > P.S.
    > > > Will purchase the first Pbasic ( Greek ) for Dummies!
    > > >
    > > > Looking for software that will convert a logic circuit to stamp
    > > > program ( Un-Greek-tified ) or similar.
    > > >
    > > > Thanks T.O.
Sign In or Register to comment.