Shop OBEX P1 Docs P2 Docs Learn Events
Unable to do serial read from BS2sx in Labview — Parallax Forums

Unable to do serial read from BS2sx in Labview

Steve123Steve123 Posts: 9
edited 2005-04-08 16:37 in BASIC Stamp
Stamp Code:
'{$STAMP BS2sx}
'{$PBASIC 2.5}
'{$PORT COM1}

baudmode CON 240
instrg VAR Byte
instrg = 0

start:
SERIN 16,baudmode,[noparse][[/noparse]instrg]
SEROUT 16,baudmode,[noparse][[/noparse]"got_it",CR]
GOTO start

The stamp waits to receive a byte and once it does, it should send the response string. Everything works when using the BS2 debug program and when using RS232 Hex Com Tool v4.0. When I run my labview program, it sends a one byte character to Com 1, a time delay then occurs, and the port is read (using the # of bytes at port function). The returned string is only one byte long, and it turns out to be the byte that I just sent to the port instead of the expected response string. Essentially, I'm reading exactly what I have just written.
I've tried using the example labview program·from parallax, and I get the same results. I've tried modifying the BS2 program by commenting out the SERIN line, and when I read the port in labview, I receive a timeout error.

LabView 7.1
Win2k with Com 1 settings of:
Baudrate: 9600
data bits:8
parity: none
stop bits: 1
flow control: none

Labview VI is attached.
Any help?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-08 02:14
    Labview may be having a problem in that anything you send to the programming port of the BASIC Stamp gets echoed back -- you have to filter this out. If you can't, don't use the programming port -- connect an RS232 invertor and use a couple of standard IO pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Steve123Steve123 Posts: 9
    edited 2005-04-08 02:38
    Thank you. That is something I will try, but why would LabView be unable to read data if it was constantly coming into the com port?

    Even if I just use:

    '{$STAMP BS2sx}
    '{$PBASIC 2.5}
    '{$PORT COM1}

    baudmode CON 240

    start:
    SEROUT 16,baudmode,[noparse][[/noparse]"got_it",CR]
    GOTO start

    I am still unable to read any information
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-08 03:28
    Is LabView set for 9600 baud·on the port you're connected to? I know nothing about LabView -- you may need to speak with their tech support folks on connecting serial devices.· An easy program to check the output of your BASIC Stamp program is a simple terminal (e.g., HyperTerminal) program -- if you can see the messages with that then you know the Stamp end of your project is working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Steve123Steve123 Posts: 9
    edited 2005-04-08 13:09
    I can read and write data with RS232 Hex Com Tool v4.0 and everything works, but I when I try to do it with Hyperterminal private edition, nothing happens. I changed the Com bauderate to 2400 and made the corresponding changes to my program but I get the same results.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-08 14:08
    I don't know why you're having problems with HyperTerminal -- I've found it fairly straightforward.· The attached programs might help.

    Another thing to remember is that the Stamp editor's·Debug Terminal is just a specialized terminal program.· When the IDE downloads a program to the BASIC Stamp that contains the DEBUG command, the editor opens the Debug Terminal for you.· You can also do this manually.· When you do you'll have to select the Com port to use, but after that you should see your data.· Once you can verify the text coming out of the BASIC Stamp it's time to turn to the good folks at LabView for getting into their software.· I believe others have done this, but having no experience with that software myself, I don't know what needs to be done.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • BeanBean Posts: 8,129
    edited 2005-04-08 14:24
    I don't know why, but when I try to use hyperterminal with my SX-Video module it doesn't work right either.
    I tried changing every setting I could think of, but never did get it working.
    When I looked at the serial data on a scope it wasn't right, but at different baud rates it was right.

    I write a simple little DOS program to send serial data on the same port, and it worked fine.
    IOW I wouldn't totally rule out a problem with hyperterminal.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "A problem well defined, is a problem·half solved."
    ·
  • Steve123Steve123 Posts: 9
    edited 2005-04-08 16:08
    Well I can try different port settings, maybe using 2 stop bits. I have a program in VB that communicates with the stamp just fine but I need it done in labview
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-08 16:37
    Well, then, the problem is clearly with LabView. Since there have been no responses here regarding how to deal with LV, you really should consult their support resources.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.