Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT format for the datalogger? — Parallax Forums

SEROUT format for the datalogger?

CheeseCheese Posts: 29
edited 2008-03-21 00:08 in BASIC Stamp
Could someone point me to a source which explains the SEROUT format for the datalogger? I've gone through the demo and test programs but haven't figured out what the format is. The documentation says that SEROUT writes the data of <size in hex(4 bytes) > to the end of the current open file. I don't understand what that means.

For example,
SEROUT TX\CTS, Baud, [noparse][[/noparse]$08, $20, $00, $00, $00, $0D, CR,
DEC5 counter, ",", DEC5 result, CR, LF, CR]

counter and result are words.


Gene

Comments

  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-03-19 00:07
    You can transmit lots of bytes in one command, and the $00,$00,$00,$0D is the number of bytes. You might look at that as $0000000D, which is 13 in hex. In this case there are 5 bytes for counter, 1 for the comma, 1 for result, and 2 for CRLF. The two other CRs are for framing only, and are not included in the count of bytes.
    $08 is the command
    $20 is an ascii space, part of the command syntax
    $00,$00,$00,$0D is the number of bytes, $0000000D = 13
    CR is part of the command syntax, ascii code 13
    ...the 13 data bytes
    CR is part of the command syntax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Chris CChris C Posts: 50
    edited 2008-03-20 01:25
    Sorry to hijack, but maybe someone can help.

    SEROUT TX, baud, ("Text" CR)

    With the above, I am getting an error because of the CR. I also tried putting a comma and it still didn't work.

    I'm trying to use the command to program an XBee module through a Stamp1.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-20 01:35
    I don't think that CR is predefined for the Stamp 1. The Stamp 1 uses a separate compiler from the Stamp 2. Try explicitly declaring it using SYMBOL. You will need the comma.
  • Chris CChris C Posts: 50
    edited 2008-03-20 01:39
    I was confused about CR. Reading the Manual, it shows CR defined for the BS1 and the BS2, without and with a comma respectively, but no matter which way I tried it wouldn't do it.

    So just define SYMBOL skipLine = CR and then use skipLine in the SEROUT?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-20 02:11
    Chris C,
    The ASCII code/value for a Carriage Return is $0D, which is 13 (decimal.)· In PBASIC1 it's: SEROUT pin, baudmode, ("text", 13)
    PBASIC Help shows CR as pre-defined.· SEROUT pin, baudmode, ("text", CR) should work.·
    pb1_serout.jpg
    However, I get that compilation error if I use the comma between "text" and CR.·
    It tokenizes OK with ("text", 13) --
    ' {$STAMP BS1}
    ' {$PBASIC 1.0}
    SEROUT 1, N2400, ("text", 13)
    



    Post Edited (PJ Allen) : 3/20/2008 2:38:39 AM GMT
  • Chris CChris C Posts: 50
    edited 2008-03-20 03:05
    Yeah, PBASIC help confused me.

    I'll have to try that though, thanks!
  • CheeseCheese Posts: 29
    edited 2008-03-20 06:10
    Sorry about delayed response (death in family)

    The issue for me is the data logger!
    I need to send a minimum of 10 samples per second to a file on the data logger drive.
    The format is comma delimited for a spread sheet.
    ##:##,##,###.#.#
    minuits:seconds,sample number,0-255 value,bit,bit,cr or line feed
    The stamp I am using is bs2px24 and the DS1302 Timekeeping Chip.I cant seem to get mS out of the chip so I will just use the second,sample number to break it down

    Thanks for keeping the post alive Hijackers welcomed
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-03-20 06:34
    So that comes out to 18 = $12 characters per record...

    SEROUT TX\CTS, Baud, [noparse][[/noparse]$08, $20, $00, $00, $00, $12, CR,HEX2 min, ":", HEX2 sec, ",",DEC2 number, ",", DEC3 value, ",",BIN1 bip, ",",BIN1 bop, CR, LF, CR]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • CheeseCheese Posts: 29
    edited 2008-03-21 00:08
    Tracy:

    Thanks so much for the input!!!
    It is working great now.
Sign In or Register to comment.