LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

BS2sx and Labview - Hyperterminal works but LabView does not

Stamp Code:
'{$STAMP BS2sx}
'{$PBASIC 2.5}
'{$PORT COM1}

baudmode CON 240 'maybe 16624

instrg VAR Byte
instrg = 0

start:
SERIN 16,baudmode,[instrg]
SEROUT 16,baudmode,["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 smplserl example programs as well as example VI's 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
0 Kudos
Message 1 of 2
(2,355 Views)
If Hyperterminal works but LabVIEW (through VISA) does not this means usually (excluding other obvious reasons such as incorrectly set communication parameters) that your protocol expects each command or line be terminated by either a carraige return, line feed or both together. Hyperterminal adds this at the moment you hit the enter key (which is the crraige return after all).

In LabVIEW you need to specify each individual character exactly as it should be send (and that is a very good thing). So put your string constant or control into Backslash mode (popup menu->'\' Codes Display). Then enter the command you want to send and append a '\n', '\r', or '\r\n' (without quotes) to the end.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 2
(2,350 Views)