04-30-2014 10:36 AM
Goodmorning labview experts,
I'm trying to connect labview to a RS 232 port belonging to a lathe. I'm trying to receive and read in labview a string that the lathe should send me. Basically I'm using the visa read programm from NI Examples.
The lathe should send me the string START, the labview programm reads the string but befor the S of START the programm shows a strange character, a sort of capiatl i with two short perpendicular segment at the top and the bottom of the letter. Sometimes it show after the T also the paragraph sign, some other times it shows the same symbol but on a different line and sometime there's no paragraph sign.
I tried the two most common end character, no end character and different waiting values for the loop but the problem is still there and now I really don't know what to do.
Thank you in advance for your help.
Regards,
Lorenzo
Solved! Go to Solution.
04-30-2014 10:53 AM
The first thing I would look at is to make sure ALL of your serial settings are correct: baud rate, number of data bits, number of stop bits, handshaking lines, etc.
When is the lathe supposed to send you this string? Is it constantly putting out data or is it only from a commanded response?
04-30-2014 11:08 AM
Hi crossrulez,
I thought the same thing and I triplechecked everything, if this setting are incorrect it appears an erros message or ALL the characters displayed are wrong.
It is supposed to send the string at a precise moment, just when the fanuc controller reads the proper command.
04-30-2014 11:10 AM
First of all the attached vi should be saved to C:\Users\<You>\Documents\LabVIEW Data\Probes\
Now when you want to debug some UART you have a new custom probe available
Or, it only takes a few seconds to create the custom probe. Now you can find out exactly what your lathe is sending and compare that to the manual for the de4vice which would tell you how messages are formated so you can configure the correct termination character if it uses one
04-30-2014 11:18 AM
Just now looked at your code. If the instrument is truely sending the termination character, you should not use the Bytes At Port. Instead, just wire a really large number to the Bytes To Read input of the VISA Read. It will stop reading when the number of specified bytes are read or the termination character is found. This will help ensure your command comes in tact.
You might want to change your read display to use Hex format. You might be able to decipher something out of that.
04-30-2014 01:04 PM
I tried the probe but it shows exactly the same string as the string reader.
I also tried to see the output in hex and (\) code. The output is this:
12 53 52 54 31 0A 14 in hex
\12SRT1\n\14 in (\) code.
So at least now i'm sure that the termination character is 0xa. What i cannot explain is why there are the 12 and the 14 at the end of the messages.
04-30-2014 02:17 PM - edited 04-30-2014 02:18 PM
the term char is 0x14 (ASCii Shift Out) th 0x12 is a start of message char. (Actually a ASCii form feed) Why they chose those is unknowable. But a Trim Whitesace will get rid of them for you.
04-30-2014 06:14 PM
Thank you both for your help with your help i managed to fix the problem.
I figured out that those two char originated from the lathe code ( POPEN and PCLOS) necessary to open and close the rs port for communication.
Regards,
Lorenzo