Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication problem with USB to serial hub

Solved!
Go to solution

Hi, I'm having a communication problem when I use a NI USB-232 (778472-01) adapter to control a pressure sensor. There are many posts about this in the forum, but I'm encounting something a bit different. I am able to use MAX to fully control the instrument with the VISA test panel. So I guess the driver of the USB-232 is correctly installed. However, in labivew, even though I can select the instrument from the visa source name, it always return an error (-1073807339) when I run the program. The screen shot of labview program is attached. Could anyone kindly help me with this problem.Thanks a lot.

The system is XP SP 3 Pro.

The Labview version is 8.6.

The MAX version is 4.5.0f0.

0 Kudos
Message 1 of 11
(5,965 Views)
Where is your serial port configuration? Do you need to wait a little bit before data is available? Does it work in highlight execution mode? Do you know which VISA Read is generating the error?
0 Kudos
Message 2 of 11
(5,958 Views)

Your code doesn't show you opening the port at all.  Have you done this somewhere else or is this all of the code?

 

If you haven't opened the port previously and set Baud and parity and so on then this code most likely won't work.

 

Shane.

0 Kudos
Message 3 of 11
(5,938 Views)
Hi, thanks for the reply. The serial port for the USB to serial hub is COM3. The waiting time is not long. I try to do it in highlight execution mode, but it still doesn't work. It is the first VISA read that generates the error.
0 Kudos
Message 4 of 11
(5,924 Views)
This is the entire codes. Do you mean that I should create a visa config in the beginning? By the way, this code is working for another computer when it's is directly connected to the pressure sensor via a serial port. Thanks.
0 Kudos
Message 5 of 11
(5,923 Views)
Solution
Accepted by VZn

If the default windows port settings just happen to correspond to the settings you need for communication you can get lucky and it will work.  If just one setting is different, it won't work.

 

It's always better to set the parameters in your code.

 

Shane.

0 Kudos
Message 6 of 11
(5,919 Views)
Thanks for the reply. But could you please kindly show me an example of how to define the port in the code? I'm not quite familiar with labview.
0 Kudos
Message 7 of 11
(5,903 Views)
Just open up the "Basic Serial Write and Read" example that ships with LabVIEW. That shows you how to configure the serial port.
Message 8 of 11
(5,896 Views)
The basic visa write and read program is working. I think I just need to add the visa config in front of my program. Thanks a lot for the great help!
0 Kudos
Message 9 of 11
(5,877 Views)
Just take a look at the block diagram for that VI. You just need to copy the part that I've highlighted. Don't forget to close the port at the end of your program. If you use a loop in your code make sure the configuration and the close are outside the loop.
Message 10 of 11
(5,860 Views)