Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT Hex Numbers — Parallax Forums

SEROUT Hex Numbers

haljuhalju Posts: 7
edited 2010-02-24 22:39 in BASIC Stamp
Hello everyone, its my first time using the BS2 and its prolly a noob question but im having some trouble with SEROUT hex numbers here's what my code looks like...

VarHeaderCombo VAR Word

VarHeaderCombo = $0466


SEROUT 16, 188, [noparse][[/noparse]VarHeaderCombo]


and my output is...

Byre Received at 9:49:35 PM : 48 msec: 66


I've declared it a "Word" so i would think i should get all 4 digits, however as you can see im only getting "66"

Can someone shed some light on this?

thanks!!!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-02-23 03:04
    Serout outputs Bytes so to get a word out you need two outputs. Take a look at the help file in the editor for the serout (and serin) commands for help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • haljuhalju Posts: 7
    edited 2010-02-23 12:59
    well is there any way to get them to send with out a delay? for example

    SEROUT 16, 188, [noparse][[/noparse]VALUE, VALUE]

    This will send the two bytes like you mentioned but it will put about 100msec delay between. This was what i tried first.

    Im trying to send commands to a x10 powerline controller and it wants 0x04 0x66 basically at the same time. I scanned the manual for a concatenate function however i didnt see one.

    thanks,
    Josh
  • AmaralAmaral Posts: 176
    edited 2010-02-23 13:32
    I never timed it, but you can try "STR ByteArray {\L}" and check if it goes without this delay in between
  • haljuhalju Posts: 7
    edited 2010-02-23 15:25
    Amaral - Thanks. I tried it but, it sends each byte in the string separately 100msecs apart

    So there is no way to concatenate? or to serout 3 bytes at once?

    Post Edited (halju) : 2/23/2010 3:37:50 PM GMT
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-02-23 16:36
    In the array form I've seen an extra delay of 150 microseconds. (That from the end of first stop bit to leading edge of next start bit) At 4800 baud, that amounts to less than one extra stop bit. I'm surprised that the controller is that picky. Direct concatenation of 1 stop bit would be as close as they could be to "at the same time".
    x VAR Word
    x0 VAR x.byte0
    x=$4066
    SEROUT 16, 188, [noparse][[/noparse] STR x\2]   ' ==> ~1.72 stop bits
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • haljuhalju Posts: 7
    edited 2010-02-23 20:45
    Thanks, i'll give this a try! and yes, the controller is very picky. Its been the biggest headache project i've ever tried.
  • haljuhalju Posts: 7
    edited 2010-02-24 03:20
    Tracy- so i tried that piece of code you gave me. Its still outputting...
    Byre Received at 10:18:11 PM : 326 msec: 66
    Byre Received at 10:18:11 PM : 426 msec: 0
    Byre Received at 10:18:11 PM : 532 msec: 0

    is this what i should be getting?
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-02-24 05:21
    I'm not familiar with the controller. What is $4066 supposed to do?

    The statement as written will send out first the $66 and then the $40. What happens if you send it $6640 instead of $4066? What happens if you send it
    SEROUT 16, 188, [noparse][[/noparse]HEX4 $4066] ' 4 ascii hex bytes instead of 2 binary bytes
    That is, you have to be sure of the format. It might expect BCD, huh?

    In the message, "Byre Received at 10:18:11 PM : 326 msec: 66"?, what does the 326 msec signify? The messages seem to be about 100 milliseconds apart.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • haljuhalju Posts: 7
    edited 2010-02-24 12:55
    The controller wants to receive...
    [noparse][[/noparse]0x04] [noparse][[/noparse]0x66] - Address A1 (A1 is a house code, device code)

    I have a homemade program similar to hyper terminal, i've "talked" to the controller. So i know it will only accept HEX numbers, and i know how fast it wants the numbers.

    "In the message, "Byre Received at 10:18:11 PM : 326 msec: 66"?, what does the 326 msec signify?"

    That is a output from my home made program. I connect the bs2 to this program so i can see what exactly im sending, the format its sending, and how fast they are sending.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-02-24 13:12
    "Im trying to send commands to a x10 powerline controller "

    There is an "XOUT" command.· Is it inappropriate?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-02-24 22:39
    Hi Josh , is there an error in your "home made program" that you should receive 66,0 and 0 I was wondering why it never registered the 4 and why it suggested it received 3 bytes instead of two.
    I'm not familiar with the X 10 protocol but did look at a few docs and did come across the exact example you quote , the docs that I read indicated that after the header (Ox4 , Ox66) the device would return a checksum (Ox6A). Did you try sending the header to the device and seeing if the device returned anything

    VarHeaderCombo VAR Byte(2)
    VarHeaderCombo(0) = $04
    VarHeaderCombo(1) = $66
    SEROUT 16, 188, [noparse][[/noparse]STR VarHeaderCombo\2]
    

    the code above will transmit the header as the protocol requires, it just needs a SERIN to follow and capture the checksum if it comes

    Jeff T.

    EDIT: another thought , using the programming port for communication the Stamp will echo back the data it receives , if the device is frequently sending data to· the Stamp the echo·may confuse the device. Something to consider.

    Post Edited (Unsoundcode) : 2/24/2010 11:01:25 PM GMT
Sign In or Register to comment.