Shop OBEX P1 Docs P2 Docs Learn Events
Help on ins and outs please... — Parallax Forums

Help on ins and outs please...

ArchiverArchiver Posts: 46,084
edited 2002-11-14 02:57 in General Discussion
I'm going through a refresher on pbasic. It's been a while. I am
trying to write a program that will control several sets of christmas
lights to "dance" in intricate patterns with a 9 minute musical piece.

The music, as it is playing, will be run through a VU type circuit,
two lines of which will be tied to two input pins of the stamp. Using
a high and low threshold on those two lines, I will be able to pick
up occasional synchronous beats from the music to re-synchronize the
program to the music and simplify programming in chunks... to be put
together at a later date.

I'm working with a BS2 at present and may have to go to the SX for
more space.

Anyway... I don't remember how to output a set of 1's and 0's to a
bank of output pins simultaneously. I would like to connect circuitry
to six output pins which will drive six individual lines of christmas
lights. I need parallel communication out. I just don't remember how!

I would like to display a six bit patterns on their respective pins,
turning on individual or multiple strands of lights.

Can anyone slap me around a bit here and jog my memory on how to do
this please?!

Thank you!

Ross

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 14:00
    Are you sure you need real parallel? If you just did

    high 1
    low 2
    low 3
    high 4
    high 5
    high 6

    It would happen serially but so flippin fast you'd never be able to tell it
    wasn't parallel.
    Original Message
    From: "rossfree" <rfreeman@w...>
    To: <basicstamps@yahoogroups.com>
    Sent: Tuesday, November 12, 2002 5:34 AM
    Subject: [noparse][[/noparse]basicstamps] Help on ins and outs please...


    > I'm going through a refresher on pbasic. It's been a while. I am
    > trying to write a program that will control several sets of christmas
    > lights to "dance" in intricate patterns with a 9 minute musical piece.
    >
    > The music, as it is playing, will be run through a VU type circuit,
    > two lines of which will be tied to two input pins of the stamp. Using
    > a high and low threshold on those two lines, I will be able to pick
    > up occasional synchronous beats from the music to re-synchronize the
    > program to the music and simplify programming in chunks... to be put
    > together at a later date.
    >
    > I'm working with a BS2 at present and may have to go to the SX for
    > more space.
    >
    > Anyway... I don't remember how to output a set of 1's and 0's to a
    > bank of output pins simultaneously. I would like to connect circuitry
    > to six output pins which will drive six individual lines of christmas
    > lights. I need parallel communication out. I just don't remember how!
    >
    > I would like to display a six bit patterns on their respective pins,
    > turning on individual or multiple strands of lights.
    >
    > Can anyone slap me around a bit here and jog my memory on how to do
    > this please?!
    >
    > Thank you!
    >
    > Ross
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 14:25
    Are you looking for OUTS (and its variants for bytes and nibbles). Check
    out the description in the BS2 memory map section of the manual--in the v1.9
    book, its on pages 214-216.

    HTH,
    Daniel

    >
    Original Message
    > From: rossfree [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=U7akOINaMDdi-ZuQlLUoZM8cz_iQYTIzY3pjT8SX1nvXDLXKxPju9yxINPbF0e0PyJBv8QtoaCPvnIX2k7i32SA-KJ2Fmw]rfreeman@w...[/url
    > Sent: Tuesday, 12 November 2002 08:34
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Help on ins and outs please...
    >
    >
    > I'm going through a refresher on pbasic. It's been a while. I am
    > trying to write a program that will control several sets of christmas
    > lights to "dance" in intricate patterns with a 9 minute musical piece.
    >
    > The music, as it is playing, will be run through a VU type circuit,
    > two lines of which will be tied to two input pins of the stamp. Using
    > a high and low threshold on those two lines, I will be able to pick
    > up occasional synchronous beats from the music to re-synchronize the
    > program to the music and simplify programming in chunks... to be put
    > together at a later date.
    >
    > I'm working with a BS2 at present and may have to go to the SX for
    > more space.
    >
    > Anyway... I don't remember how to output a set of 1's and 0's to a
    > bank of output pins simultaneously. I would like to connect circuitry
    > to six output pins which will drive six individual lines of christmas
    > lights. I need parallel communication out. I just don't remember how!
    >
    > I would like to display a six bit patterns on their respective pins,
    > turning on individual or multiple strands of lights.
    >
    > Can anyone slap me around a bit here and jog my memory on how to do
    > this please?!
    >
    > Thank you!
    >
    > Ross
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 15:02
    The outputs can be addressed in parrallel with the following commands:

    OUTL = %11110000 ;makes pins 0 ~ 3 low and 4 ~ 7 high
    OUTH = %11110000 ;makes pins 8 ~ 11 low and 12 ~ 16 high
    OUTA = %1111 ;makes pins - ~ 3 high
    OUTB will address pins 4 ~ 7
    OUTC will address pins 8 ~ 11
    OUTD will address pins 12 ~ 16

    This will allow you to send out one command and adress 4, 8 or even 16 pins
    (uses OUTS to address all 16 pins of the BS2, but then there are no pins left
    for input).

    This is less typing and faster code than addressing each pin individually.

    I hope this helps.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 15:12
    After reading your message again, to send out a parrallel set of bits, (see
    my other posting on what the commands are) you can only address a bank of 4,
    8 or 16 pins at a time.
    A possible solution is to do the following:
    Suppose your 12 outputs are pins 0 through 11 with the first bank of LED pins
    0 ~ 5, and the second bank of leds pins 6 ~ 11.

    If the first two leds on the second bank (pins 6 & 7 ) are currently low and
    you want to keep them that way, and alter pins 0 ~ 5, you can send the
    command
    OUTSL = %00xxxxxx ;where the x's are the bits you want to change (pins 0 ~
    5, set to 1 or 0) and bits 6 & 7 (the leds from the second bank you don't
    want to change) will remain low.
    Write back if you need more clarification

    smartdim@a...


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 18:04
    Thanks for getting back...

    I need to write a more compacted code. Spelling it out line by line
    would eat the five hundred max lines I have available on the BS2.

    Ross

    --- In basicstamps@y..., PM <pmeloy@s...> wrote:
    > Are you sure you need real parallel? If you just did
    >
    > high 1
    > low 2
    > low 3
    > high 4
    > high 5
    > high 6
    >
    > It would happen serially but so flippin fast you'd never be able to
    tell it
    > wasn't parallel.
    >
    Original Message
    > From: "rossfree" <rfreeman@w...>
    > To: <basicstamps@y...>
    > Sent: Tuesday, November 12, 2002 5:34 AM
    > Subject: [noparse][[/noparse]basicstamps] Help on ins and outs please...
    >
    >
    > > I'm going through a refresher on pbasic. It's been a while. I am
    > > trying to write a program that will control several sets of
    christmas
    > > lights to "dance" in intricate patterns with a 9 minute musical
    piece.
    > >
    > > The music, as it is playing, will be run through a VU type
    circuit,
    > > two lines of which will be tied to two input pins of the stamp.
    Using
    > > a high and low threshold on those two lines, I will be able to
    pick
    > > up occasional synchronous beats from the music to re-synchronize
    the
    > > program to the music and simplify programming in chunks... to be
    put
    > > together at a later date.
    > >
    > > I'm working with a BS2 at present and may have to go to the SX for
    > > more space.
    > >
    > > Anyway... I don't remember how to output a set of 1's and 0's to a
    > > bank of output pins simultaneously. I would like to connect
    circuitry
    > > to six output pins which will drive six individual lines of
    christmas
    > > lights. I need parallel communication out. I just don't remember
    how!
    > >
    > > I would like to display a six bit patterns on their respective
    pins,
    > > turning on individual or multiple strands of lights.
    > >
    > > Can anyone slap me around a bit here and jog my memory on how to
    do
    > > this please?!
    > >
    > > Thank you!
    > >
    > > Ross
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@y...
    > > from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 19:41
    >Thanks for getting back...
    >
    >I need to write a more compacted code. Spelling it out line by line
    >would eat the five hundred max lines I have available on the BS2.
    >
    >Ross
    >
    >--- In basicstamps@y..., PM <pmeloy@s...> wrote:
    >> Are you sure you need real parallel? If you just did
    >>
    >> high 1
    >> low 2
    >> low 3
    >> high 4
    >> high 5
    >> high 6
    >>
    >> It would happen serially but so flippin fast you'd never be able to
    >tell it
    >> wasn't parallel.
    >>
    Original Message
    >> From: "rossfree" <rfreeman@w...>
    >> To: <basicstamps@y...>
    >> Sent: Tuesday, November 12, 2002 5:34 AM
    >> Subject: [noparse][[/noparse]basicstamps] Help on ins and outs please...
    >>
    >>
    >> > I'm going through a refresher on pbasic. It's been a while. I am
    >> > trying to write a program that will control several sets of
    >christmas
    >> > lights to "dance" in intricate patterns with a 9 minute musical
    >piece.
    >> >
    >> > The music, as it is playing, will be run through a VU type
    >circuit,
    >> > two lines of which will be tied to two input pins of the stamp.
    >Using
    >> > a high and low threshold on those two lines, I will be able to
    >pick
    >> > up occasional synchronous beats from the music to re-synchronize
    >the
    >> > program to the music and simplify programming in chunks... to be
    >put
    >> > together at a later date.
    >> >
    >> > I'm working with a BS2 at present and may have to go to the SX for
    >> > more space.
    >> >
    >> > Anyway... I don't remember how to output a set of 1's and 0's to a
    >> > bank of output pins simultaneously. I would like to connect
    >circuitry
    >> > to six output pins which will drive six individual lines of
    >christmas
    >> > lights. I need parallel communication out. I just don't remember
    >how!
    >> >
    >> > I would like to display a six bit patterns on their respective
    >pins,
    >> > turning on individual or multiple strands of lights.
    >> >
    >> > Can anyone slap me around a bit here and jog my memory on how to
    >do
    >> > this please?!
    >> >
    >> > Thank you!
    >> >
    >> > Ross
    >> >
    >> >
    >> > To UNSUBSCRIBE, just send mail to:
    >> > basicstamps-unsubscribe@y...
    >> > from the same email address that you subscribed. Text in the
    >Subject and
    >> Body of the message will be ignored.
    >> >
    >> >
    >> > Your use of Yahoo! Groups is subject to
    >http://docs.yahoo.com/info/terms/
    >> >
    >> >
    >
    >
    >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.
    >
    >
    >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 20:05
    OUTL = %11110000· ;makes pins 0 ~ 3 low and 4 ~ 7 high
    OUTH·· = %11110000 ;makes pins 8 ~ 11 low and 12 ~ 16 high
    OUTA = %1111·· ;makes pins - ~ 3 high
    OUTB will address pins 4 ~ 7
    OUTC will address pins 8 ~ 11
    OUTD will address pins 12 ~ 16

    This will allow you to send out one command and adress 4, 8 or even 16 pins
    (uses OUTS to address all 16 pins of the BS2, but then there are no pins left
    for input).

    This is less typing and faster code than addressing each pin individually.

    I hope this helps.
    AND
    After reading your message again, to send out a parrallel set of bits, (see
    my other posting on what the commands are) you can only address a bank of 4,
    8 or 16 pins at a time.
    A possible solution is to do the following:
    Suppose your 12 outputs are pins 0 through 11 with the first bank of LED pins
    0 ~ 5, and the second bank of leds pins 6 ~ 11.

    If the first two leds on the second bank (pins 6 & 7 ) are currently low and
    you want to keep them that way, and alter pins 0 ~ 5, you can send the
    command
    OUTSL = %00xxxxxx· ;where the x's are the bits you want to change (pins 0 ~
    5, set to 1 or 0) and bits 6 & 7 (the leds from the second bank you don't
    want to change) will remain low.
    Write back if you need more clarification

    smartdim@a...


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-12 21:35
    All good feedback... and I truly appreciate it.

    Let me tell what I am trying to do and see if this jives with those
    that know how to do it.

    I have a nine minute musical piece. I intend to write a program that
    will flash christmas lights in various patterns, each assigned to a
    different segment of the musical piece.

    The main trunk of the program will establish a tempo and then call
    subroutines one at a time... each subroutine will produce a pattern
    of flashing lights that may last from a couple of seconds to thirty
    seconds or so.

    It is important that the subroutine loops back to the main trunk
    where a it will track through one or two IF statements. Then it will
    go back to the subroutine and continue to loop.

    The IF statements might suggest a total number of loops before it
    progresses to the next section of the trunk, varying the tempo as
    needed and then calling a new subroutine (following the next section
    of the music).

    If I store my lighting patterns in the subroutines, I can easily call
    them later if desired without much fuss.

    I intended to write the program something like this:

    x var nib
    y var word
    z var byte
    tempo var byte
    loops var byte
    dirH = %11111100 'only output the six most significant digits

    loops = 0 'number of beats being counted
    tempo = 200 'adjustable as needed for program loop time

    MAIN:
    gosub PATTERN1
    if loops = 16 then goto SECTION2
    goto main

    SECTION2:
    end

    PATTERN1:
    lookup x,[noparse][[/noparse]127,191,223,239,247,251]y
    outl = y
    z = z + 1
    if z = tempo then x = x + 1 and z = 0 and loops = loops + 1
    if x = 6 then x = 0
    return

    In the "lookup" statement above, I call decimal numbers which when
    converted to binary will drive low one of the outputs on I/O pins 10
    thru 15. I think the least significant didgets will be truncated
    because they fall on I/O pins 8 and 9 which are stated as inputs. The
    lookup numbers above would pattern the lights to 'chase'.

    The beauty (if there is something that can be called beautiful here)
    is that each of the subroutines will look very much alike except that
    the lookup statements will change to drive the lights in different
    patterns. This should make writing the code fairly straight forward.

    Of course I do what to add in a few bells and whistles like fading
    and re-synchronizing to the beat(one of my inputs). But I think I can
    do it.

    I don't know if I can use all of those "and's" in the "if z"
    statement above.

    Ok all... nail me for my mistakes. I can take it!

    Ross




    --- In basicstamps@y..., smartdim@a... wrote:
    > OUTL = %11110000· ;makes pins 0 ~ 3 low and 4 ~ 7 high
    > OUTH·· = %11110000 ;makes pins 8 ~ 11 low and 12 ~ 16 high
    > OUTA = %1111·· ;makes pins - ~ 3 high
    > OUTB will address pins 4 ~ 7
    > OUTC will address pins 8 ~ 11
    > OUTD will address pins 12 ~ 16
    >
    > This will allow you to send out one command and adress 4, 8 or even
    16 pins
    > (uses OUTS to address all 16 pins of the BS2, but then there are no
    pins left
    > for input).
    >
    > This is less typing and faster code than addressing each pin
    individually.
    >
    > I hope this helps.
    > AND
    > After reading your message again, to send out a parrallel set of
    bits, (see
    > my other posting on what the commands are) you can only address a
    bank of 4,
    > 8 or 16 pins at a time.
    > A possible solution is to do the following:
    > Suppose your 12 outputs are pins 0 through 11 with the first bank
    of LED pins
    > 0 ~ 5, and the second bank of leds pins 6 ~ 11.
    >
    > If the first two leds on the second bank (pins 6 & 7 ) are
    currently low and
    > you want to keep them that way, and alter pins 0 ~ 5, you can send
    the
    > command
    > OUTSL = %00xxxxxx· ;where the x's are the bits you want to change
    (pins 0 ~
    > 5, set to 1 or 0) and bits 6 & 7 (the leds from the second bank you
    don't
    > want to change) will remain low.
    > Write back if you need more clarification
    >
    > smartdim@a...
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-14 02:57
    One way to produce very compact patterns is using DATA statements to
    save the patterns and then reconstructing the light patterns from the
    saved byte(s).

    The code for the Toddler robot uses these DATA patterns to good
    advantage. Look at the Advanced Robotics text (you can download it
    from Parallax) and you will find examples. Toddler stores a repeat
    count at the beginning of the table and uses an FF (255) for the end
    of the particular table. You can put a length byte at the front of
    the table if you need every possible pattern for the lights. Since it
    is music, a repeat count might be handy in your table as well. You
    can also read a given table multiple times from subroutines.

    Your code can take care of the timing of reading the DATA out.

    Another benefit is that is a lot easier to read and modify the
    patterns from data tables than from code.

    Sounds like a fun project!

    Harry
    www.bluebelldesign.com

    --- In basicstamps@y..., "rossfree" <rfreeman@w...> wrote:
    > All good feedback... and I truly appreciate it.
    >
    > Let me tell what I am trying to do and see if this jives with those
    > that know how to do it.
    >
    > I have a nine minute musical piece. I intend to write a program
    that
    > will flash christmas lights in various patterns, each assigned to a
    > different segment of the musical piece.
    >
    > The main trunk of the program will establish a tempo and then call
    > subroutines one at a time... each subroutine will produce a pattern
    > of flashing lights that may last from a couple of seconds to thirty
    > seconds or so.
    >
    > It is important that the subroutine loops back to the main trunk
    > where a it will track through one or two IF statements. Then it
    will
    > go back to the subroutine and continue to loop.
    >
    > The IF statements might suggest a total number of loops before it
    > progresses to the next section of the trunk, varying the tempo as
    > needed and then calling a new subroutine (following the next
    section
    > of the music).
    >
    > If I store my lighting patterns in the subroutines, I can easily
    call
    > them later if desired without much fuss.
    >
    > I intended to write the program something like this:
    >
    > x var nib
    > y var word
    > z var byte
    > tempo var byte
    > loops var byte
    > dirH = %11111100 'only output the six most significant digits
    >
    > loops = 0 'number of beats being counted
    > tempo = 200 'adjustable as needed for program loop time
    >
    > MAIN:
    > gosub PATTERN1
    > if loops = 16 then goto SECTION2
    > goto main
    >
    > SECTION2:
    > end
    >
    > PATTERN1:
    > lookup x,[noparse][[/noparse]127,191,223,239,247,251]y
    > outl = y
    > z = z + 1
    > if z = tempo then x = x + 1 and z = 0 and loops = loops + 1
    > if x = 6 then x = 0
    > return
    >
    > In the "lookup" statement above, I call decimal numbers which when
    > converted to binary will drive low one of the outputs on I/O pins
    10
    > thru 15. I think the least significant didgets will be truncated
    > because they fall on I/O pins 8 and 9 which are stated as inputs.
    The
    > lookup numbers above would pattern the lights to 'chase'.
    >
    > The beauty (if there is something that can be called beautiful
    here)
    > is that each of the subroutines will look very much alike except
    that
    > the lookup statements will change to drive the lights in different
    > patterns. This should make writing the code fairly straight
    forward.
    >
    > Of course I do what to add in a few bells and whistles like fading
    > and re-synchronizing to the beat(one of my inputs). But I think I
    can
    > do it.
    >
    > I don't know if I can use all of those "and's" in the "if z"
    > statement above.
    >
    > Ok all... nail me for my mistakes. I can take it!
    >
    > Ross
    >
    >
    >
    >
    > --- In basicstamps@y..., smartdim@a... wrote:
    > > OUTL = %11110000· ;makes pins 0 ~ 3 low and 4 ~ 7 high
    > > OUTH·· = %11110000 ;makes pins 8 ~ 11 low and 12 ~ 16 high
    > > OUTA = %1111·· ;makes pins - ~ 3 high
    > > OUTB will address pins 4 ~ 7
    > > OUTC will address pins 8 ~ 11
    > > OUTD will address pins 12 ~ 16
    > >
    > > This will allow you to send out one command and adress 4, 8 or
    even
    > 16 pins
    > > (uses OUTS to address all 16 pins of the BS2, but then there are
    no
    > pins left
    > > for input).
    > >
    > > This is less typing and faster code than addressing each pin
    > individually.
    > >
    > > I hope this helps.
    > > AND
    > > After reading your message again, to send out a parrallel set of
    > bits, (see
    > > my other posting on what the commands are) you can only address a
    > bank of 4,
    > > 8 or 16 pins at a time.
    > > A possible solution is to do the following:
    > > Suppose your 12 outputs are pins 0 through 11 with the first bank
    > of LED pins
    > > 0 ~ 5, and the second bank of leds pins 6 ~ 11.
    > >
    > > If the first two leds on the second bank (pins 6 & 7 ) are
    > currently low and
    > > you want to keep them that way, and alter pins 0 ~ 5, you can
    send
    > the
    > > command
    > > OUTSL = %00xxxxxx· ;where the x's are the bits you want to
    change
    > (pins 0 ~
    > > 5, set to 1 or 0) and bits 6 & 7 (the leds from the second bank
    you
    > don't
    > > want to change) will remain low.
    > > Write back if you need more clarification
    > >
    > > smartdim@a...
    > >
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.