LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hola!!!Yesterday, I asked a question about serial port comunication, because I wanted to find a function in Labview similar to "ProcessSystem Events" in Labwindows!!

My problem is that I have written a comand through the serial port, and I doesn´t receive the answer. If I execute the programm step by step, I don´t have any problem but if the program runs i don´t get the answer!!!It is not a problem of the bytes that I write and receive, i have used the function "Visa Bytes at Serial Port"!!I have used th function "wait" but it doesn´t work!!!!i have used a Flat sequence but it hasn´t solved the problem!!so, i don´t know what i can do!!!
I attach the "different versions" that i did, maybe someone find a solution!!
Dennis, I have the problem, when
I read the last time in the program, I don´t receive the answer!thank you!!!

Gracinda
Download All
0 Kudos
Message 1 of 6
(3,101 Views)
You write your command to the port, then immediately check the bytes at port and read those. Now since the time delay between these two operations are 0 no bytes have yet arrived at the port and so the read function is asked to read 0 bytes...

If you know how many bytes the reply will consist of do not check the bytes at port but wire that number of bytes to the read, it will then wait up to 20 seconds (if I recall the VISA behaviour correct) for that number of bytes to be available. OR continously check the number of bytes and do a read when it reports the correct number of bytes (then you can make your own timeout...). If the reply has a termination character VISA can be set up to return when it has received that.If you do not know the length of the reply
nor have a termination character to rely on you can define a rpely timeout and an interbyte time limit, check the number of bytes every interbyte time and if the bytes starts to come in but there is a halt longer than the defined limit you assume the whole reply has arrived and do the read...
0 Kudos
Message 2 of 6
(3,101 Views)
The default VISA timeout if you just open the port yourself is 2 seconds. (This is a fairly standard VISA default regardless of the type of VISA resource you open.) We set it to 10 seconds by default if you use VISA Configure Serial Port VI, since most users will need slightly longer timeouts when using Serial.

Dan Mondrik
National Instruments
0 Kudos
Message 3 of 6
(3,101 Views)
Dear Mads;
Thank you for your answer.
I don´t have a termination character but I know the number of bytes that I have to receive. I tried checking the number of bytes that I received, using "Bytes at Port", but it gets a value and it isn´t refreshed, it has a value so my program stop in the while structure that I have added. I attach the vi. I don´t know how to do that. I am starting with Labview, and it is a little difficult for me!!
In the first change that I did, I added the function "Bytes at Port" inside the While loops, but it doesn´t work either :(!!!

Thank you!
0 Kudos
Message 4 of 6
(3,101 Views)
You have to put the bytes at port check inside the while loop (now it is run once immediately after the send and will report a 0 so it does not help to check if that 0 ever changes...), and then you check. Terminate the while loop when the bytes at port number gets equal or above the number of bytes you expect.
0 Kudos
Message 5 of 6
(3,101 Views)
Dear Mads;

I have put the "Bytes at port" inside the while loop, and surprise!!!it works, but in one vi it works properly, and in another vi it doesn´t work, and the programm is similar, so I am thinking that it depends on the command that I sent.So, I will see if I can find a solution!!

Thank you for everything!!

Ciao!!!
0 Kudos
Message 6 of 6
(3,101 Views)