Shop OBEX P1 Docs P2 Docs Learn Events
Hexadecimal Serial Messages — Parallax Forums

Hexadecimal Serial Messages

ArchiverArchiver Posts: 46,084
edited 2003-04-23 16:17 in General Discussion
Dear All
I am tryin to get RS 232 signals from the BS2 SX.The stamp will send
hexadecimal signals(7 byte size) of the form "FF 01 00 04 20 00 25"
Can I use the serial port avaiable with education board for this.Do
have to make any special connections??
Also will this code work(I mean is it ok if I send the hex message
like this)
SerString Var Byte(7)
SerString(0)=$FF
SerString(1)=$01
SerString(2)=$00
SerString(3)=$04
SerString(4)=$20
SerString(5)=$00
SerString(6)=$25
SEROUT 16, 240, [noparse][[/noparse]STR SerString\7]
I would be really grateful if any of you could help me
Best
Jimmy

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-04-23 07:56
    I think your code should work - but you have to try.
    You can use the serial connector from the board of education to
    transmit data between your computer and the basic stamp (I do this
    all the time in my projects). However, when sending data from
    your computer to the stamp, you have to take into account that
    the stamp echoes all characters it receives. This is beacuse the
    Rx and Tx pins are wired together on the stamp. If you use
    a terminal program you have to turn local echo off or each character
    will be displayed twice. If you make your own program, you have
    to receive and discard the echoed characters.

    Beside this, to conserve precious RAM I recommend using the
    scratchpad RAM to hold data for transmission. The send loop
    would look about like this:

    for n = 0 to (datalen - 1)
    get SPRST + n, tmp1 ' Scratch Pad Ram STart constant
    serout TxD,BAUD,[noparse][[/noparse]tmp1]
    next
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-23 15:08
    If you want to send in hex format, you'll have to send each character
    seperatedly using the HEX modifier. To match your example (with spaces
    between data bytes), I would add this to your code:

    FOR idx = 0 TO 6
    SEROUT 16, 240, [noparse][[/noparse]HEX2 serString(idx), " "]
    NEXT

    -- Jon Williams
    -- Parallax


    In a message dated 4/23/2003 12:11:39 AM Central Standard Time,
    jimmy_prett@y... writes:

    > Dear All
    > I am tryin to get RS 232 signals from the BS2 SX.The stamp will send
    > hexadecimal signals(7 byte size) of the form "FF 01 00 04 20 00 25"
    > Can I use the serial port avaiable with education board for this.Do
    > have to make any special connections??
    > Also will this code work(I mean is it ok if I send the hex message
    > like this)
    > SerString Var Byte(7)
    > SerString(0)=$FF
    > SerString(1)=$01
    > SerString(2)=$00
    > SerString(3)=$04
    > SerString(4)=$20
    > SerString(5)=$00
    > SerString(6)=$25
    > SEROUT 16, 240, [noparse][[/noparse]STR SerString\7]
    > I would be really grateful if any of you could help me
    > Best
    > Jimmy
    >



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-23 16:17
    Yes, this should work as you intend.

    Note 'Hex' may confuse some people. If you
    use: SEROUT <pin>, <BaudMode>, [noparse][[/noparse]HEX <value>] then
    <value> converted to one or more hex characters
    will be output.

    If you just output [noparse][[/noparse] $ff ], then the one byte
    containing $ff will be output, which I believe
    is what you intend.

    --- In basicstamps@yahoogroups.com, "jimmy_prett" <jimmy_prett@y...>
    wrote:
    > Dear All
    > I am tryin to get RS 232 signals from the BS2 SX.The stamp will
    send
    > hexadecimal signals(7 byte size) of the form "FF 01 00 04 20 00 25"
    > Can I use the serial port avaiable with education board for this.Do
    > have to make any special connections??
    > Also will this code work(I mean is it ok if I send the hex message
    > like this)
    > SerString Var Byte(7)
    > SerString(0)=$FF
    > SerString(1)=$01
    > SerString(2)=$00
    > SerString(3)=$04
    > SerString(4)=$20
    > SerString(5)=$00
    > SerString(6)=$25
    > SEROUT 16, 240, [noparse][[/noparse]STR SerString\7]
    > I would be really grateful if any of you could help me
    > Best
    > Jimmy
Sign In or Register to comment.