LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi!!!I need help!!I am desperated!!!The serial port makes me become crazy!!!

I send a command through the serial port, and I have any problem. I think that the problem is when I receive the answer!!!
The "odd" point is that when I execute the programm step by step, there is any problem, but when I run the vi, I don´t receive the answer.
I wrote some days ago, and people gave me some solutions. They suggested me that I had a problem of timeout, and they told me that one solution was to wait until I get the number of bytes that make up the answer using bytes at the port, and putting it inside a while loop, but it doesn´t work, well, sometimes it works and other times it doesn´t work!!!! I tried other solutions like wait time but without any result!!!

D
o you have any solution????

I attach the vi, maybe, it was useful to detect the mistake!!!!

Thank you!!

Graci
Download All
0 Kudos
Message 1 of 7
(3,595 Views)
put the wait (make sure it is long enough) in the while loop and try again.

-Joe
0 Kudos
Message 2 of 7
(3,595 Views)
Hi Bichillo,

I recommend that you quiery the serial port because how do you know that there is always 3 bytes to read? If you fix the amount of data to read to "3", then you may get an error message saying that there is more data available at the serial port.

You can try something like this.... (as a starting point).

It is a good idea to OPen the VISA seeion and to close it. (I closed it in the attached vi as an example. Take it out if you want to continue communicating with the port.)

JLV
Download All
Message 3 of 7
(3,593 Views)
I have tried this, but it sometimes works and other times not, so , it is not a good solution for me!!

Thank you!!

Graci
0 Kudos
Message 4 of 7
(3,592 Views)
Hi JLV!!

Thank you for your solution, but this vi works . The vi that doesn´t works is entrada_analogica.vi, the first one that I attached. And the problem is in the the frame 1(0...1), when I write other command and I try to read the answer, the answer is one byte,and I have to receive 10 bytes, so the vi stops in the while loop and I have to abort the execution. Do you have any idea to solve this?

Thank you!!

Graci
0 Kudos
Message 5 of 7
(3,592 Views)
Hi!!I am Bichillo again!!

I have change the while loop, and I have used the same code that you have used in the solution you have given me, but the problem now, is that I only received one byte, and I can´t understand, why I receive 10 bytes, the correct answer when I run the vi step by step ;?!!!

Thank you again!!

Graci
Download All
0 Kudos
Message 6 of 7
(3,591 Views)
The problem is when you are running step by step the programme has enough time to receive your 10 bytes. When you run the VI normal it immediatly stopped when it has received 1 or more bytes, because you used the "Not equal to 0" to stop your while loop.
It is also better to use the "Wait Until Next ms Multiple" function in a while loop.

I changed your VI and maybe it will solve your problem!
0 Kudos
Message 7 of 7
(3,590 Views)