Shop OBEX P1 Docs P2 Docs Learn Events
read OUT staus — Parallax Forums

read OUT staus

ArchiverArchiver Posts: 46,084
edited 2003-01-03 15:29 in General Discussion
Hi All,

Can anyone please comment on this statement. I can not seem to get it
to work.

Result var byte

if outs(result) then display

I have also tried if outL(result) then ...

I have also tried if out0(result) then...

I don't think that the out statment works if followed immediatley by
a variable representing a pin number (1, 2 or 3 etc). If I use out1
or out2, I can read the pin status. However reading 24 pins takes up
too much code this way.

Can I assign a variable such as "result", which represents a pin
number, to the out statment?

I simply want to read the status of multiple outputs and display the
status.

Ken

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-01-03 13:07
    If you want to examine the a single bit in the Outs register, do this:

    IF Outs.LowBit(result) THEN ...

    -- Jon Williams
    -- Parallax

    In a message dated 1/3/2003 12:07:51 AM Central Standard Time,
    jduldig@s... writes:

    > Hi All,
    >
    > Can anyone please comment on this statement. I can not seem to get it
    > to work.
    >
    > Result var byte
    >
    > if outs(result) then display
    >
    > I have also tried if outL(result) then ...
    >
    > I have also tried if out0(result) then...
    >
    > I don't think that the out statment works if followed immediatley by
    > a variable representing a pin number (1, 2 or 3 etc). If I use out1
    > or out2, I can read the pin status. However reading 24 pins takes up
    > too much code this way.
    >
    > Can I assign a variable such as "result", which represents a pin
    > number, to the out statment?
    >
    > I simply want to read the status of multiple outputs and display the
    > status.
    >
    > Ken



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-03 13:23
    On 3 Jan 03 at 6:05, digdul2002 jduldig@s.... wrote:

    > ...Can anyone please comment on this statement. I can not seem to
    > get it to work.
    >
    > Result var byte
    >
    > if outs(result) then display

    OUTS is a word-sized variable at memory location 2. OUTS(result)
    refers to a word of memory at location 2 + (result * 2), memory
    which you have probably declared for use by other variables.

    > I don't think that the out statment works if followed immediatley by
    > a variable representing a pin number (1, 2 or 3 etc). If I use out1
    > or out2, I can read the pin status. However reading 24 pins takes up
    > too much code this way.

    Try this as a stand-alone program:

    i VAR WORD
    j VAR BYTE

    FOR i = 0 TI 65535
    OUTS = i
    DEBUG CR,HEX4 OUTS," "
    FOR j = 15 TO 0
    DEBUG BIN1 OUT0(j)
    NEXT
    NEXT

    This cycles OUTS through all possible values, reading each output
    latch individually as an array member. It works.

    It may be that your program is not setting the output latches
    to the values you intend, which causes unexpected OUT0(value)
    results. To verify this, add this statement to your program at the
    point where you are testing the OUT0(value) settings:

    DEBUG CR,BIN16 OUTS," ",DEC value

    This will show you the current value for all 16 output latches and
    should match what you are seeing via the OUT0(value). It will also
    show the actual quantity contained by your "value" variable, which
    may not be what you intend/expect--another reason OUT0(value) seems
    wrong.

    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-03 15:29
    Hi Ken,

    You can assign outs to a variable, like this

    Result var word(2)
    K var byte
    Bitvalue var bit

    Mainio
    Result(0) = outs
    Auxio
    Xresult(1) = outs

    For k=0 to 31
    pinvalue = result.bit0(k) 'get value for single pin
    debug bitvalue+48 'display 0 or 1
    next

    Hope this helps

    Regards peter


    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AhzkuoJcu3Sqbj9NYM0lr0axuSzYFCCuKN_qhj1pEDYk2NANcW6nfrV1bYXF0PmuQD1SFIrk2rbK3yMcTQ]jduldig@s...[/url
    Verzonden: donderdag 2 januari 2003 22:05
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] read OUT staus

    Hi All,

    Can anyone please comment on this statement. I can not seem to get it
    to work.

    Result var byte

    if outs(result) then display

    I have also tried if outL(result) then ...

    I have also tried if out0(result) then...

    I don't think that the out statment works if followed immediatley by
    a variable representing a pin number (1, 2 or 3 etc). If I use out1
    or out2, I can read the pin status. However reading 24 pins takes up
    too much code this way.

    Can I assign a variable such as "result", which represents a pin
    number, to the out statment?

    I simply want to read the status of multiple outputs and display the
    status.

    Ken


    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/
Sign In or Register to comment.