LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

visa serial port and while loop

Solved!
Go to solution

Hi,

 

using the shift register helped, thank you for that Smiley Happy

I also deleted the wait and the byte at serial port, and the programm is still working.

Thank you all

0 Kudos
Message 51 of 55
(1,064 Views)

Glad we could help.

0 Kudos
Message 52 of 55
(1,036 Views)

As we have said, the idea of the Wait and Bytes at Port came from NI's example. If you don't want to use Bytes at Port to handle the case where no data is received (cable unplugged, instrument off, wrong baud rate, etc.), you will have to handle the timeout error which will occur in that case. Are you doing that?

 

You can try it with my example. If you wire up a large number to the byte count of the VISA Read and disconnect or power off your serial instrument, you will get this error message when you click the Stop button, as I do:

 

Timeout error.png

 

If you wire Bytes at Port to byte count, you won't get the error because you told the VISA read there was nothing to read, so it returns (continues) gracefully.

 

I modified my vi by adding a Boolean control which, if True, wires 0 to the Wait and 1000 to the byte count. If False, Bytes at Port is connected to byte count. That way I can test both methods easily. I call that control "Max Speed Test" because it runs "open loop" as fast as the instrument can respond.

0 Kudos
Message 53 of 55
(1,030 Views)

Thanks for sharing the .vi file. I was looking for it and couldn't find it anywhere.

0 Kudos
Message 54 of 55
(634 Views)

Atapour,

 

Glad it helped. (This is the first addition to this forum thread in 5 years!)

 

(On page 1 of this thread Dennis said, "Shift registers are a basic concept and are shown in numerous examples and tutorials." Yes, that is true, but I haven't seen anywhere that this is applied specifically to NI's Serial Write and Read type example. As I said, I got it from a NI phone tech support person (who himself had to research it internally) when I first started using LabVIEW. I also agree that NI (if you are listening) need to update serial examples. But I haven't checked in a while so I don't know where this stands. But since Atapour asked this question, I assume he did research this and found only this post.)

 

Cheers!

Ed

0 Kudos
Message 55 of 55
(602 Views)