LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read serial port

Hi!!!First, sorry for my english.I have a problem with the reading of the serial port. I receive the same as i send, that is to say, if I write OPEN, receipt OPEN, and want to receive what it sends to the robot when receiving the order to me. How can I do it?
 
Thanks for all.
0 Kudos
Message 1 of 12
(3,450 Views)
This may be normal if you are sending messages over a 2-wire 485 line. In this case, simply filter out your own message in the receive buffer.
Do the messages are terminated with LF? In this case you should read twice, the first read for your command, the second for the answer from the device.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 12
(3,438 Views)
First, have you tried using something like Hyperterminal to talk to the robot? That's the first thing to do and if you have tried it, does it work? Second, Are you using one of the shipping examples for serial com? Which one? Are you sending a termination character like the shipping examples do? The shipping example called Basic Serial Write and Read uses a \r and a \n which is a Carriage Return/Line Feed. If you aren't, you probably need to. If you are, are you sure that it is correct?
0 Kudos
Message 3 of 12
(3,437 Views)
Hi. Yes, i have tried with the hyperterminal, and if i use it,  the robot sends me a signal, but with my labview's program doesn't  do it. The program is very simple. I only want to do OPEN and CLOSE, so i have a text file with this orders, which  i charge from labview with "Read Characters From File.vi". I use a VISA Write like. I send you and example.
0 Kudos
Message 4 of 12
(3,425 Views)

Where's the example? You need to select the Browse button below to attach files. If you selected Insert an Image, you need to insert an image that is hosted on some server and I'm guessing your image is on your local drive. That won't work unless your local drive is a web server.

Since Hyperterminal works, then my guess is you've set up the serial port incorrectly in LabVIEW or you are not sending the termination character like I said.

0 Kudos
Message 5 of 12
(3,420 Views)
Sorry, but i'm a novice. I send you the Labview's file. Can you give me a solution?
 
Thank you very much.
0 Kudos
Message 6 of 12
(3,383 Views)
Hi Ivan77,

there is one subvi missing (modEscritura.vi) but I assume that it simply writes the string to the serial port.
You are sending a string composed of a trailing CR (output parameter bb from Match Pattern) and other characters (parameter a). Are you sure this is the correct sequence? Usually you should send the CR at the end of the command string.
I don't well understand what you are doing in the while loop: are you extracting the last line from the file?
Why don't you visualize the string you are sending? You may also select  "\" Codes Display for the indicator (right-click on it) to better show the position of the CR.
Hope this helps.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 12
(3,372 Views)
Hi pincpanter. In the while loop i'm looking for the carriage characters like "/s" or "/r", and I separate the string to have the orders what i want. For example: RUN/s, OPEN/s, etc...
 
modEscritura simply send the string by the serial port.
 
0 Kudos
Message 8 of 12
(3,365 Views)
Dear Ivan,
the character you are searching is only one: the carriage return \r (decimal code 13, hex 0D).
Sorry but I insist: you are sending  \rOPEN, shouldn't you send OPEN\r ? You didn't answer this question.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 9 of 12
(3,354 Views)

Hi pincpanter. I understand you, but if i connect "Match Pattern" and "Concatenated Strings" as you say, doesn't works, while if i connect "/rOPEN" works well except robot doesn't execute the last instruction. Sorry but I'm very confused.

 

Thanks for all.

0 Kudos
Message 10 of 12
(3,348 Views)