Shop OBEX P1 Docs P2 Docs Learn Events
Serial communication — Parallax Forums

Serial communication

cclaud2cclaud2 Posts: 21
edited 2011-08-10 05:43 in BASIC Stamp
Is it possible to send multiple variables at once through serout and receive those variables by serin?

"Sender"
SEROUT SO\FC, Baud, [noparse][[/noparse]dec tempS, dec pressureS] ' send multiple variables?

"Receiver"
SERIN SI\FC, Baud, [noparse][[/noparse]dec tempR, dec pressureR] ' receive·multiple variables?

-Or how would you do this?· Any help would be greatly appreciated.
·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-21 01:18
    You just need to put a delimiter between the values on the transmit end so that the receiver can differentiate them:

    SEROUT So\Fc, Baud, [noparse][[/noparse]DEC tempS, ",", DEC pressureS]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • cclaud2cclaud2 Posts: 21
    edited 2006-04-21 23:23
    Well how would the receiver obtain and distinguish those variables?

    SEROUT So\Fc, Baud, [noparse][[/noparse]DEC tempS, ",", DEC pressureS]

    SERIN So\Fc, Baud, [noparse][[/noparse]DEC tempS,·",", DEC pressureS]· '<-- I cannot receive·
    ············································································· the·variables
    ·
  • NewzedNewzed Posts: 2,503
    edited 2006-04-21 23:38
    You can't format a serin like that.· You have to have a variable in the serin statement.· For example:

    serin......[noparse][[/noparse]temp, press]

    The Stamp would receive two bytes from the serout statement, receive the data and store what i received in temp and press.· You can then debug:

    debug dec ? temp, cr
    debug dec ? press, cr

    OK?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-21 23:46
    Make your SEROUT look like this

    · SEROUT So\Fc, Baud, [noparse][[/noparse]DEC tempS, ",", DEC pressureS, ","]

    ... and it will work -- sorry, I left the delimiter off the second variable and this is required since you're moving data between the two devices as text.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • NewzedNewzed Posts: 2,503
    edited 2006-04-22 00:08
    cclaud2, please ignore my post.· You can use a decimal formatter in a serin statement if the serout ahead of it is properly formatted.· Sorry about that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • cclaud2cclaud2 Posts: 21
    edited 2006-04-22 01:06
    I will give it a shot.· Thanks.
  • FalconFalcon Posts: 191
    edited 2011-08-10 05:43
    I found a partial answer to my latest question in this old thread while searching, so I'm going to start here.


    I have these six SEROUT text statements (see below) that I need to send to a PINK module when an event occurs. A simple webpage links to the PINK variables to fill certain table “cells”. I am monitoring 16 conditions in and around my home so all of this is multiplied by 16 and is taking up way too much space.

    They do work individually, but I want to combine SEROUT variables to minimize the code size.

        SEROUT TX, BAUD, ["!NB0W20:OPEN", CLS]                    
        SEROUT TX, BAUD, ["!NB0W21:", CLS]                         
        SEROUT TX, BAUD, ["!NB0W60:DATE and TIME", CLS]              
        SEROUT TX, BAUD, ["!NB0WES:GARAGE DOOR OPEN", CLS]        
        SEROUT TX, BAUD, ["!NB0SM",CLS]                            
        SEROUT TX, BAUD, ["!NB0ST"]                              
    
    


    I tried to combine three of them onto one line like this:

    SEROUT TX, BAUD, ["!NB0W20:OPEN", "!NB0W21:", "!NB0W60:DATE and TIME", CLS]

    That just resulted in the cell displaying this

    OPEN!
    NB0W21:!
    NB0W60:DATE
    and TIME

    Not what I want.

    This thread mentions placing "." delimiters between actual variables, whereas I am sending text "strings". Would this apply to the text as well?

    falcon
Sign In or Register to comment.