Shop OBEX P1 Docs P2 Docs Learn Events
capturing variable — Parallax Forums

capturing variable

ArchiverArchiver Posts: 46,084
edited 2004-04-17 05:43 in General Discussion
I'm trying to communicate with an asynchronous device via SERIN and
SEROUT. It's communicating, but returns an unexpected result.
instead of giving me the expected 8byte ASCII hexadecimal string, I
get $7C. any idea why?

thanks for the help. Steve
_________________________________________________________________
'{$STAMP BS2p}

' declare variable
result VAR Byte

SendData:
SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1

ReadData:
SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin 10,
'store in variable "result"
DEBUG CLS, HEX? result 'convert to HEX and display...
'result = $7C
'should be 7F0000000836A410<CR>
STOP
No_Data:
DEBUG CLS, "Timed out"

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-16 20:52
    Perhaps you're sending it an unexpected or incorrectly formatted
    instruction....

    Since the BASIC Stamp stores everything as a number anyway, prevent
    possible errors when sending ASCII characters by simply embedding that
    character. Like this:

    SendData:
    SEROUT 9, 16624, [noparse][[/noparse]"S"]

    And, according to my BASIC Stamp, the ASCII code for "S" is 83, not 82.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=0oTcilLJqqpdY2E9w7DwywJq7I8CL0YyFyi1iqwgX1EURKyvMgSYRSFeV3QbG5nreC-2pmf_APIubFUNuHY]stepnote@c...[/url
    Sent: Friday, April 16, 2004 2:05 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] capturing variable


    I'm trying to communicate with an asynchronous device via SERIN and
    SEROUT. It's communicating, but returns an unexpected result.
    instead of giving me the expected 8byte ASCII hexadecimal string, I
    get $7C. any idea why?

    thanks for the help. Steve
    _________________________________________________________________
    '{$STAMP BS2p}

    ' declare variable
    result VAR Byte

    SendData:
    SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1

    ReadData:
    SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin 10,
    'store in variable "result"
    DEBUG CLS, HEX? result 'convert to HEX and display...
    'result = $7C
    'should be 7F0000000836A410<CR> STOP
    No_Data:
    DEBUG CLS, "Timed out"
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-16 22:15
    Jon: I tried that (see below). it still returns "$7C". thanks

    ____________________________________________________________________

    result VAR Byte
    '1 loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    ReadData:
    SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin 10,
    store in variable "result"
    DEBUG CLS, HEX? result 'convert to HEX and display...result =
    $E5 should be 7F0000000836A410<CR>
    STOP
    No_Data:
    DEBUG CLS, "Timed out"












    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Perhaps you're sending it an unexpected or incorrectly formatted
    > instruction....
    >
    > Since the BASIC Stamp stores everything as a number anyway, prevent
    > possible errors when sending ASCII characters by simply embedding
    that
    > character. Like this:
    >
    > SendData:
    > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    >
    > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    not 82.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 2:05 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] capturing variable
    >
    >
    > I'm trying to communicate with an asynchronous device via SERIN
    and
    > SEROUT. It's communicating, but returns an unexpected result.
    > instead of giving me the expected 8byte ASCII hexadecimal string,
    I
    > get $7C. any idea why?
    >
    > thanks for the help. Steve
    > _________________________________________________________________
    > '{$STAMP BS2p}
    >
    > ' declare variable
    > result VAR Byte
    >
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    >
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > 'store in
    variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...
    > 'result = $7C
    > 'should be 7F0000000836A410<CR> STOP
    > No_Data:
    > DEBUG CLS, "Timed out"
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-16 22:28
    Hello stenote,
    If I'm correct you are trying to receive 8 bytes. In that case
    try the following. This code will bring in the 8 bytes. If you have any
    questions please reply.



    '{$STAMP BS2p}
    '{$PBASIC 2.0}
    result VAR Byte(8) 'setups an 8 byte array
    temp VAR Nib ' used to access array for displaying
    '1 loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    ReadData:
    SERIN 16,16624,2000, No_Data, [noparse][[/noparse]STR result\8] 'read the input of 8
    bytes STORE in variable "result"
    FOR temp = 0 TO 7
    DEBUG HEX result(temp),CR 'convert to HEX and display...result = $E5
    'should be 7F0000000836A410<CR>
    NEXT

    STOP
    No_Data: DEBUG CLS, "Timed out"



    Stephen Swanson
    Technical Support Manager
    Parallax, Inc.
    599 Menlo Drive, #100
    Rocklin, CA 95765

    Phone (916) 624-8333
    E-mail ..... sswanson@p...
    Main site...... www.parallax.com
    Educational site.... www.parallax.com/sic
    Javelin Stamp... www.parallax.com/javelin


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rxOxsd-rH7pIxNYIl9B7iLzEs4rMFR95k7ckpVrg-R874EuNdZIkdtE1meJcsE5170AFemGAmR8-iA]stepnote@c...[/url
    Sent: Friday, April 16, 2004 2:15 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: capturing variable

    Jon: I tried that (see below). it still returns "$7C". thanks

    ____________________________________________________________________

    result VAR Byte
    '1 loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    ReadData:
    SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin 10,
    store in variable "result"
    DEBUG CLS, HEX? result 'convert to HEX and display...result =
    $E5 should be 7F0000000836A410<CR>
    STOP
    No_Data:
    DEBUG CLS, "Timed out"












    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Perhaps you're sending it an unexpected or incorrectly formatted
    > instruction....
    >
    > Since the BASIC Stamp stores everything as a number anyway, prevent
    > possible errors when sending ASCII characters by simply embedding
    that
    > character. Like this:
    >
    > SendData:
    > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    >
    > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    not 82.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 2:05 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] capturing variable
    >
    >
    > I'm trying to communicate with an asynchronous device via SERIN
    and
    > SEROUT. It's communicating, but returns an unexpected result.
    > instead of giving me the expected 8byte ASCII hexadecimal string,
    I
    > get $7C. any idea why?
    >
    > thanks for the help. Steve
    > _________________________________________________________________
    > '{$STAMP BS2p}
    >
    > ' declare variable
    > result VAR Byte
    >
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    >
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > 'store in
    variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...
    > 'result = $7C
    > 'should be 7F0000000836A410<CR> STOP
    > No_Data:
    > DEBUG CLS, "Timed out"



    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-16 22:48
    Aha ... you're only capturing the first byte. Create an eight-byte
    array, then use the STR modifier to capture it. Like this:

    result VAR Byte(8)
    idx VAR Nib


    Then modify your receive code like this:

    Read_Data:
    SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    DEBUG CLS
    FOR idx = 0 TO 7
    DEBUG HEX2 result(idx)
    NEXT
    STOP

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=39xMijJWqshFGy0x9xi6FYsrkVq_fWKC_TFl3udkuaSSyQHTi8ki6lJQjA7KUuDiL581pgyCqC3gR5dzyQU]stepnote@c...[/url
    Sent: Friday, April 16, 2004 4:15 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: capturing variable


    Jon: I tried that (see below). it still returns "$7C". thanks

    ____________________________________________________________________

    result VAR Byte
    '1 loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    ReadData:
    SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin 10,
    store in variable "result"
    DEBUG CLS, HEX? result 'convert to HEX and display...result =
    $E5 should be 7F0000000836A410<CR>
    STOP
    No_Data:
    DEBUG CLS, "Timed out"












    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Perhaps you're sending it an unexpected or incorrectly formatted
    > instruction....
    >
    > Since the BASIC Stamp stores everything as a number anyway, prevent
    > possible errors when sending ASCII characters by simply embedding
    that
    > character. Like this:
    >
    > SendData:
    > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    >
    > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    not 82.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 2:05 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] capturing variable
    >
    >
    > I'm trying to communicate with an asynchronous device via SERIN
    and
    > SEROUT. It's communicating, but returns an unexpected result.
    > instead of giving me the expected 8byte ASCII hexadecimal string,
    I
    > get $7C. any idea why?
    >
    > thanks for the help. Steve
    > _________________________________________________________________
    > '{$STAMP BS2p}
    >
    > ' declare variable
    > result VAR Byte
    >
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    >
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > 'store in
    variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...
    > 'result = $7C
    > 'should be 7F0000000836A410<CR> STOP
    > No_Data:
    > DEBUG CLS, "Timed out"



    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:08
    Jon: looks like it should work, I understand about capturing the
    first byte, makes sense. Here's what I tried, but now it "times out"

    thanks, Steve

    '{$STAMP BS2p}

    ' declare variable

    result VAR Byte(8)
    idx VAR Nib

    'loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1

    ReadData:
    SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    FOR idx = 0 TO 7
    DEBUG HEX2 result(idx)
    NEXT
    STOP

    No_Data:
    DEBUG CLS, "Timed out"
















    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Aha ... you're only capturing the first byte. Create an eight-byte
    > array, then use the STR modifier to capture it. Like this:
    >
    > result VAR Byte(8)
    > idx VAR Nib
    >
    >
    > Then modify your receive code like this:
    >
    > Read_Data:
    > SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    > DEBUG CLS
    > FOR idx = 0 TO 7
    > DEBUG HEX2 result(idx)
    > NEXT
    > STOP
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 4:15 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    >
    > Jon: I tried that (see below). it still returns "$7C". thanks
    >
    >
    ____________________________________________________________________
    >
    > result VAR Byte
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > store in variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...result =
    > $E5 should be 7F0000000836A410<CR>
    > STOP
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Perhaps you're sending it an unexpected or incorrectly formatted
    > > instruction....
    > >
    > > Since the BASIC Stamp stores everything as a number anyway,
    prevent
    > > possible errors when sending ASCII characters by simply embedding
    > that
    > > character. Like this:
    > >
    > > SendData:
    > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > >
    > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > not 82.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:05 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > >
    > >
    > > I'm trying to communicate with an asynchronous device via SERIN
    > and
    > > SEROUT. It's communicating, but returns an unexpected result.
    > > instead of giving me the expected 8byte ASCII hexadecimal
    string,
    > I
    > > get $7C. any idea why?
    > >
    > > thanks for the help. Steve
    > > _________________________________________________________________
    > > '{$STAMP BS2p}
    > >
    > > ' declare variable
    > > result VAR Byte
    > >
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > >
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > 'store in
    > variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > 'result = $7C
    > > 'should be 7F0000000836A410<CR> STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:13
    Stephen: thanks...I think between what you and Jon said is
    essentially the same thing, and I tried it and responded to Jon's
    message. Now it "times out". a bit baffling at this point, but I
    really appreciate the input from you guys.

    thanks a lot. Steve

    --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    <sswanson@p...> wrote:
    > Hello stenote,
    > If I'm correct you are trying to receive 8 bytes. In that
    case
    > try the following. This code will bring in the 8 bytes. If you
    have any
    > questions please reply.
    >
    >
    >
    > '{$STAMP BS2p}
    > '{$PBASIC 2.0}
    > result VAR Byte(8) 'setups an 8 byte array
    > temp VAR Nib ' used to access array for displaying
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 16,16624,2000, No_Data, [noparse][[/noparse]STR result\8] 'read the input of
    8
    > bytes STORE in variable "result"
    > FOR temp = 0 TO 7
    > DEBUG HEX result(temp),CR 'convert to HEX and display...result
    = $E5
    > 'should be 7F0000000836A410<CR>
    > NEXT
    >
    > STOP
    > No_Data: DEBUG CLS, "Timed out"
    >
    >
    >
    > Stephen Swanson
    > Technical Support Manager
    > Parallax, Inc.
    > 599 Menlo Drive, #100
    > Rocklin, CA 95765
    >
    > Phone (916) 624-8333
    > E-mail ..... sswanson@p...
    > Main site...... www.parallax.com
    > Educational site.... www.parallax.com/sic
    > Javelin Stamp... www.parallax.com/javelin
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 2:15 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    > Jon: I tried that (see below). it still returns "$7C". thanks
    >
    >
    ____________________________________________________________________
    >
    > result VAR Byte
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > store in variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...result =
    > $E5 should be 7F0000000836A410<CR>
    > STOP
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Perhaps you're sending it an unexpected or incorrectly formatted
    > > instruction....
    > >
    > > Since the BASIC Stamp stores everything as a number anyway,
    prevent
    > > possible errors when sending ASCII characters by simply
    embedding
    > that
    > > character. Like this:
    > >
    > > SendData:
    > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > >
    > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > not 82.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:05 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > >
    > >
    > > I'm trying to communicate with an asynchronous device via SERIN
    > and
    > > SEROUT. It's communicating, but returns an unexpected result.
    > > instead of giving me the expected 8byte ASCII hexadecimal
    string,
    > I
    > > get $7C. any idea why?
    > >
    > > thanks for the help. Steve
    > > _________________________________________________________________
    > > '{$STAMP BS2p}
    > >
    > > ' declare variable
    > > result VAR Byte
    > >
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > >
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > 'store in
    > variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > 'result = $7C
    > > 'should be 7F0000000836A410<CR> STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:14
    Sure anytime.


    Stephen Swanson
    Technical Support Manager
    Parallax, Inc.
    599 Menlo Drive, #100
    Rocklin, CA 95765

    Phone (916) 624-8333
    E-mail ..... sswanson@p...
    Main site...... www.parallax.com
    Educational site.... www.parallax.com/sic
    Javelin Stamp... www.parallax.com/javelin


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=s9mbG-yGtSz8uCTzAkvl-EOjiIyUsDKkvvuf44vNVgEVG1sf-lloB2QkssPb9TCQC84odTeVBDU8M5xFrA]stepnote@c...[/url
    Sent: Friday, April 16, 2004 4:13 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: capturing variable

    Stephen: thanks...I think between what you and Jon said is
    essentially the same thing, and I tried it and responded to Jon's
    message. Now it "times out". a bit baffling at this point, but I
    really appreciate the input from you guys.

    thanks a lot. Steve

    --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    <sswanson@p...> wrote:
    > Hello stenote,
    > If I'm correct you are trying to receive 8 bytes. In that
    case
    > try the following. This code will bring in the 8 bytes. If you
    have any
    > questions please reply.
    >
    >
    >
    > '{$STAMP BS2p}
    > '{$PBASIC 2.0}
    > result VAR Byte(8) 'setups an 8 byte array
    > temp VAR Nib ' used to access array for displaying
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 16,16624,2000, No_Data, [noparse][[/noparse]STR result\8] 'read the input of
    8
    > bytes STORE in variable "result"
    > FOR temp = 0 TO 7
    > DEBUG HEX result(temp),CR 'convert to HEX and display...result
    = $E5
    > 'should be 7F0000000836A410<CR>
    > NEXT
    >
    > STOP
    > No_Data: DEBUG CLS, "Timed out"
    >
    >
    >
    > Stephen Swanson
    > Technical Support Manager
    > Parallax, Inc.
    > 599 Menlo Drive, #100
    > Rocklin, CA 95765
    >
    > Phone (916) 624-8333
    > E-mail ..... sswanson@p...
    > Main site...... www.parallax.com
    > Educational site.... www.parallax.com/sic
    > Javelin Stamp... www.parallax.com/javelin
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 2:15 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    > Jon: I tried that (see below). it still returns "$7C". thanks
    >
    >
    ____________________________________________________________________
    >
    > result VAR Byte
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > store in variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...result =
    > $E5 should be 7F0000000836A410<CR>
    > STOP
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Perhaps you're sending it an unexpected or incorrectly formatted
    > > instruction....
    > >
    > > Since the BASIC Stamp stores everything as a number anyway,
    prevent
    > > possible errors when sending ASCII characters by simply
    embedding
    > that
    > > character. Like this:
    > >
    > > SendData:
    > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > >
    > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > not 82.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:05 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > >
    > >
    > > I'm trying to communicate with an asynchronous device via SERIN
    > and
    > > SEROUT. It's communicating, but returns an unexpected result.
    > > instead of giving me the expected 8byte ASCII hexadecimal
    string,
    > I
    > > get $7C. any idea why?
    > >
    > > thanks for the help. Steve
    > > _________________________________________________________________
    > > '{$STAMP BS2p}
    > >
    > > ' declare variable
    > > result VAR Byte
    > >
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > >
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > 'store in
    > variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > 'result = $7C
    > > 'should be 7F0000000836A410<CR> STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...



    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:32
    to confirm:

    is the baud setup "16624" equivalent to "9600,N,8,1"??

    thanks


    --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    <sswanson@p...> wrote:
    > Sure anytime.
    >
    >
    > Stephen Swanson
    > Technical Support Manager
    > Parallax, Inc.
    > 599 Menlo Drive, #100
    > Rocklin, CA 95765
    >
    > Phone (916) 624-8333
    > E-mail ..... sswanson@p...
    > Main site...... www.parallax.com
    > Educational site.... www.parallax.com/sic
    > Javelin Stamp... www.parallax.com/javelin
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 4:13 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    > Stephen: thanks...I think between what you and Jon said is
    > essentially the same thing, and I tried it and responded to Jon's
    > message. Now it "times out". a bit baffling at this point, but I
    > really appreciate the input from you guys.
    >
    > thanks a lot. Steve
    >
    > --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    > <sswanson@p...> wrote:
    > > Hello stenote,
    > > If I'm correct you are trying to receive 8 bytes. In that
    > case
    > > try the following. This code will bring in the 8 bytes. If you
    > have any
    > > questions please reply.
    > >
    > >
    > >
    > > '{$STAMP BS2p}
    > > '{$PBASIC 2.0}
    > > result VAR Byte(8) 'setups an 8 byte array
    > > temp VAR Nib ' used to access array for displaying
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 16,16624,2000, No_Data, [noparse][[/noparse]STR result\8] 'read the input
    of
    > 8
    > > bytes STORE in variable "result"
    > > FOR temp = 0 TO 7
    > > DEBUG HEX result(temp),CR 'convert to HEX and
    display...result
    > = $E5
    > > 'should be 7F0000000836A410<CR>
    > > NEXT
    > >
    > > STOP
    > > No_Data: DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > Stephen Swanson
    > > Technical Support Manager
    > > Parallax, Inc.
    > > 599 Menlo Drive, #100
    > > Rocklin, CA 95765
    > >
    > > Phone (916) 624-8333
    > > E-mail ..... sswanson@p...
    > > Main site...... www.parallax.com
    > > Educational site.... www.parallax.com/sic
    > > Javelin Stamp... www.parallax.com/javelin
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:15 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > >
    > > Jon: I tried that (see below). it still returns "$7C". thanks
    > >
    > >
    >
    ____________________________________________________________________
    > >
    > > result VAR Byte
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > store in variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...result
    =
    > > $E5 should be 7F0000000836A410<CR>
    > > STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > <jwilliams@p...>
    > > wrote:
    > > > Perhaps you're sending it an unexpected or incorrectly
    formatted
    > > > instruction....
    > > >
    > > > Since the BASIC Stamp stores everything as a number anyway,
    > prevent
    > > > possible errors when sending ASCII characters by simply
    > embedding
    > > that
    > > > character. Like this:
    > > >
    > > > SendData:
    > > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > > >
    > > > And, according to my BASIC Stamp, the ASCII code for "S" is
    83,
    > > not 82.
    > > >
    > > > -- Jon Williams
    > > > -- Applications Engineer, Parallax
    > > > -- Dallas Office
    > > >
    > > >
    > > >
    Original Message
    > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > Sent: Friday, April 16, 2004 2:05 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > > >
    > > >
    > > > I'm trying to communicate with an asynchronous device via
    SERIN
    > > and
    > > > SEROUT. It's communicating, but returns an unexpected
    result.
    > > > instead of giving me the expected 8byte ASCII hexadecimal
    > string,
    > > I
    > > > get $7C. any idea why?
    > > >
    > > > thanks for the help. Steve
    > > >
    _________________________________________________________________
    > > > '{$STAMP BS2p}
    > > >
    > > > ' declare variable
    -
    > > > result VAR Byte
    > > >
    > > > SendData:
    > > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > > >
    > > > ReadData:
    > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on
    pin
    > > 10,
    > > > 'store in
    > > variable "result"
    > > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > > 'result = $7C
    > > > 'should be 7F0000000836A410<CR>
    STOP
    > > > No_Data:
    > > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:39
    Yes,
    For inverted, true would be 240

    Stephen Swanson
    Technical Support Manager
    Parallax, Inc.
    599 Menlo Drive, #100
    Rocklin, CA 95765

    Phone (916) 624-8333
    E-mail ..... sswanson@p...
    Main site...... www.parallax.com
    Educational site.... www.parallax.com/sic
    Javelin Stamp... www.parallax.com/javelin


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=15yW7zLc2Gnute3Vk-2-QpKREq7pemIxQsgE4kX5ylD0CXfgAewG9RZYuNL70EC9D7cETTYtAgwbHgw]stepnote@c...[/url
    Sent: Friday, April 16, 2004 4:33 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: capturing variable

    to confirm:

    is the baud setup "16624" equivalent to "9600,N,8,1"??

    thanks


    --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    <sswanson@p...> wrote:
    > Sure anytime.
    >
    >
    > Stephen Swanson
    > Technical Support Manager
    > Parallax, Inc.
    > 599 Menlo Drive, #100
    > Rocklin, CA 95765
    >
    > Phone (916) 624-8333
    > E-mail ..... sswanson@p...
    > Main site...... www.parallax.com
    > Educational site.... www.parallax.com/sic
    > Javelin Stamp... www.parallax.com/javelin
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 4:13 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    > Stephen: thanks...I think between what you and Jon said is
    > essentially the same thing, and I tried it and responded to Jon's
    > message. Now it "times out". a bit baffling at this point, but I
    > really appreciate the input from you guys.
    >
    > thanks a lot. Steve
    >
    > --- In basicstamps@yahoogroups.com, "Stephen Swanson"
    > <sswanson@p...> wrote:
    > > Hello stenote,
    > > If I'm correct you are trying to receive 8 bytes. In that
    > case
    > > try the following. This code will bring in the 8 bytes. If you
    > have any
    > > questions please reply.
    > >
    > >
    > >
    > > '{$STAMP BS2p}
    > > '{$PBASIC 2.0}
    > > result VAR Byte(8) 'setups an 8 byte array
    > > temp VAR Nib ' used to access array for displaying
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 16,16624,2000, No_Data, [noparse][[/noparse]STR result\8] 'read the input
    of
    > 8
    > > bytes STORE in variable "result"
    > > FOR temp = 0 TO 7
    > > DEBUG HEX result(temp),CR 'convert to HEX and
    display...result
    > = $E5
    > > 'should be 7F0000000836A410<CR>
    > > NEXT
    > >
    > > STOP
    > > No_Data: DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > Stephen Swanson
    > > Technical Support Manager
    > > Parallax, Inc.
    > > 599 Menlo Drive, #100
    > > Rocklin, CA 95765
    > >
    > > Phone (916) 624-8333
    > > E-mail ..... sswanson@p...
    > > Main site...... www.parallax.com
    > > Educational site.... www.parallax.com/sic
    > > Javelin Stamp... www.parallax.com/javelin
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:15 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > >
    > > Jon: I tried that (see below). it still returns "$7C". thanks
    > >
    > >
    >
    ____________________________________________________________________
    > >
    > > result VAR Byte
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > store in variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...result
    =
    > > $E5 should be 7F0000000836A410<CR>
    > > STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > <jwilliams@p...>
    > > wrote:
    > > > Perhaps you're sending it an unexpected or incorrectly
    formatted
    > > > instruction....
    > > >
    > > > Since the BASIC Stamp stores everything as a number anyway,
    > prevent
    > > > possible errors when sending ASCII characters by simply
    > embedding
    > > that
    > > > character. Like this:
    > > >
    > > > SendData:
    > > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > > >
    > > > And, according to my BASIC Stamp, the ASCII code for "S" is
    83,
    > > not 82.
    > > >
    > > > -- Jon Williams
    > > > -- Applications Engineer, Parallax
    > > > -- Dallas Office
    > > >
    > > >
    > > >
    Original Message
    > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > Sent: Friday, April 16, 2004 2:05 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > > >
    > > >
    > > > I'm trying to communicate with an asynchronous device via
    SERIN
    > > and
    > > > SEROUT. It's communicating, but returns an unexpected
    result.
    > > > instead of giving me the expected 8byte ASCII hexadecimal
    > string,
    > > I
    > > > get $7C. any idea why?
    > > >
    > > > thanks for the help. Steve
    > > >
    _________________________________________________________________
    > > > '{$STAMP BS2p}
    > > >
    > > > ' declare variable
    -
    > > > result VAR Byte
    > > >
    > > > SendData:
    > > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > > >
    > > > ReadData:
    > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on
    pin
    > > 10,
    > > > 'store in
    > > variable "result"
    > > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > > 'result = $7C
    > > > 'should be 7F0000000836A410<CR>
    STOP
    > > > No_Data:
    > > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...



    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:43
    Well, there's nothing wrong with your BASIC Stamp code -- you may need
    to check for the correct baud parameter (I see that Stephen has
    addressed that) and what the actual output from your mystery device is.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: stenote [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=sk9EOAXIjB--PLTAvYSAJsFkMFysFs4jlsSdCTLXedK5Hd48Tkl-HaE3B1TuErAj9e5mxjhLUOCZmjl-]stepnote@c...[/url
    Sent: Friday, April 16, 2004 6:08 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: capturing variable


    Jon: looks like it should work, I understand about capturing the
    first byte, makes sense. Here's what I tried, but now it "times out"

    thanks, Steve

    '{$STAMP BS2p}

    ' declare variable

    result VAR Byte(8)
    idx VAR Nib

    'loop through SEROUT/SERIN
    SendData:
    SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1

    ReadData:
    SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    FOR idx = 0 TO 7
    DEBUG HEX2 result(idx)
    NEXT
    STOP

    No_Data:
    DEBUG CLS, "Timed out"
















    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Aha ... you're only capturing the first byte. Create an eight-byte
    > array, then use the STR modifier to capture it. Like this:
    >
    > result VAR Byte(8)
    > idx VAR Nib
    >
    >
    > Then modify your receive code like this:
    >
    > Read_Data:
    > SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    > DEBUG CLS
    > FOR idx = 0 TO 7
    > DEBUG HEX2 result(idx)
    > NEXT
    > STOP
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 4:15 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    >
    > Jon: I tried that (see below). it still returns "$7C". thanks
    >
    >
    ____________________________________________________________________
    >
    > result VAR Byte
    > '1 loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > ReadData:
    > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    10,
    > store in variable "result"
    > DEBUG CLS, HEX? result 'convert to HEX and display...result =
    > $E5 should be 7F0000000836A410<CR>
    > STOP
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Perhaps you're sending it an unexpected or incorrectly formatted
    > > instruction....
    > >
    > > Since the BASIC Stamp stores everything as a number anyway,
    prevent
    > > possible errors when sending ASCII characters by simply embedding
    > that
    > > character. Like this:
    > >
    > > SendData:
    > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > >
    > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > not 82.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 2:05 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > >
    > >
    > > I'm trying to communicate with an asynchronous device via SERIN
    > and
    > > SEROUT. It's communicating, but returns an unexpected result.
    > > instead of giving me the expected 8byte ASCII hexadecimal
    string,
    > I
    > > get $7C. any idea why?
    > >
    > > thanks for the help. Steve
    > > _________________________________________________________________
    > > '{$STAMP BS2p}
    > >
    > > ' declare variable
    > > result VAR Byte
    > >
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > >
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > 'store in
    > variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > 'result = $7C
    > > 'should be 7F0000000836A410<CR> STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...



    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







    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:56
    back to the books. I need to digest this whole thing and see which
    way is up. the device was referred to in "stamp 2' page 46,
    and 'was' the Point Six, Inc HA7S 1-wire interface, which apparently
    now belongs to "Embedded Data Systems."

    thanks for all the help, guys, I may be back at you in a day or two.

    Steve

    __________________________________________________________________

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Well, there's nothing wrong with your BASIC Stamp code -- you may
    need
    > to check for the correct baud parameter (I see that Stephen has
    > addressed that) and what the actual output from your mystery
    device is.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 6:08 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    >
    > Jon: looks like it should work, I understand about capturing the
    > first byte, makes sense. Here's what I tried, but now it "times
    out"
    >
    > thanks, Steve
    >
    >
    > '{$STAMP BS2p}
    >
    > ' declare variable
    -
    >
    > result VAR Byte(8)
    > idx VAR Nib
    >
    > 'loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    >
    > ReadData:
    > SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    > FOR idx = 0 TO 7
    > DEBUG HEX2 result(idx)
    > NEXT
    > STOP
    >
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Aha ... you're only capturing the first byte. Create an eight-
    byte
    > > array, then use the STR modifier to capture it. Like this:
    > >
    > > result VAR Byte(8)
    > > idx VAR Nib
    > >
    > >
    > > Then modify your receive code like this:
    > >
    > > Read_Data:
    > > SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    > > DEBUG CLS
    > > FOR idx = 0 TO 7
    > > DEBUG HEX2 result(idx)
    > > NEXT
    > > STOP
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 4:15 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > >
    > >
    > > Jon: I tried that (see below). it still returns "$7C". thanks
    > >
    > >
    >
    ____________________________________________________________________
    > >
    > > result VAR Byte
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > store in variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...result
    =
    > > $E5 should be 7F0000000836A410<CR>
    > > STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > <jwilliams@p...>
    > > wrote:
    > > > Perhaps you're sending it an unexpected or incorrectly
    formatted
    > > > instruction....
    > > >
    > > > Since the BASIC Stamp stores everything as a number anyway,
    > prevent
    > > > possible errors when sending ASCII characters by simply
    embedding
    > > that
    > > > character. Like this:
    > > >
    > > > SendData:
    > > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > > >
    > > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > > not 82.
    > > >
    > > > -- Jon Williams
    > > > -- Applications Engineer, Parallax
    > > > -- Dallas Office
    > > >
    > > >
    > > >
    Original Message
    > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > Sent: Friday, April 16, 2004 2:05 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > > >
    > > >
    > > > I'm trying to communicate with an asynchronous device via SERIN
    > > and
    > > > SEROUT. It's communicating, but returns an unexpected result.
    > > > instead of giving me the expected 8byte ASCII hexadecimal
    > string,
    > > I
    > > > get $7C. any idea why?
    > > >
    > > > thanks for the help. Steve
    > > >
    _________________________________________________________________
    > > > '{$STAMP BS2p}
    > > >
    > > > ' declare variable
    -
    > > > result VAR Byte
    > > >
    > > > SendData:
    > > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > > >
    > > > ReadData:
    > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on
    pin
    > > 10,
    > > > 'store in
    > > variable "result"
    > > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > > 'result = $7C
    > > > 'should be 7F0000000836A410<CR>
    STOP
    > > > No_Data:
    > > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM
    to
    > > abuse@p...
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 00:56
    back to the books. I need to digest this whole thing and see which
    way is up. the device was referred to in "stamp 2' page 46,
    and 'was' the Point Six, Inc HA7S 1-wire interface, which apparently
    now belongs to "Embedded Data Systems."

    thanks for all the help, guys, I may be back at you in a day or two.

    Steve

    __________________________________________________________________

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > Well, there's nothing wrong with your BASIC Stamp code -- you may
    need
    > to check for the correct baud parameter (I see that Stephen has
    > addressed that) and what the actual output from your mystery
    device is.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > Sent: Friday, April 16, 2004 6:08 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >
    >
    > Jon: looks like it should work, I understand about capturing the
    > first byte, makes sense. Here's what I tried, but now it "times
    out"
    >
    > thanks, Steve
    >
    >
    > '{$STAMP BS2p}
    >
    > ' declare variable
    -
    >
    > result VAR Byte(8)
    > idx VAR Nib
    >
    > 'loop through SEROUT/SERIN
    > SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    >
    > ReadData:
    > SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    > FOR idx = 0 TO 7
    > DEBUG HEX2 result(idx)
    > NEXT
    > STOP
    >
    > No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams"
    <jwilliams@p...>
    > wrote:
    > > Aha ... you're only capturing the first byte. Create an eight-
    byte
    > > array, then use the STR modifier to capture it. Like this:
    > >
    > > result VAR Byte(8)
    > > idx VAR Nib
    > >
    > >
    > > Then modify your receive code like this:
    > >
    > > Read_Data:
    > > SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    > > DEBUG CLS
    > > FOR idx = 0 TO 7
    > > DEBUG HEX2 result(idx)
    > > NEXT
    > > STOP
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 4:15 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > >
    > >
    > > Jon: I tried that (see below). it still returns "$7C". thanks
    > >
    > >
    >
    ____________________________________________________________________
    > >
    > > result VAR Byte
    > > '1 loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > ReadData:
    > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > 10,
    > > store in variable "result"
    > > DEBUG CLS, HEX? result 'convert to HEX and display...result
    =
    > > $E5 should be 7F0000000836A410<CR>
    > > STOP
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > <jwilliams@p...>
    > > wrote:
    > > > Perhaps you're sending it an unexpected or incorrectly
    formatted
    > > > instruction....
    > > >
    > > > Since the BASIC Stamp stores everything as a number anyway,
    > prevent
    > > > possible errors when sending ASCII characters by simply
    embedding
    > > that
    > > > character. Like this:
    > > >
    > > > SendData:
    > > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > > >
    > > > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    > > not 82.
    > > >
    > > > -- Jon Williams
    > > > -- Applications Engineer, Parallax
    > > > -- Dallas Office
    > > >
    > > >
    > > >
    Original Message
    > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > Sent: Friday, April 16, 2004 2:05 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > > >
    > > >
    > > > I'm trying to communicate with an asynchronous device via SERIN
    > > and
    > > > SEROUT. It's communicating, but returns an unexpected result.
    > > > instead of giving me the expected 8byte ASCII hexadecimal
    > string,
    > > I
    > > > get $7C. any idea why?
    > > >
    > > > thanks for the help. Steve
    > > >
    _________________________________________________________________
    > > > '{$STAMP BS2p}
    > > >
    > > > ' declare variable
    -
    > > > result VAR Byte
    > > >
    > > > SendData:
    > > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > > >
    > > > ReadData:
    > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on
    pin
    > > 10,
    > > > 'store in
    > > variable "result"
    > > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > > 'result = $7C
    > > > 'should be 7F0000000836A410<CR>
    STOP
    > > > No_Data:
    > > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM
    to
    > > abuse@p...
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please report SPAM to
    > abuse@p...
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 03:07
    Hi Steve,

    What often happens in cases like this, is that the instrument
    responds too fast, before the Stamp is ready to receive. It takes
    the Stamp a good fraction of a millisecond between the time it sends
    the "S" and before it is ready to receive its first byte. But the
    instrument may only wait a few microseconds. The Stamp has no input
    serial buffer. When it is ready, it starts receiving out of sync in
    the middle of the response.

    In your latest experiment, it would "time out" because it tuned in
    too late to get all 8 of the characters it is expecting. Even when
    it times out, you can print the string buffer and see if there is
    anything recognizable there. It might be garbled, but it will give
    you an idea of whether or not my theory is correct.

    The setup delay for a SERIN command with a timeout and using the STR
    modifier is about 240 microseconds on a BS2sx, and a bit faster on
    the BS2p. 600 microseconds on a vanilla BS2.

    -- Tracy




    You were expecting back the string "7F0000000836A410<CR>", but when
    you were only looking for one byte, you got $7f

    >Jon: looks like it should work, I understand about capturing the
    >first byte, makes sense. Here's what I tried, but now it "times out"
    >
    >thanks, Steve
    >
    >
    >'{$STAMP BS2p}
    >
    >' declare variable
    >
    >result VAR Byte(8)
    >idx VAR Nib
    >
    >'loop through SEROUT/SERIN
    >SendData:
    > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    >
    >ReadData:
    > SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    > FOR idx = 0 TO 7
    > DEBUG HEX2 result(idx)
    > NEXT
    > STOP
    >
    >No_Data:
    > DEBUG CLS, "Timed out"
    >
    >
    >
    >--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    >wrote:
    >> Aha ... you're only capturing the first byte. Create an eight-byte
    >> array, then use the STR modifier to capture it. Like this:
    >>
    >> result VAR Byte(8)
    >> idx VAR Nib
    >>
    >>
    >> Then modify your receive code like this:
    >>
    >> Read_Data:
    >> SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    >> DEBUG CLS
    >> FOR idx = 0 TO 7
    >> DEBUG HEX2 result(idx)
    >> NEXT
    >> STOP
    >>
    >> -- Jon Williams
    >> -- Applications Engineer, Parallax
    >> -- Dallas Office
    >>
    >>
    >>
    Original Message
    >> From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    >> Sent: Friday, April 16, 2004 4:15 PM
    >> To: basicstamps@yahoogroups.com
    >> Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    >>
    >>
    >> Jon: I tried that (see below). it still returns "$7C". thanks
    >>
    >>
    >____________________________________________________________________
    >>
    >> result VAR Byte
    >> '1 loop through SEROUT/SERIN
    >> SendData:
    >> SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    >> ReadData:
    >> SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    >10,
    >> store in variable "result"
    >> DEBUG CLS, HEX? result 'convert to HEX and display...result =
    >> $E5 should be 7F0000000836A410<CR>
    >> STOP
    >> No_Data:
    >> DEBUG CLS, "Timed out"
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >> --- In basicstamps@yahoogroups.com, "Jon Williams"
    ><jwilliams@p...>
    >> wrote:
    >> > Perhaps you're sending it an unexpected or incorrectly formatted
    >> > instruction....
    >> >
    >> > Since the BASIC Stamp stores everything as a number anyway,
    >prevent
    >> > possible errors when sending ASCII characters by simply embedding
    >> that
    >> > character. Like this:
    >> >
    >> > SendData:
    >> > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    >> >
    >> > And, according to my BASIC Stamp, the ASCII code for "S" is 83,
    >> not 82.
    >> >
    >> > -- Jon Williams
    >> > -- Applications Engineer, Parallax
    >> > -- Dallas Office
    >> >
    >> >
    >> >
    Original Message
    >> > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    >> > Sent: Friday, April 16, 2004 2:05 PM
    >> > To: basicstamps@yahoogroups.com
    >> > Subject: [noparse][[/noparse]basicstamps] capturing variable
    >> >
    >> >
    >> > I'm trying to communicate with an asynchronous device via SERIN
    >> and
    >> > SEROUT. It's communicating, but returns an unexpected result.
    >> > instead of giving me the expected 8byte ASCII hexadecimal
    >string,
    >> I
    >> > get $7C. any idea why?
    > > >
    >> > thanks for the help. Steve
    >> > _________________________________________________________________
    >> > '{$STAMP BS2p}
    >> >
    >> > ' declare variable
    >> > result VAR Byte
    >> >
    >> > SendData:
    >> > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    >> >
    >> > ReadData:
    >> > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    >> 10,
    >> > 'store in
    >> variable "result"
    >> > DEBUG CLS, HEX? result 'convert to HEX and display...
    >> > 'result = $7C
    >> > 'should be 7F0000000836A410<CR> STOP
    >> > No_Data:
    > > > DEBUG CLS, "Timed out"
    >>
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-17 05:43
    After you get that all squared away, you can try the SERIN SPSTR
    modifier to put that string into scratchpad memory and save yourself
    some space. To learn more click Help|Contents on the menu of the
    Stamp editor.

    It has been said that SPSTR only works with fixed length strings.
    Well, I use it for variable length strings. You can e-mail me at
    FrankSmith512@y... if you need to learn how to do that. I only
    read a very small amount of the posts. E-mail will be your best bet.

    Best Wishes,
    Frank




    --- In basicstamps@yahoogroups.com, "stenote" <stepnote@c...> wrote:
    > back to the books. I need to digest this whole thing and see which
    > way is up. the device was referred to in "stamp 2' page 46,
    > and 'was' the Point Six, Inc HA7S 1-wire interface, which
    apparently
    > now belongs to "Embedded Data Systems."
    >
    > thanks for all the help, guys, I may be back at you in a day or two.
    >
    > Steve
    >
    > __________________________________________________________________
    >
    > --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    > wrote:
    > > Well, there's nothing wrong with your BASIC Stamp code -- you may
    > need
    > > to check for the correct baud parameter (I see that Stephen has
    > > addressed that) and what the actual output from your mystery
    > device is.
    > >
    > > -- Jon Williams
    > > -- Applications Engineer, Parallax
    > > -- Dallas Office
    > >
    > >
    > >
    Original Message
    > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > Sent: Friday, April 16, 2004 6:08 PM
    > > To: basicstamps@yahoogroups.com
    > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > >
    > >
    > > Jon: looks like it should work, I understand about capturing the
    > > first byte, makes sense. Here's what I tried, but now it "times
    > out"
    > >
    > > thanks, Steve
    > >
    > >
    > > '{$STAMP BS2p}
    > >
    > > ' declare variable
    -
    > -
    > >
    > > result VAR Byte(8)
    > > idx VAR Nib
    > >
    > > 'loop through SEROUT/SERIN
    > > SendData:
    > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > >
    > > ReadData:
    > > SERIN 10, 16624, 1000, No_Data, [noparse][[/noparse]STR result\8]
    > > FOR idx = 0 TO 7
    > > DEBUG HEX2 result(idx)
    > > NEXT
    > > STOP
    > >
    > > No_Data:
    > > DEBUG CLS, "Timed out"
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > <jwilliams@p...>
    > > wrote:
    > > > Aha ... you're only capturing the first byte. Create an eight-
    > byte
    > > > array, then use the STR modifier to capture it. Like this:
    > > >
    > > > result VAR Byte(8)
    > > > idx VAR Nib
    > > >
    > > >
    > > > Then modify your receive code like this:
    > > >
    > > > Read_Data:
    > > > SERIN 10, 16624, 2000, No_Data, [noparse][[/noparse]STR result\8]
    > > > DEBUG CLS
    > > > FOR idx = 0 TO 7
    > > > DEBUG HEX2 result(idx)
    > > > NEXT
    > > > STOP
    > > >
    > > > -- Jon Williams
    > > > -- Applications Engineer, Parallax
    > > > -- Dallas Office
    > > >
    > > >
    > > >
    Original Message
    > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > Sent: Friday, April 16, 2004 4:15 PM
    > > > To: basicstamps@yahoogroups.com
    > > > Subject: [noparse][[/noparse]basicstamps] Re: capturing variable
    > > >
    > > >
    > > > Jon: I tried that (see below). it still returns "$7C". thanks
    > > >
    > > >
    > >
    > ____________________________________________________________________
    > > >
    > > > result VAR Byte
    > > > '1 loop through SEROUT/SERIN
    > > > SendData:
    > > > SEROUT 9,16624,[noparse][[/noparse]"S"] 'sending ASCII "S" at 9600,N,8,1
    > > > ReadData:
    > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on pin
    > > 10,
    > > > store in variable "result"
    > > > DEBUG CLS, HEX? result 'convert to HEX and display...result
    > =
    > > > $E5 should be 7F0000000836A410<CR>
    > > > STOP
    > > > No_Data:
    > > > DEBUG CLS, "Timed out"
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > --- In basicstamps@yahoogroups.com, "Jon Williams"
    > > <jwilliams@p...>
    > > > wrote:
    > > > > Perhaps you're sending it an unexpected or incorrectly
    > formatted
    > > > > instruction....
    > > > >
    > > > > Since the BASIC Stamp stores everything as a number anyway,
    > > prevent
    > > > > possible errors when sending ASCII characters by simply
    > embedding
    > > > that
    > > > > character. Like this:
    > > > >
    > > > > SendData:
    > > > > SEROUT 9, 16624, [noparse][[/noparse]"S"]
    > > > >
    > > > > And, according to my BASIC Stamp, the ASCII code for "S" is
    83,
    > > > not 82.
    > > > >
    > > > > -- Jon Williams
    > > > > -- Applications Engineer, Parallax
    > > > > -- Dallas Office
    > > > >
    > > > >
    > > > >
    Original Message
    > > > > From: stenote [noparse][[/noparse]mailto:stepnote@c...]
    > > > > Sent: Friday, April 16, 2004 2:05 PM
    > > > > To: basicstamps@yahoogroups.com
    > > > > Subject: [noparse][[/noparse]basicstamps] capturing variable
    > > > >
    > > > >
    > > > > I'm trying to communicate with an asynchronous device via
    SERIN
    > > > and
    > > > > SEROUT. It's communicating, but returns an unexpected
    result.
    > > > > instead of giving me the expected 8byte ASCII hexadecimal
    > > string,
    > > > I
    > > > > get $7C. any idea why?
    > > > >
    > > > > thanks for the help. Steve
    > > > >
    > _________________________________________________________________
    > > > > '{$STAMP BS2p}
    > > > >
    > > > > ' declare variable
    -
    > -
    > > > > result VAR Byte
    > > > >
    > > > > SendData:
    > > > > SEROUT 9,16624,[noparse][[/noparse]82] 'sending ASCII "S" at 9600,N,8,1
    > > > >
    > > > > ReadData:
    > > > > SERIN 10,16624,2000, No_Data, [noparse][[/noparse]result] 'read the input on
    > pin
    > > > 10,
    > > > > 'store in
    > > > variable "result"
    > > > > DEBUG CLS, HEX? result 'convert to HEX and display...
    > > > > 'result = $7C
    > > > > 'should be 7F0000000836A410<CR>
    > STOP
    > > > > No_Data:
    > > > > DEBUG CLS, "Timed out"
    > > >
    > > >
    > > >
    > > > 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
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > This message has been scanned by WebShield. Please report SPAM
    > to
    > > > abuse@p...
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > This message has been scanned by WebShield. Please report SPAM to
    > > abuse@p...
Sign In or Register to comment.