From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set COM settings in NI VISA Interactive Control

Solved!
Go to solution

Hello everybody,

I have made a custom pcb that communicate continously through RS232 with the pc (it's a one way communication from the device to LabView). I've followed the serial communication example and the .vi seems to be working fine via loopback test, but when I try to read the actual signal coming from the pcb there are zero bytes available at port.

 

I used the VISA Config block to setup the communication (9600 bps, 8 bits, no parity, 1 stop bit, no termination character) and the Buffer Size block, but in the NI Visa Interactive Control the serial port is configured to have the Transmit Buffer and the Receive Buffer sizes to be 0 and to check for a termination character (line feed)  on Reads. I tried to change the settings and I get a "no error" message, but when I apply changes and close the port window they're brought back to default values.

 

Could this be the reason I get no data in the read buffer? How can I change the Interactive Control settings?

 

Thanks in advance to everybody

0 Kudos
Message 1 of 10
(3,670 Views)

What is the "VISA Interactive Control"?  Can you provide a couple of screenshots of that show these settings and that control?

 

Perhaps attach the VI you are using?

0 Kudos
Message 2 of 10
(3,646 Views)

Here's the .vi.

The NI Visa Interactive Control is the program that let you configure port communication from an interface. I also set all the parameters I need in the .vi, but up to no success.

 

EDIT: There'd be a third screenshot of the VISA but it essentially shows that the port is set to search the termination character. Which is not what I need, since I'm transmitting a trail of bits not organized in messages.

 

2nd EDIT: Ok, the VISA Interactive Control has nothing to do with the running LabVIEW session, so I guess that can be taken away from the possible causes.

Download All
0 Kudos
Message 3 of 10
(3,631 Views)

How did you get to the "VISA Interactive Control"?  I go into Measurement and Automation Explorer, go to a serial port, and I can open the VISA Test Panel.  It looks exactly like that, but says VISA Test Panel in the title bar, not VISA Interactive Control.

 

Are things working okay when you use that dialog box?

 

Your VI has the VISA configure which will take care of everything for you.  Nothing jumps out at me there as having a problem.

 

Where I do see a problem is later in your VI.  After you flush the serial port and set the buffer size (which I don't ever find the need to do either of those myself), you read the Bytes at Port, then feed that into the loop.  It is very possible that Bytes at Port is zero at that instance.  Only if data starting arriving between the instant you change the buffer size and the instant you check the number of bytes at port could tha be greater than zero.  That zero than gets passed in the loop where it will always remain zero since it only gets read before the loop starts.

 

Try moving the Bytes at Port inside your loop.

 

 

Message 4 of 10
(3,615 Views)

Yes it's the same page that's in NI MAX. Using that dialog box has the same effect of the previous one, I change the settings but they are not memorized when reopening the port. I tried to "Run as admin" NI MAX, even if my user account has admin privileges, but I got no luck.

Can the NI MAX settings interfere with the LabVIEW processing? It would explain why there are no bytes at input, since there'd be no termination character to be found.

 

I'd already tried to move Bytes at Port inside the while loop but, following your advice, I tried again: the measured bytes at input port is again a constant zero.

 

Right now I'm back at circuit level checking the output's waveform, but it looks like everything's fine...

0 Kudos
Message 5 of 10
(3,603 Views)
Solution
Accepted by topic author senor_homme

I don't see anything in that dialog that is meant to "save" changes.  I only see apply which probably only applies while you have that test session open.

If you do want to change the "default" settings for a port, you do it with in MAX when you click on the port.  Change a setting there and you can click save.  I would never recommend to do that.  To me, the VI should be the one setting the parameters.

 

It shouldn't matter anyway.  Setting the settings in your VI will override anything that comes in as defaults by way of Windows, or MAX.

 


@senor_homme wrote:

 It would explain why there are no bytes at input, since there'd be no termination character to be found.

 



The use of the termination character has nothing to do with whether the there are bytes at the port.  The termination character (if enabled) is a method to tell when a VISA Read will come back with data.   A VISA read comes back with data whenever:

1.  The termination character arrives at the port if it has been enabled.

2.  The number of requested bytes comes back  (and requesting zero bytes means it comes back immediately with nothing.)

3.  The Timeout period has expired.

 

Have you tried seeing if your device is sending data using some other Windows terminal program that isn't LabVIEW?  Windows used to come with Hyperterminal, but it has disappeared.  I don't know what I would recommend instead.

Message 6 of 10
(3,596 Views)

it is better to use some other software like hyper terminal to test your comments if they work well then for next step start to write code in labveiw 

Message 7 of 10
(3,560 Views)

I eventually found out what's going wrong. I'm connecting the pcb to LabVIEW through a RS232-to-USB converter. When it's not plugged, the MAX232 outputs a full -8/+8 V signal swing, while when it's plugged, the signal is cut at -6V.

I will try to attach the pcb straight to a serial port and see if it does communicate that way.

 

Thank for all your kind replies, despite my messy initial post.

Download All
0 Kudos
Message 8 of 10
(3,531 Views)

That is strange.  You may want to try a different USB/RS-232 converter as well.  But hopefully if you have a traditional RS-232 9-pin serial port on your PC, that will give you the best results.  But those ports seem to be disappearing from PC's nowadays.

 

You should check the design of the serial port in your custom built PCB.  It sounds like there may be an issue with its ability to output a valid electronic signal when the load of the USB/232 adapter is placed on it.

0 Kudos
Message 9 of 10
(3,510 Views)

I think it should probably due to the power supply, which is fed by the pc through a PicKIT3, whose max output is 30mA. The pcb draws 20mA and I just found out that also the usb converter has the the same current consumption, so I guess I'm exceeding the current limit. That, or the MAX232 output stage has failed somehow.

0 Kudos
Message 10 of 10
(3,481 Views)