Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

using carriage return instead of line feed in serial comm's

My serial device needs a carriage return to terminate read and write strings. I try to use the visa configure serial port vi to set it to hex D, i.e. CR, but to no avail. I can apparently write to the device because when i go read the buffer in hyperterminal or matlab i get the commands i sent. I just can not read it. When i open a visa session in max, and include a \r at the end of my write commands i can read from the device, so i know it will work with labview. i do get a timeout error in MAX even though it reads the line of data in the buffer. Any one encounter this before?
0 Kudos
Message 1 of 7
(3,835 Views)
Hello,
So it seems that you are not being able to read any data from your device in labview. If yes, then you should check your configuration settings in your configure serial port vi. Also, you can use visa read and write for your serial communication.
If not, then could you please restate your problem so I could assist you further?
Thank you and have a great day!
Good luck.
Koninika
National Instruments
0 Kudos
Message 2 of 7
(3,835 Views)
Koninika,
My device gives out a carriage return at the end of the data line to tell whatever software is reading it to stop reading. for some reason (and I have configured it with visa serial port configure.vi) it won't remember to look for a carriage return and ends up timing out. is there a way to force the serial port read (i've also tried using the VISA vi's) to look for the carriage return?
Robby
I have attached my vi
0 Kudos
Message 3 of 7
(3,835 Views)
Hello Robby,
In order for you to force your serial port read to detect the carriage return you need to create 3 properties from your visa open vi.
1)Serial settings property->serial end mode for read (set it to 2 or create a constant of termination charater)
2)Message based settings property ->termination charater enable ->make it true
3)Message based settings property->termination charater property (set ascii value to 13 - Table of ASCII characters and their code equivalents)
I am attaching a simple vi which illustrates the implementation of the above steps.
Let me know if you have any further qu
estions.
Good luck and have a great day!
Koninika
National Instruments
0 Kudos
Message 4 of 7
(3,835 Views)
I have labview 6. Can you convert the executable for me?
0 Kudos
Message 5 of 7
(3,835 Views)
It sounds like the problem may be when you are writing the command. Are you sure you're appending a carriage return to your write commands? Setting the termchar won't do that automatically.

And don't forget that even if you do put "\r" at the end of your string, the LabVIEW string may be interpreting that as 2 characters instead of 1. Make sure your strings are in hex mode (or any mode other than just ASCII). The reason it worked in MAX/VISAIC is because that window interprets "\r" and sends just a single character, the carriage return.

You can verify this by using NI Spy. Look at the data that is written and view the buffer window. Then you will know for sure.

Dan Mondrik
National Instruments
0 Kudos
Message 6 of 7
(3,835 Views)
Hello Robby,
I am attaching the previous VI in labview 6.0. Please check it out and let me know if you have any further questions.
Good luck and have a great day!
Koninika
National Instruments
0 Kudos
Message 7 of 7
(3,835 Views)