Shop OBEX P1 Docs P2 Docs Learn Events
INL Command — Parallax Forums

INL Command

ArchiverArchiver Posts: 46,084
edited 2003-03-12 20:05 in General Discussion
Ok, I'm trying to get a good understanding of the INS,INL,INH
functions or commands in PBASIC or within the BS2SX IC. I'm trying
to continuously check the status of the first inputs(1-8) on the
activity board(Port X7). When 2 of the pins go high, I want to use
the IF...THEN statement to do other things. But I can't seem to
check the INL or the inputs correctly. Can someone help me with this
problem? Thank You

Another question, on the activity board, port X7 shows pins 1-20.
Does it really mean pins 0-19? ...like pin1 is really pin0 for
programming purposes??? Thanks...someone please help me out

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 13:42
    In a message dated 3/11/2003 7:37:55 PM Pacific Standard Time,
    the_prettiest@h... writes:

    > Ok, I'm trying to get a good understanding of the INS,INL,INH
    > functions or commands in PBASIC or within the BS2SX IC. I'm trying
    > to continuously check the status of the first inputs(1-8) on the
    > activity board(Port X7). When 2 of the pins go high, I want to use
    > the IF...THEN statement to do other things. But I can't seem to
    > check the INL or the inputs correctly. Can someone help me with this
    > problem? Thank You
    >
    > Another question, on the activity board, port X7 shows pins 1-20.
    > Does it really mean pins 0-19? ...like pin1 is really pin0 for
    > programming purposes??? Thanks...someone please help me out


    You want to do what is called bit masking.......

    Write and AND statement to check the bits that you want to view.

    example

    if you want to check bits 0 and 1 but actually looking at the first 8 bits
    (INL)

    My syntax is probably wrong, but the idea is this:

    Assing a variable to INL, for example Low_byte

    code:

    Low_byte = INL
    Low_byte = Low_byte AND 00000011

    Now perform your IF test on Low_byte

    If both bits of INL were high, Low_byte will equal 3 (decimal)

    If only bit 1 was high, Low_byte will equal 2.(decimal)

    If only bit 0 was high, Low_byte will equal 1.(decimal)

    Many other "stampers" will indeed correct my syntax if it is incorrect, and
    likely give you a better way to do it. This solution is only one of many.

    Ken



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 14:32
    --- In basicstamps@yahoogroups.com, smartdim@a... wrote:
    > In a message dated 3/11/2003 7:37:55 PM Pacific Standard Time,
    > the_prettiest@h... writes:
    >
    > > Ok, I'm trying to get a good understanding of the INS,INL,INH
    > > functions or commands in PBASIC or within the BS2SX IC. I'm
    trying
    > > to continuously check the status of the first inputs(1-8) on the
    > > activity board(Port X7). When 2 of the pins go high, I want to
    use
    > > the IF...THEN statement to do other things. But I can't seem to
    > > check the INL or the inputs correctly. Can someone help me with
    this
    > > problem? Thank You
    > >
    > > Another question, on the activity board, port X7 shows pins 1-
    20.
    > > Does it really mean pins 0-19? ...like pin1 is really pin0 for
    > > programming purposes??? Thanks...someone please help me out
    >
    >
    > You want to do what is called bit masking.......
    >
    > Write and AND statement to check the bits that you want to view.
    >
    > example
    >
    > if you want to check bits 0 and 1 but actually looking at the first
    8 bits
    > (INL)
    >
    > My syntax is probably wrong, but the idea is this:
    >
    > Assing a variable to INL, for example Low_byte
    >
    > code:
    >
    > Low_byte = INL
    > Low_byte = Low_byte AND 00000011
    >
    > Now perform your IF test on Low_byte
    >
    > If both bits of INL were high, Low_byte will equal 3 (decimal)
    >
    > If only bit 1 was high, Low_byte will equal 2.(decimal)
    >
    > If only bit 0 was high, Low_byte will equal 1.(decimal)
    >
    > Many other "stampers" will indeed correct my syntax if it is
    incorrect, and
    > likely give you a better way to do it. This solution is only one of
    many.
    >
    > Ken
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]

    Thanks Ken! This clears up a lot. So I must setup a variable that's
    equal to INL? Ok, I'm checking 8 inputs only. At any time, any one
    of those 8 inputs may go high, but only 2 go high at a time and they
    only stay high for 1 second before going back low. I must
    continuously read or check these inputs and make sure that I catch
    them when they go high. So, with this being the case, should I start
    out with something like:

    Low_Byte = INL
    Low_Byte = Low_Byte AND 11111111

    IF Low_Byte = 9 THEN Label-On 'Bits 0 and 3 go high

    Would this be correct? Would I need to use INA, INB, INC, IND? Thanks
    for your help...all of you...Thanks
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 15:01
    In a message dated 3/12/2003 6:34:31 AM Pacific Standard Time,
    the_prettiest@h... writes:

    > Thanks Ken! This clears up a lot. So I must setup a variable that's
    > equal to INL? Ok, I'm checking 8 inputs only. At any time, any one
    > of those 8 inputs may go high, but only 2 go high at a time and they
    > only stay high for 1 second before going back low. I must
    > continuously read or check these inputs and make sure that I catch
    > them when they go high. So, with this being the case, should I start
    > out with something like:
    >
    > Low_Byte = INL
    > Low_Byte = Low_Byte AND 11111111
    >
    > IF Low_Byte = 9 THEN Label-On 'Bits 0 and 3 go high
    >
    > Would this be correct? Would I need to use INA, INB, INC, IND? Thanks
    > for your help...all of you...Thanks
    >

    From what I see, you correctly understood my explanation.

    The example you listed will indeed check the status of all 8 bits, and you
    are correct when you stated:

    "IF Low_Byte = 9 THEN Label-On 'Bits 0 and 3 go high"

    You can use INA if you want to check only input pins 0 through 3. INB equates
    to input pins 4 through 7, INC = bits 8 ~ 11 and of course, IND = bits 12 ~
    15.

    Or, INL will check pins 0 ~ 7, INH is pins 8 ~ 15. (if I remember correclty -
    I don't use the stamp much these days)

    Also, since your "two pins" will remain high for only one second, you program
    loop should continuously check INL. The loop itself probably takes i500 to
    600 uS or less to complete, so you should have no problem "missing" the high
    state of both pins.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 15:20
    --- In basicstamps@yahoogroups.com, smartdim@a... wrote:
    > In a message dated 3/12/2003 6:34:31 AM Pacific Standard Time,
    > the_prettiest@h... writes:
    >
    > > Thanks Ken! This clears up a lot. So I must setup a variable
    that's
    > > equal to INL? Ok, I'm checking 8 inputs only. At any time, any
    one
    > > of those 8 inputs may go high, but only 2 go high at a time and
    they
    > > only stay high for 1 second before going back low. I must
    > > continuously read or check these inputs and make sure that I
    catch
    > > them when they go high. So, with this being the case, should I
    start
    > > out with something like:
    > >
    > > Low_Byte = INL
    > > Low_Byte = Low_Byte AND 11111111
    > >
    > > IF Low_Byte = 9 THEN Label-On 'Bits 0 and 3 go high
    > >
    > > Would this be correct? Would I need to use INA, INB, INC, IND?
    Thanks
    > > for your help...all of you...Thanks
    > >
    >
    > From what I see, you correctly understood my explanation.
    >
    > The example you listed will indeed check the status of all 8 bits,
    and you
    > are correct when you stated:
    >
    > "IF Low_Byte = 9 THEN Label-On 'Bits 0 and 3 go high"
    >
    > You can use INA if you want to check only input pins 0 through 3.
    INB equates
    > to input pins 4 through 7, INC = bits 8 ~ 11 and of course, IND =
    bits 12 ~
    > 15.
    >
    > Or, INL will check pins 0 ~ 7, INH is pins 8 ~ 15. (if I remember
    correclty -
    > I don't use the stamp much these days)
    >
    > Also, since your "two pins" will remain high for only one second,
    you program
    > loop should continuously check INL. The loop itself probably takes
    i500 to
    > 600 uS or less to complete, so you should have no
    problem "missing" the high
    > state of both pins.
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]


    Thanks a lot! Ok, I'm dealing with X-10, the XOUT command, and it
    seems to slow down the process a little, unless I had things setup
    wrong which caused this. When certain pins go high, I want to
    perform a certain XOUT command. Ok, so could you give me an example
    of how the top portion, the variable declarations section, would look
    for what I have going on? Or do I basically have it already? Will I
    need to declare anything as INL or will the Low_Byte = INL do? What
    would I declare Low_Byte as in the declarations? Thanks for all of
    your help. It also seems like when I put my wires into the board,
    the program seems to quit running or something. I'm using the
    Activity Board. The input port, (X7) has pins 1-20, does it really
    mean 0-19...for programming purposes? ...is my first pin pin1 or
    pin0? Ok...I know that's a lot of questions...I'm sorry about that,
    but if you could answer each of them I would really appreciate it,
    really. Thanks in advance.
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 16:26
    In a message dated 3/12/2003 7:22:23 AM Pacific Standard Time,
    the_prettiest@h... writes:

    > Thanks a lot! Ok, I'm dealing with X-10, the XOUT command, and it
    > seems to slow down the process a little, unless I had things setup
    > wrong which caused this. When certain pins go high, I want to
    > perform a certain XOUT command. Ok, so could you give me an example
    > of how the top portion, the variable declarations section, would look
    > for what I have going on? Or do I basically have it already? Will I
    > need to declare anything as INL or will the Low_Byte = INL do? What
    > would I declare Low_Byte as in the declarations? Thanks for all of
    > your help. It also seems like when I put my wires into the board,
    > the program seems to quit running or something. I'm using the
    > Activity Board. The input port, (X7) has pins 1-20, does it really
    > mean 0-19...for programming purposes? ...is my first pin pin1 or
    > pin0? Ok...I know that's a lot of questions...I'm sorry about that,
    > but if you could answer each of them I would really appreciate it,
    > really. Thanks in advance.
    >

    I am not familiar with the "activity board" and input port X7, and pins 1-20.
    Sorry for that. I am sure there are some "stampers" out there that will be
    able to help you in that area.

    Generally, from what I know, when talking about software, the least
    significant bit is bit 0. So the lowest eight bits are bits 0 through bit 7
    (first 8 bits)

    Regarding the top portion of your program for variable declaration, the
    following can be used to check the state of input pins 0 through 7.

    Low_byte var byte 'defines variable Low_byte as 8 bits
    mask var byte 'defines variable mask as 8 bits
    mask = $FF 'assigns value %11111111 to mask


    loop:

    Low_byte = INL 'moves contents of INL into variable
    Low_byte
    Low_byte = Low_byte AND mask 'returns which bits of INL were high
    'perform your IF statement to check any
    number of bits

    more code etc.

    I hope this helps

    Ken


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-12 20:05
    In a message dated 3/12/2003 8:28:32 AM Pacific Standard Time,
    smartdim@a... writes:

    > Regarding the top portion of your program for variable declaration, the
    > following can be used to check the state of input pins 0 through 7.
    >
    > Low_byte var byte 'defines variable Low_byte as 8 bits
    > mask var byte 'defines variable mask as 8 bits
    > mask = $FF 'assigns value %11111111 to mask
    >
    >
    > loop:
    >
    > Low_byte = INL 'moves contents of INL into variable
    > Low_byte 'OMIT THIS LINE
    > Low_byte = Low_byte AND mask 'returns which bits of INL were high
    > 'perform your IF statement to check any
    > number of bits
    >
    > more code etc.
    >
    > I hope this helps
    >
    > Ken
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.