Shop OBEX P1 Docs P2 Docs Learn Events
Serial real-time with PC to BS2 — Parallax Forums

Serial real-time with PC to BS2

ArchiverArchiver Posts: 46,084
edited 2002-11-27 23:23 in General Discussion
Here's my BS2 code. This works as expected when I run it from the
BS2 editor and send the commands entered through the keyboard.

*********************************
' {$STAMP BS2 }


PIN_CMD VAR BIT


Again:
TOGGLE 10
SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC PIN_CMD]
DEBUG CLS, ? PIN_CMD

IF PIN_CMD = 1 THEN TurnOn
IF PIN_CMD = 0 THEN TurnOff
GOTO Again


TurnOn:
HIGH 0
DEBUG CLS, BIN1 IN0
GOTO Again


TurnOff:
LOW 0
DEBUG CLS, BIN1 IN0
GOTO Again


NoData:
DEBUG CR, "no data received"
GOTO Again


*************************

All I'm trying to do now, is to get any programming language to
interface with the serial port to do the control.

following is my matlab code.

>> s1 = serial('COM1', 'Baudrate', 9600)

Serial Port Object : Serial-COM1

Communication Settings
Port: COM1
BaudRate: 9600
Terminator: LF

Communication State
Status: closed
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0

>> fopen(s1)
??? Error using ==> serial/fopen
Error using ==> fopen
Port: COM1 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected
to the requested device.

>> instrfind

Instrument Object Array

Index: Type: Status: Name:
1 serial closed Serial-COM1
2 serial closed Serial-COM1


I've tried it w/ using a C++ serial port library, and it doesn't
work either. I'm not sure my library is any good, since it's just a
shareware version I found online. Do you know of any good but free
libraries around?

-Nigel

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-11-27 17:09
    Do you have Visual Basic? I know it works with VB and I have an example
    posted to the files section on yahoo groups. I'm sure you can get the
    matlab to do it too - I am no help there though.

    mkl

    Original Message
    From: Nigel <kailar88@y...>
    Date: Wednesday, November 27, 2002 10:45 am
    Subject: [noparse][[/noparse]basicstamps] Serial real-time with PC to BS2

    >
    > Here's my BS2 code. This works as expected when I run it from the
    > BS2 editor and send the commands entered through the keyboard.
    >
    > *********************************
    > ' {$STAMP BS2 }
    >
    >
    > PIN_CMD VAR BIT
    >
    >
    > Again:
    > TOGGLE 10
    > SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC PIN_CMD]
    > DEBUG CLS, ? PIN_CMD
    >
    > IF PIN_CMD = 1 THEN TurnOn
    > IF PIN_CMD = 0 THEN TurnOff
    > GOTO Again
    >
    >
    > TurnOn:
    > HIGH 0
    > DEBUG CLS, BIN1 IN0
    > GOTO Again
    >
    >
    > TurnOff:
    > LOW 0
    > DEBUG CLS, BIN1 IN0
    > GOTO Again
    >
    >
    > NoData:
    > DEBUG CR, "no data received"
    > GOTO Again
    >
    >
    > *************************
    >
    > All I'm trying to do now, is to get any programming language to
    > interface with the serial port to do the control.
    >
    > following is my matlab code.
    >
    > >> s1 = serial('COM1', 'Baudrate', 9600)
    >
    > Serial Port Object : Serial-COM1
    >
    > Communication Settings
    > Port: COM1
    > BaudRate: 9600
    > Terminator: LF
    >
    > Communication State
    > Status: closed
    > RecordStatus: off
    >
    > Read/Write State
    > TransferStatus: idle
    > BytesAvailable: 0
    > ValuesReceived: 0
    > ValuesSent: 0
    >
    > >> fopen(s1)
    > ??? Error using ==> serial/fopen
    > Error using ==> fopen
    > Port: COM1 is not available. No ports are available.
    > Use INSTRFIND to determine if other instrument objects are
    > connected
    > to the requested device.
    >
    > >> instrfind
    >
    > Instrument Object Array
    >
    > Index: Type: Status: Name:
    > 1 serial closed Serial-COM1
    > 2 serial closed Serial-COM1
    >
    >
    > I've tried it w/ using a C++ serial port library, and it doesn't
    > work either. I'm not sure my library is any good, since it's just
    > a
    > shareware version I found online. Do you know of any good but
    > free
    > libraries around?
    >
    > -Nigel
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-27 17:22
    Our StampPlot program can be used for real time data acquisition and
    control. And best of all, a Standard license is free to
    home/education users.

    I can give you help on using it for what you want too.

    http://www.selmaware.com/stampplot

    For example, you can read checkbox and control a BS2 output with:
    DEBUG "!READ (CHK1)",CR
    SERIN 84,16,[noparse][[/noparse]DEC PIN_CMD],CR

    We've just posted a page with plenty of BS2 code discussions.
    http://www.selmaware.com/stampPlot_v3/example_gen_use.htm

    -Martin


    --- In basicstamps@y..., "Nigel" <kailar88@y...> wrote:
    >
    > Here's my BS2 code. This works as expected when I run it from the
    > BS2 editor and send the commands entered through the keyboard.
    >
    > *********************************
    > ' {$STAMP BS2 }
    >
    >
    > PIN_CMD VAR BIT
    >
    >
    > Again:
    > TOGGLE 10
    > SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC PIN_CMD]
    > DEBUG CLS, ? PIN_CMD
    >
    > IF PIN_CMD = 1 THEN TurnOn
    > IF PIN_CMD = 0 THEN TurnOff
    > GOTO Again
    >
    >
    > TurnOn:
    > HIGH 0
    > DEBUG CLS, BIN1 IN0
    > GOTO Again
    >
    >
    > TurnOff:
    > LOW 0
    > DEBUG CLS, BIN1 IN0
    > GOTO Again
    >
    >
    > NoData:
    > DEBUG CR, "no data received"
    > GOTO Again
    >
    >
    > *************************
    >
    > All I'm trying to do now, is to get any programming language to
    > interface with the serial port to do the control.
    >
    > following is my matlab code.
    >
    > >> s1 = serial('COM1', 'Baudrate', 9600)
    >
    > Serial Port Object : Serial-COM1
    >
    > Communication Settings
    > Port: COM1
    > BaudRate: 9600
    > Terminator: LF
    >
    > Communication State
    > Status: closed
    > RecordStatus: off
    >
    > Read/Write State
    > TransferStatus: idle
    > BytesAvailable: 0
    > ValuesReceived: 0
    > ValuesSent: 0
    >
    > >> fopen(s1)
    > ??? Error using ==> serial/fopen
    > Error using ==> fopen
    > Port: COM1 is not available. No ports are available.
    > Use INSTRFIND to determine if other instrument objects are
    connected
    > to the requested device.
    >
    > >> instrfind
    >
    > Instrument Object Array
    >
    > Index: Type: Status: Name:
    > 1 serial closed Serial-COM1
    > 2 serial closed Serial-COM1
    >
    >
    > I've tried it w/ using a C++ serial port library, and it doesn't
    > work either. I'm not sure my library is any good, since it's just
    a
    > shareware version I found online. Do you know of any good but free
    > libraries around?
    >
    > -Nigel
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-27 18:46
    This looks real nice Martin, I would like to print this out
    but it is a little too wide to fit onto a page, what can I
    do to print it correctly.

    larry

    Original Message
    From: "Martin Hebel" <martin@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 27, 2002 9:22 AM
    Subject: [noparse][[/noparse]basicstamps] Re: Serial real-time with PC to BS2


    > Our StampPlot program can be used for real time data
    acquisition and
    > control. And best of all, a Standard license is free to
    > home/education users.
    >
    > I can give you help on using it for what you want too.
    >
    > http://www.selmaware.com/stampplot
    >
    > For example, you can read checkbox and control a BS2
    output with:
    > DEBUG "!READ (CHK1)",CR
    > SERIN 84,16,[noparse][[/noparse]DEC PIN_CMD],CR
    >
    > We've just posted a page with plenty of BS2 code
    discussions.
    > http://www.selmaware.com/stampPlot_v3/example_gen_use.htm
    >
    > -Martin
    >
    >
    > --- In basicstamps@y..., "Nigel" <kailar88@y...> wrote:
    > >
    > > Here's my BS2 code. This works as expected when I run
    it from the
    > > BS2 editor and send the commands entered through the
    keyboard.
    > >
    > > *********************************
    > > ' {$STAMP BS2 }
    > >
    > >
    > > PIN_CMD VAR BIT
    > >
    > >
    > > Again:
    > > TOGGLE 10
    > > SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC
    PIN_CMD]
    > > DEBUG CLS, ? PIN_CMD
    > >
    > > IF PIN_CMD = 1 THEN TurnOn
    > > IF PIN_CMD = 0 THEN TurnOff
    > > GOTO Again
    > >
    > >
    > > TurnOn:
    > > HIGH 0
    > > DEBUG CLS, BIN1 IN0
    > > GOTO Again
    > >
    > >
    > > TurnOff:
    > > LOW 0
    > > DEBUG CLS, BIN1 IN0
    > > GOTO Again
    > >
    > >
    > > NoData:
    > > DEBUG CR, "no data received"
    > > GOTO Again
    > >
    > >
    > > *************************
    > >
    > > All I'm trying to do now, is to get any programming
    language to
    > > interface with the serial port to do the control.
    > >
    > > following is my matlab code.
    > >
    > > >> s1 = serial('COM1', 'Baudrate', 9600)
    > >
    > > Serial Port Object : Serial-COM1
    > >
    > > Communication Settings
    > > Port: COM1
    > > BaudRate: 9600
    > > Terminator: LF
    > >
    > > Communication State
    > > Status: closed
    > > RecordStatus: off
    > >
    > > Read/Write State
    > > TransferStatus: idle
    > > BytesAvailable: 0
    > > ValuesReceived: 0
    > > ValuesSent: 0
    > >
    > > >> fopen(s1)
    > > ??? Error using ==> serial/fopen
    > > Error using ==> fopen
    > > Port: COM1 is not available. No ports are available.
    > > Use INSTRFIND to determine if other instrument objects
    are
    > connected
    > > to the requested device.
    > >
    > > >> instrfind
    > >
    > > Instrument Object Array
    > >
    > > Index: Type: Status: Name:
    > > 1 serial closed Serial-COM1
    > > 2 serial closed Serial-COM1
    > >
    > >
    > > I've tried it w/ using a C++ serial port library, and it
    doesn't
    > > work either. I'm not sure my library is any good, since
    it's just
    > a
    > > shareware version I found online. Do you know of any
    good but free
    > > libraries around?
    > >
    > > -Nigel
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-27 19:17
    Sorry about that, the image had pushed my borders out.
    Cleaned it up, thanks, try it again.

    -Martin


    --- In basicstamps@y..., "Larry Gaminde" <lgaminde@t...> wrote:
    > This looks real nice Martin, I would like to print this out
    > but it is a little too wide to fit onto a page, what can I
    > do to print it correctly.
    >
    > larry
    >
    >
    Original Message
    > From: "Martin Hebel" <martin@s...>
    > To: <basicstamps@y...>
    > Sent: November 27, 2002 9:22 AM
    > Subject: [noparse][[/noparse]basicstamps] Re: Serial real-time with PC to BS2
    >
    >
    > > Our StampPlot program can be used for real time data
    > acquisition and
    > > control. And best of all, a Standard license is free to
    > > home/education users.
    > >
    > > I can give you help on using it for what you want too.
    > >
    > > http://www.selmaware.com/stampplot
    > >
    > > For example, you can read checkbox and control a BS2
    > output with:
    > > DEBUG "!READ (CHK1)",CR
    > > SERIN 84,16,[noparse][[/noparse]DEC PIN_CMD],CR
    > >
    > > We've just posted a page with plenty of BS2 code
    > discussions.
    > > http://www.selmaware.com/stampPlot_v3/example_gen_use.htm
    > >
    > > -Martin
    > >
    > >
    > > --- In basicstamps@y..., "Nigel" <kailar88@y...> wrote:
    > > >
    > > > Here's my BS2 code. This works as expected when I run
    > it from the
    > > > BS2 editor and send the commands entered through the
    > keyboard.
    > > >
    > > > *********************************
    > > > ' {$STAMP BS2 }
    > > >
    > > >
    > > > PIN_CMD VAR BIT
    > > >
    > > >
    > > > Again:
    > > > TOGGLE 10
    > > > SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC
    > PIN_CMD]
    > > > DEBUG CLS, ? PIN_CMD
    > > >
    > > > IF PIN_CMD = 1 THEN TurnOn
    > > > IF PIN_CMD = 0 THEN TurnOff
    > > > GOTO Again
    > > >
    > > >
    > > > TurnOn:
    > > > HIGH 0
    > > > DEBUG CLS, BIN1 IN0
    > > > GOTO Again
    > > >
    > > >
    > > > TurnOff:
    > > > LOW 0
    > > > DEBUG CLS, BIN1 IN0
    > > > GOTO Again
    > > >
    > > >
    > > > NoData:
    > > > DEBUG CR, "no data received"
    > > > GOTO Again
    > > >
    > > >
    > > > *************************
    > > >
    > > > All I'm trying to do now, is to get any programming
    > language to
    > > > interface with the serial port to do the control.
    > > >
    > > > following is my matlab code.
    > > >
    > > > >> s1 = serial('COM1', 'Baudrate', 9600)
    > > >
    > > > Serial Port Object : Serial-COM1
    > > >
    > > > Communication Settings
    > > > Port: COM1
    > > > BaudRate: 9600
    > > > Terminator: LF
    > > >
    > > > Communication State
    > > > Status: closed
    > > > RecordStatus: off
    > > >
    > > > Read/Write State
    > > > TransferStatus: idle
    > > > BytesAvailable: 0
    > > > ValuesReceived: 0
    > > > ValuesSent: 0
    > > >
    > > > >> fopen(s1)
    > > > ??? Error using ==> serial/fopen
    > > > Error using ==> fopen
    > > > Port: COM1 is not available. No ports are available.
    > > > Use INSTRFIND to determine if other instrument objects
    > are
    > > connected
    > > > to the requested device.
    > > >
    > > > >> instrfind
    > > >
    > > > Instrument Object Array
    > > >
    > > > Index: Type: Status: Name:
    > > > 1 serial closed Serial-COM1
    > > > 2 serial closed Serial-COM1
    > > >
    > > >
    > > > I've tried it w/ using a C++ serial port library, and it
    > doesn't
    > > > work either. I'm not sure my library is any good, since
    > it's just
    > > a
    > > > shareware version I found online. Do you know of any
    > good but free
    > > > libraries around?
    > > >
    > > > -Nigel
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@y...
    > > from the same email address that you subscribed. Text in
    > the Subject and Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-27 23:23
    Thanks so much, it printed just perfect.

    Larry
    Original Message
    From: "Martin Hebel" <martin@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: November 27, 2002 11:17 AM
    Subject: [noparse][[/noparse]basicstamps] Re: Serial real-time with PC to BS2


    > Sorry about that, the image had pushed my borders out.
    > Cleaned it up, thanks, try it again.
    >
    > -Martin
    >
    >
    > --- In basicstamps@y..., "Larry Gaminde" <lgaminde@t...>
    wrote:
    > > This looks real nice Martin, I would like to print this
    out
    > > but it is a little too wide to fit onto a page, what can
    I
    > > do to print it correctly.
    > >
    > > larry
    > >
    > >
    Original Message
    > > From: "Martin Hebel" <martin@s...>
    > > To: <basicstamps@y...>
    > > Sent: November 27, 2002 9:22 AM
    > > Subject: [noparse][[/noparse]basicstamps] Re: Serial real-time with PC to
    BS2
    > >
    > >
    > > > Our StampPlot program can be used for real time data
    > > acquisition and
    > > > control. And best of all, a Standard license is free
    to
    > > > home/education users.
    > > >
    > > > I can give you help on using it for what you want too.
    > > >
    > > > http://www.selmaware.com/stampplot
    > > >
    > > > For example, you can read checkbox and control a BS2
    > > output with:
    > > > DEBUG "!READ (CHK1)",CR
    > > > SERIN 84,16,[noparse][[/noparse]DEC PIN_CMD],CR
    > > >
    > > > We've just posted a page with plenty of BS2 code
    > > discussions.
    > > >
    http://www.selmaware.com/stampPlot_v3/example_gen_use.htm
    > > >
    > > > -Martin
    > > >
    > > >
    > > > --- In basicstamps@y..., "Nigel" <kailar88@y...>
    wrote:
    > > > >
    > > > > Here's my BS2 code. This works as expected when I
    run
    > > it from the
    > > > > BS2 editor and send the commands entered through the
    > > keyboard.
    > > > >
    > > > > *********************************
    > > > > ' {$STAMP BS2 }
    > > > >
    > > > >
    > > > > PIN_CMD VAR BIT
    > > > >
    > > > >
    > > > > Again:
    > > > > TOGGLE 10
    > > > > SERIN 16, 16468, 5000, NoData, [noparse][[/noparse]WAIT("cmd: "), DEC
    > > PIN_CMD]
    > > > > DEBUG CLS, ? PIN_CMD
    > > > >
    > > > > IF PIN_CMD = 1 THEN TurnOn
    > > > > IF PIN_CMD = 0 THEN TurnOff
    > > > > GOTO Again
    > > > >
    > > > >
    > > > > TurnOn:
    > > > > HIGH 0
    > > > > DEBUG CLS, BIN1 IN0
    > > > > GOTO Again
    > > > >
    > > > >
    > > > > TurnOff:
    > > > > LOW 0
    > > > > DEBUG CLS, BIN1 IN0
    > > > > GOTO Again
    > > > >
    > > > >
    > > > > NoData:
    > > > > DEBUG CR, "no data received"
    > > > > GOTO Again
    > > > >
    > > > >
    > > > > *************************
    > > > >
    > > > > All I'm trying to do now, is to get any programming
    > > language to
    > > > > interface with the serial port to do the control.
    > > > >
    > > > > following is my matlab code.
    > > > >
    > > > > >> s1 = serial('COM1', 'Baudrate', 9600)
    > > > >
    > > > > Serial Port Object : Serial-COM1
    > > > >
    > > > > Communication Settings
    > > > > Port: COM1
    > > > > BaudRate: 9600
    > > > > Terminator: LF
    > > > >
    > > > > Communication State
    > > > > Status: closed
    > > > > RecordStatus: off
    > > > >
    > > > > Read/Write State
    > > > > TransferStatus: idle
    > > > > BytesAvailable: 0
    > > > > ValuesReceived: 0
    > > > > ValuesSent: 0
    > > > >
    > > > > >> fopen(s1)
    > > > > ??? Error using ==> serial/fopen
    > > > > Error using ==> fopen
    > > > > Port: COM1 is not available. No ports are available.
    > > > > Use INSTRFIND to determine if other instrument
    objects
    > > are
    > > > connected
    > > > > to the requested device.
    > > > >
    > > > > >> instrfind
    > > > >
    > > > > Instrument Object Array
    > > > >
    > > > > Index: Type: Status: Name:
    > > > > 1 serial closed Serial-COM1
    > > > > 2 serial closed Serial-COM1
    > > > >
    > > > >
    > > > > I've tried it w/ using a C++ serial port library,
    and it
    > > doesn't
    > > > > work either. I'm not sure my library is any good,
    since
    > > it's just
    > > > a
    > > > > shareware version I found online. Do you know of
    any
    > > good but free
    > > > > libraries around?
    > > > >
    > > > > -Nigel
    > > >
    > > >
    > > > To UNSUBSCRIBE, just send mail to:
    > > > basicstamps-unsubscribe@y...
    > > > from the same email address that you subscribed. Text
    in
    > > the Subject and Body of the message will be ignored.
    > > >
    > > >
    > > > Your use of Yahoo! Groups is subject to
    > > http://docs.yahoo.com/info/terms/
    > > >
    > > >
    >
    >
    > 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.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
Sign In or Register to comment.