Shop OBEX P1 Docs P2 Docs Learn Events
SERIN with VB6 — Parallax Forums

SERIN with VB6

ArchiverArchiver Posts: 46,084
edited 2004-01-16 00:27 in General Discussion
I'm having trouble with a very simple program receiving data from
VB6 via SERIN. In VB6 I'm sending either a "1" or "0" to the SERIN
on my basic stamp. My settings for MScomm1 are 9600,n,8,1. Here is
my program for the Stamp:

#####################################
'{$STAMP BS2}
'{$PORT COM1}
'{$PBASIC 2.5}

datain VAR Byte

check_data:
SERIN 16,4054, [noparse][[/noparse]datain]
IF datain = "1" THEN GOTO on_sub
IF datain = "0" THEN GOTO off_sub

on_sub:
HIGH 0 ' Turn LED ON
GOTO check_data

off_sub:
LOW 0 ' Turn LED OFF
GOTO check_data
##########################################
When I click on either the send "0" or send "1" it turns the LED
on. It is suppose to turn on with "1" and off with "0". I'm sure
I'm making some simple mistake, but I've been working on this for a
week and it's bugging me!


Thanks for your help!
Adam

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-01-15 19:11
    Where did you get the '4054' for the Baud Selector?

    The manual has, on page 297, a table of baud rates
    to baud selectors.

    For 9600,n,8,1, out the '16' port, on a BS2,
    you should use:

    I9600 CON 16384 + 84 ' 16384 == 'Inverted' (with driver)
    ' 84 == 9600 baud,n,8,1
    ' OR, I9600 CON 16468

    --- In basicstamps@yahoogroups.com, "sumguy16hem" <a.przybilla@c...>
    wrote:
    > I'm having trouble with a very simple program receiving data from
    > VB6 via SERIN. In VB6 I'm sending either a "1" or "0" to the SERIN
    > on my basic stamp. My settings for MScomm1 are 9600,n,8,1. Here is
    > my program for the Stamp:
    >
    > #####################################
    > '{$STAMP BS2}
    > '{$PORT COM1}
    > '{$PBASIC 2.5}
    >
    > datain VAR Byte
    >
    > check_data:
    > SERIN 16,4054, [noparse][[/noparse]datain]
    > IF datain = "1" THEN GOTO on_sub
    > IF datain = "0" THEN GOTO off_sub
    >
    > on_sub:
    > HIGH 0 ' Turn LED ON
    > GOTO check_data
    >
    > off_sub:
    > LOW 0 ' Turn LED OFF
    > GOTO check_data
    > ##########################################
    > When I click on either the send "0" or send "1" it turns the LED
    > on. It is suppose to turn on with "1" and off with "0". I'm sure
    > I'm making some simple mistake, but I've been working on this for a
    > week and it's bugging me!
    >
    >
    > Thanks for your help!
    > Adam
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-15 19:17
    > SERIN 16,4054, [noparse][[/noparse]datain]

    that should be hex, $4054.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-15 19:51
    Once you select the correct Stamp baud rate / serial mode, it may also be
    helpful if you insert a GOTO check_data at the end of this routine to keep
    from "falling through" into the on_sub.

    check_data:
    SERIN 16,4054, [noparse][[/noparse]datain]
    IF datain = "1" THEN GOTO on_sub
    IF datain = "0" THEN GOTO off_sub
    GOTO check_data

    Regards,

    -Bruce
    tech@r...
    http://www.rentron.com

    > I'm having trouble with a very simple program receiving data from
    > VB6 via SERIN. In VB6 I'm sending either a "1" or "0" to the SERIN
    > on my basic stamp. My settings for MScomm1 are 9600,n,8,1. Here is
    > my program for the Stamp:
    >
    > #####################################
    > '{$STAMP BS2}
    > '{$PORT COM1}
    > '{$PBASIC 2.5}
    >
    > datain VAR Byte
    >
    > check_data:
    > SERIN 16,4054, [noparse][[/noparse]datain]
    > IF datain = "1" THEN GOTO on_sub
    > IF datain = "0" THEN GOTO off_sub
    >
    > on_sub:
    > HIGH 0 ' Turn LED ON
    > GOTO check_data
    >
    > off_sub:
    > LOW 0 ' Turn LED OFF
    > GOTO check_data
    > ##########################################
    > When I click on either the send "0" or send "1" it turns the LED
    > on. It is suppose to turn on with "1" and off with "0". I'm sure
    > I'm making some simple mistake, but I've been working on this for a
    > week and it's bugging me!
    >
    >
    > Thanks for your help!
    > Adam
    >
    >
    > 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 visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-15 23:47
    How would I go about sending other data i.e. strings(words) or
    longer numbers other than boolean "1" or "0" through the SERIN
    command.

    thanks,
    Adam
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-16 00:27
    Here's what you're looking for:

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/89.pdf

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: sumguy16hem [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=OP8ULMgQyufAQirIej7rNUsG5cpzJpnf86oKdLwbhZAeccDZtCN7996JIm6o7jx4XQCAVZDsiYp26a4EZ8hqJBWG]a.przybilla@c...[/url
    Sent: Thursday, January 15, 2004 5:47 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] SERIN with VB6


    How would I go about sending other data i.e. strings(words) or
    longer numbers other than boolean "1" or "0" through the SERIN
    command.

    thanks,
    Adam


    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 visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.