LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication works in hyperterminal but not in LabView

Hello,
I am trying to control an APP Automated Pressure Controller using LabView 6.1 via a serial connection.  I am able to control the system with Hyperterminal but not with LabView.  I set used the same setup (9600 baud, 1 stop bit, no parity, no flow control, etc) in LabView that worked in hyperterminal.

According the the documentation from the Pressure Controller: "Every character that is sent to the controller is echoed back to your computer so you can check to see everything is working.  When a valid command is given, the controller will also send a carriage return (acsii 13) followed by a line feed (ascii 10) to signify the command was executed.  Before sending any commands, the program should clear any characters in the input buffer that may be there from previous responses."

In hyperterminal, when I type in a command such as "OA", the Pressure Controller responds (without pressing enter or any other keys) and I can see the "OA" on the screen.  As soon as the Controller is done responding, the cursor moves down to the next line (which I assume is caused by the carriage return and line feed) and waits for the next command.

I have tried to use the Serial Communication.vi with no success.  Does Hyperterminal add (or Labview omit) a special character or command that I am missing?  Do I need to do something special to clear the input buffer in LabView?

Thanks for any help.
Alex
0 Kudos
Message 1 of 8
(4,139 Views)
hi there
 
do you read from the serial port after you sent the command? (see attachment)
 
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 2 of 8
(4,127 Views)
chris,
I did read back from the serial port after I sent the command.  Only the first character, "O" in the case of the "OA" command was read back.  I have LV6.1 and cannot open your attachment.  Is there someway you could save it as an older version?
thanks.
alex
0 Kudos
Message 3 of 8
(4,117 Views)
Sounds like maybe you aren't reading enough bytes back?

Here is a picture of chris's block diagram.


I think he's also hinting at the fact that maybe you didn't specify enough bytes to be read on the VISA Read vi.
0 Kudos
Message 4 of 8
(4,096 Views)
hi there
 
thanks, MJBrehm..
 
just another weird thougth: "A" in the command "OA" is the hex representation of the termination char. are you sure your device sends back the command as a string and not as binary data?
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 5 of 8
(4,078 Views)

Hello,

Try to run your application in other system (computer), frequently some PCs configurations are not recognized by LabVIEW serial routines. I do not know exactly the problem but is not the first time I know that kind of problem.

Sometimes the problem comes from the serial property called Termination Character that enables receive buffered data once you have a Carrier Return or a Line Feed symbol (Hex 0D/0A) character into the buffer. Try to set it true and assign a 0A Hex Value.

For sending information you need to finish all command message with an enter symbol concatenating both (Message + Hex 0D0A) using the special character in the string palette library. This action permits system to put out buffered data. 

Good Look

0 Kudos
Message 6 of 8
(4,065 Views)
Hello,
I got some more information from the manufacturer.  The controller is designed to echo back every byte which I send serially.  The buffer however is only 1 byte wide, so to send "CF"  I have to
1 write C
2 read C
3 write F
4 read F
Also, I found that I have to close the VISA session after each write/read cycle, otherwise things don't work.  Does anyone have an explanation?  I figured I could just do:

configure serial port
write
read
write
read
close

but instead I must

configure serial port
write
read
close
configure serial port
write
read
close

Thanks for the help.
alex

0 Kudos
Message 7 of 8
(4,020 Views)

hi there

you said "According the the documentation from the Pressure Controller: "Every character that is sent to the controller is echoed back to your computer so you can check to see everything is working.  When a valid command is given, the controller will also send a carriage return (acsii 13) followed by a line feed (ascii 10) to signify the command was executed.  Before sending any commands, the program should clear any characters in the input buffer that may be there from previous responses."

-> set the termination char to (0xA = '\n' = LF) at the VISA Configure Serial Port
-> then you have to read TWO characters: the command you sent AND the carriage return 0xD.
-> this should clear the input buffer for the next command without a need to close the port

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 8 of 8
(4,015 Views)