Shop OBEX P1 Docs P2 Docs Learn Events
Basic SEROUT SERIN question — Parallax Forums

Basic SEROUT SERIN question

ArchiverArchiver Posts: 46,084
edited 2004-06-14 14:49 in General Discussion
I have what i think is a very basic question. I am trying to use a
Basic stamp 2 to controll a water bath/Circulator(PolyScience 9112).
It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
send out a comand to turn on the bath i.e.:
SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
That works fine, but the problem lies on the SERIN. When a camand
such as the one above is sent the bath replys with an ASCII '!' to
say that its been recived. so I'm trying to do the following:

SerData VAR BYTE

SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
PAUSE 25
SERIN 1, 16780,[noparse][[/noparse]SerData]
DEBUG SerData

OR

SerData VAR BYTE

SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
SERIN 1, 16780,[noparse][[/noparse]SerData]
DEBUG SerData

The problem is i never see the ! in the debug window or even when i
have hyperterminal connected in parallel.

Idealy I want to be able to send out a that will respond in the
temprature 'xxx.xx'

SO anyone out there have any idea why I'm not seeing that '!' comming
back?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-06-11 05:05
    This is from the help menu in the Stamp editor...

    Rpin is a variable/constant/expression* (0 - 16) that specifies the
    I/O pin through which the serial data will be received. This pin will
    be set to input mode. On the BS2, BS2e, BS2sx, BS2p and BS2pe, if
    Rpin is set to 16, the BASIC Stamp uses the dedicated serial-input
    pin (SIN, physical pin 2), which is normally used by the Stamp Editor
    during the download process.

    Did you mean to use an Rpin value of 16 instead of 1?

    If you are using the dedicated serial i/o use 16. Otherwise, I
    believe you need to be using two different pins.

    I am new to the Stamp, but it just caught me off guard that you were
    using the same pin for input and output.

    Good luck,
    Frank




    --- In basicstamps@yahoogroups.com, "pueet" <pueet@y...> wrote:
    > I have what i think is a very basic question. I am trying to use a
    > Basic stamp 2 to controll a water bath/Circulator(PolyScience
    9112).
    > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    > send out a comand to turn on the bath i.e.:
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > That works fine, but the problem lies on the SERIN. When a camand
    > such as the one above is sent the bath replys with an ASCII '!' to
    > say that its been recived. so I'm trying to do the following:
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > PAUSE 25
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > OR
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > The problem is i never see the ! in the debug window or even when i
    > have hyperterminal connected in parallel.
    >
    > Idealy I want to be able to send out a that will respond in the
    > temprature 'xxx.xx'
    >
    > SO anyone out there have any idea why I'm not seeing that '!'
    comming
    > back?
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-11 07:05
    Pueet,

    You don't want the pause between the SERIN and SEROUT commands. You said
    that the unit you are connecting to can use ether inverted or true. Do you
    know which it returns? Is it the same as is transmitted to it, or does it
    have a jumper to set it, or is it always one or the other? So you might try
    396 as the baud rate on the SERIN and see if it is sending back true data.

    Another guess might be that the ACK (the "!") is too fast for the Stamp to
    pick up. Do you have access to an oscilliscope? That way you could see if
    the ACK is being sent or not.

    Jonathan

    www.madlabs.info


    Original Message
    From: "pueet" <pueet@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, June 10, 2004 2:14 PM
    Subject: [noparse][[/noparse]basicstamps] Basic SEROUT SERIN question


    > I have what i think is a very basic question. I am trying to use a
    > Basic stamp 2 to controll a water bath/Circulator(PolyScience 9112).
    > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    > send out a comand to turn on the bath i.e.:
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > That works fine, but the problem lies on the SERIN. When a camand
    > such as the one above is sent the bath replys with an ASCII '!' to
    > say that its been recived. so I'm trying to do the following:
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > PAUSE 25
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > OR
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > The problem is i never see the ! in the debug window or even when i
    > have hyperterminal connected in parallel.
    >
    > Idealy I want to be able to send out a that will respond in the
    > temprature 'xxx.xx'
    >
    > SO anyone out there have any idea why I'm not seeing that '!' comming
    > back?
    >
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-11 15:42
    Yes, I think I know.

    You want to say:
    SERIN 1,16780, [noparse][[/noparse]STR SerData\1]

    Which means, get from pin 1 a single byte, as a
    'string'.

    When you get '!' with a 'plain' SERIN, SERIN
    recieves that as a 0..255 value -- actually,
    it recieves the ascii value of '!' which is
    33. So, I assume your 'debug' output is 33,
    which is the return character.

    Now, you also must know that IF the response
    begins to be sent BEFORE you issue your
    'SERIN', then the first few bits may be
    missed by the BS2. So you want to issue your
    SERIN as soon as possible -- and even that
    may not be soon enough.

    Note the SERIN will 'pend', waiting for a
    byte to be recieved, forever if you don't
    put a time-out on it.


    --- In basicstamps@yahoogroups.com, "pueet" <pueet@y...> wrote:
    > I have what i think is a very basic question. I am trying to use a
    > Basic stamp 2 to controll a water bath/Circulator(PolyScience
    9112).
    > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    > send out a comand to turn on the bath i.e.:
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > That works fine, but the problem lies on the SERIN. When a camand
    > such as the one above is sent the bath replys with an ASCII '!' to
    > say that its been recived. so I'm trying to do the following:
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > PAUSE 25
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > OR
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > The problem is i never see the ! in the debug window or even when i
    > have hyperterminal connected in parallel.
    >
    > Idealy I want to be able to send out a that will respond in the
    > temprature 'xxx.xx'
    >
    > SO anyone out there have any idea why I'm not seeing that '!'
    comming
    > back?
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-11 20:51
    Jonathan,
    Thanks for the reply, just as you suggested I connected a
    oscilliscope to the TX and RX lines and send out the command. just
    as expected i recived a signal back at about 5ms after the last data
    signal on the transmit. so once again i'm stuck at why don't i see
    the information back. even tried the 396 as you suggested. one
    thing i did noticed is that the signal i send is at a peak of about
    4.3V where the signal coming to the stamp is at about 6v. could that
    be a factor? any other suggestions?

    Justin

    --- In basicstamps@yahoogroups.com, "Jonathan Peakall"
    <jpeakall@p...> wrote:
    > Pueet,
    >
    > You don't want the pause between the SERIN and SEROUT commands. You
    said
    > that the unit you are connecting to can use ether inverted or true.
    Do you
    > know which it returns? Is it the same as is transmitted to it, or
    does it
    > have a jumper to set it, or is it always one or the other? So you
    might try
    > 396 as the baud rate on the SERIN and see if it is sending back
    true data.
    >
    > Another guess might be that the ACK (the "!") is too fast for the
    Stamp to
    > pick up. Do you have access to an oscilliscope? That way you could
    see if
    > the ACK is being sent or not.
    >
    > Jonathan
    >
    > www.madlabs.info
    >
    >
    >
    Original Message
    > From: "pueet" <pueet@y...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Thursday, June 10, 2004 2:14 PM
    > Subject: [noparse][[/noparse]basicstamps] Basic SEROUT SERIN question
    >
    >
    > > I have what i think is a very basic question. I am trying to use
    a
    > > Basic stamp 2 to controll a water bath/Circulator(PolyScience
    9112).
    > > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able
    to
    > > send out a comand to turn on the bath i.e.:
    > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > That works fine, but the problem lies on the SERIN. When a camand
    > > such as the one above is sent the bath replys with an ASCII '!' to
    > > say that its been recived. so I'm trying to do the following:
    > >
    > > SerData VAR BYTE
    > >
    > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > PAUSE 25
    > > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > > DEBUG SerData
    > >
    > > OR
    > >
    > > SerData VAR BYTE
    > >
    > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > > DEBUG SerData
    > >
    > > The problem is i never see the ! in the debug window or even when
    i
    > > have hyperterminal connected in parallel.
    > >
    > > Idealy I want to be able to send out a that will respond in the
    > > temprature 'xxx.xx'
    > >
    > > SO anyone out there have any idea why I'm not seeing that '!'
    comming
    > > back?
    > >
    > >
    > >
    > >
    > > 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
    > >
    > >
    > >
    > >
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-12 01:40
    Justin,

    You say that you have checked the TX/RX pins, so it sounds like they are
    seperate pins (one for TX, on for RX) but your code lookes at the same pin
    for both TX and RX. Is this correct?

    I would think the Stamp would tolerate the extra 1V, but I could be wrong.
    Theroretically one shouldn't ever input more than 5V. If that were the case,
    maybe trying a RS232 chip would make it work, as this would change the
    voltage to 5V. Still I don't think that is it.

    I assume that your code is hanging when waiting for the ACK? I would also
    think that 5mS is enough time for the Stamp to get the ACK. Any experts out
    there know if this is true?

    Jonathan

    www.madlabs.info



    Original Message
    From: "pueet" <pueet@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, June 11, 2004 12:51 PM
    Subject: [noparse][[/noparse]basicstamps] Re: Basic SEROUT SERIN question


    > Jonathan,
    > Thanks for the reply, just as you suggested I connected a
    > oscilliscope to the TX and RX lines and send out the command. just
    > as expected i recived a signal back at about 5ms after the last data
    > signal on the transmit. so once again i'm stuck at why don't i see
    > the information back. even tried the 396 as you suggested. one
    > thing i did noticed is that the signal i send is at a peak of about
    > 4.3V where the signal coming to the stamp is at about 6v. could that
    > be a factor? any other suggestions?
    >
    > Justin
    >
    > --- In basicstamps@yahoogroups.com, "Jonathan Peakall"
    > <jpeakall@p...> wrote:
    > > Pueet,
    > >
    > > You don't want the pause between the SERIN and SEROUT commands. You
    > said
    > > that the unit you are connecting to can use ether inverted or true.
    > Do you
    > > know which it returns? Is it the same as is transmitted to it, or
    > does it
    > > have a jumper to set it, or is it always one or the other? So you
    > might try
    > > 396 as the baud rate on the SERIN and see if it is sending back
    > true data.
    > >
    > > Another guess might be that the ACK (the "!") is too fast for the
    > Stamp to
    > > pick up. Do you have access to an oscilliscope? That way you could
    > see if
    > > the ACK is being sent or not.
    > >
    > > Jonathan
    > >
    > > www.madlabs.info
    > >
    > >
    > >
    Original Message
    > > From: "pueet" <pueet@y...>
    > > To: <basicstamps@yahoogroups.com>
    > > Sent: Thursday, June 10, 2004 2:14 PM
    > > Subject: [noparse][[/noparse]basicstamps] Basic SEROUT SERIN question
    > >
    > >
    > > > I have what i think is a very basic question. I am trying to use
    > a
    > > > Basic stamp 2 to controll a water bath/Circulator(PolyScience
    > 9112).
    > > > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able
    > to
    > > > send out a comand to turn on the bath i.e.:
    > > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > > That works fine, but the problem lies on the SERIN. When a camand
    > > > such as the one above is sent the bath replys with an ASCII '!' to
    > > > say that its been recived. so I'm trying to do the following:
    > > >
    > > > SerData VAR BYTE
    > > >
    > > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > > PAUSE 25
    > > > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > > > DEBUG SerData
    > > >
    > > > OR
    > > >
    > > > SerData VAR BYTE
    > > >
    > > > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > > > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > > > DEBUG SerData
    > > >
    > > > The problem is i never see the ! in the debug window or even when
    > i
    > > > have hyperterminal connected in parallel.
    > > >
    > > > Idealy I want to be able to send out a that will respond in the
    > > > temprature 'xxx.xx'
    > > >
    > > > SO anyone out there have any idea why I'm not seeing that '!'
    > comming
    > > > back?
    > > >
    > > >
    > > >
    > > >
    > > > 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
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    >
    >
    >
    >
    > 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
    >
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-12 23:14
    --- In basicstamps@yahoogroups.com, "pueet" <pueet@y...> wrote:
    > I have what i think is a very basic question. I am trying to use a
    > Basic stamp 2 to controll a water bath/Circulator(PolyScience
    9112).
    > It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    > send out a comand to turn on the bath i.e.:
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > That works fine, but the problem lies on the SERIN. When a camand
    > such as the one above is sent the bath replys with an ASCII '!' to
    > say that its been recived. so I'm trying to do the following:
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > PAUSE 25
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > OR
    >
    > SerData VAR BYTE
    >
    > SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > SERIN 1, 16780,[noparse][[/noparse]SerData]
    > DEBUG SerData
    >
    > The problem is i never see the ! in the debug window or even when i
    > have hyperterminal connected in parallel.
    >
    > Idealy I want to be able to send out a that will respond in the
    > temprature 'xxx.xx'
    >
    > SO anyone out there have any idea why I'm not seeing that '!'
    comming
    > back?



    At the risk of adding more confusion to your life, may I suggest
    the following:

    1. You are using the same pin to both transmit and receive. Use a
    different pin for each unless you use pin 16 ( as has been pointed
    out ) If you do use pin 16, the baud parameter will be 396.

    2. Don't put the pause between Serout and serin. Once you do the
    serout, immediately setup the serin in the next line.

    3. Most importantly, use the 'WAIT' parameter so serin will wait
    around until it sees the !. What is happpening is that unless the !
    shows up at the instant the serin line executes, you miss the
    character.
    I'd suggest serin 2,16780,2000,nochar,[noparse][[/noparse]wait ("!")]
    Normally, you'd also receive other characters, but in your case,
    the only thing expected is the !. "nochar" is the label of the point
    in the program that executes if no characters are received in 2 secs.

    4. If you want confirmation on the debug screen, just add a debug
    statement after the serin line. debug "!"

    Tom Sisk
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-13 00:03
    Justin

    switching gears just a little bit here. you say your turning on bath water
    via the stamp. you must have some type of water soleniods. Don't mind me
    asking but where did you get them? I have been looking everywhere trying to
    find 12V 100psi water valves. found some someplace but they wanted an 2
    arms and 1 leg. maybe I'm wrong but thinking you can pick'em up for around
    $30.
    If you or anyone else knows where I can locate them please let me know.

    thanks
    Daryl


    At 04:14 PM 6/10/2004, you wrote:
    >I have what i think is a very basic question. I am trying to use a
    >Basic stamp 2 to controll a water bath/Circulator(PolyScience 9112).
    >It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    >send out a comand to turn on the bath i.e.:
    >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    >That works fine, but the problem lies on the SERIN. When a camand
    >such as the one above is sent the bath replys with an ASCII '!' to
    >say that its been recived. so I'm trying to do the following:
    >
    >SerData VAR BYTE
    >
    >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    >PAUSE 25
    >SERIN 1, 16780,[noparse][[/noparse]SerData]
    >DEBUG SerData
    >
    >OR
    >
    >SerData VAR BYTE
    >
    >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    >SERIN 1, 16780,[noparse][[/noparse]SerData]
    >DEBUG SerData
    >
    >The problem is i never see the ! in the debug window or even when i
    >have hyperterminal connected in parallel.
    >
    >Idealy I want to be able to send out a that will respond in the
    >temprature 'xxx.xx'
    >
    >SO anyone out there have any idea why I'm not seeing that '!' comming
    >back?
    >
    >
    >
    >
    >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
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-06-14 14:49
    Daryl,

    As for your question about the soleniods, you may have miss
    understood me when i say "water bath" what it is is this unit:
    http://www.polyscience.com/lab/9100.html
    It is used in chemical labs to put a test sample in to raise or lower
    it to a X deg temp. to see its shelf life or preasure it may put
    off. all it is, is a 6 liter tank that is filled with a liquid such
    as Ethylene Glycol (Anti-freeze) and a motor sucks the liquid up and
    pumps it back (Circulate). so there are no valves or soleniods in
    the unit. but you may whant to check through some of there other
    products and see if they have something that may to fit your need and
    contact them.
    Good Luck,
    Justin


    --- In basicstamps@yahoogroups.com, Daryl Berryhill <djberry@h...>
    wrote:
    > Justin
    >
    > switching gears just a little bit here. you say your turning on
    bath water
    > via the stamp. you must have some type of water soleniods. Don't
    mind me
    > asking but where did you get them? I have been looking everywhere
    trying to
    > find 12V 100psi water valves. found some someplace but they wanted
    an 2
    > arms and 1 leg. maybe I'm wrong but thinking you can pick'em up for
    around
    > $30.
    > If you or anyone else knows where I can locate them please let me
    know.
    >
    > thanks
    > Daryl
    >
    >
    > At 04:14 PM 6/10/2004, you wrote:
    > >I have what i think is a very basic question. I am trying to use a
    > >Basic stamp 2 to controll a water bath/Circulator(PolyScience
    9112).
    > >It uses Rs-232 (2400 8-N-1 Inverted or non-inverted) I am able to
    > >send out a comand to turn on the bath i.e.:
    > >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > >That works fine, but the problem lies on the SERIN. When a camand
    > >such as the one above is sent the bath replys with an ASCII '!' to
    > >say that its been recived. so I'm trying to do the following:
    > >
    > >SerData VAR BYTE
    > >
    > >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > >PAUSE 25
    > >SERIN 1, 16780,[noparse][[/noparse]SerData]
    > >DEBUG SerData
    > >
    > >OR
    > >
    > >SerData VAR BYTE
    > >
    > >SEROUT 1, 16780,[noparse][[/noparse]83,79,49,13]
    > >SERIN 1, 16780,[noparse][[/noparse]SerData]
    > >DEBUG SerData
    > >
    > >The problem is i never see the ! in the debug window or even when i
    > >have hyperterminal connected in parallel.
    > >
    > >Idealy I want to be able to send out a that will respond in the
    > >temprature 'xxx.xx'
    > >
    > >SO anyone out there have any idea why I'm not seeing that '!'
    comming
    > >back?
    > >
    > >
    > >
    > >
    > >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
    > >
    > >
    > >
    > >
Sign In or Register to comment.