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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Port problems - carriage return and use as an executable

Solved!
Go to solution

Hi,

 

I developed an application to send a few simple commands over the serial port and to read the corresponding responses from a device that I am communicating with.  I have been using Logic Port to watch the TX line of the serial port.

 

Using the Visa Configure Serial Port i set the Enable Termination Character property to True and used the hex value D to try to make the termination character a carriage return.  When I sent the command i would send the cmd followed by Enter.  No matter if this property was set to true or the hex value was set to D for carriage return or A for line feed, the serial port would always send a line feed.

 

I then got crafty and changed the String constant from normal display to Hexadecimal display.  The ONLY way I could send a carriage return was by manually putting 0x0D after the command.  So my question is, why is the Visa Configure Serial Port not working properly and is there a preferred way to send a carriage return?

 

My next issue has to deal with building executables.  I am using LabVIEW 8.2 and wrote this program for another co-worker to use on his laptop.  I had him install the Labview 8.2 Runtime engine and pointed him to the executable that I generated.  I made the executable by simply clicking Tools -> Build Executable.  The problem that I noticed was that the executable would open and run fine, but it would not send any data out over the serial port.  I then ran the executable on my laptop (which contains the full version of LabVIEW 8.2) and the serial port worked fine.  I guess my question is....Are there any plug-ins that need to be installed to use the serial port with the Labview runtime engine?  Or is there a step that I have failed to do?

 

Thanks,

Gary Still

0 Kudos
Message 1 of 10
(7,870 Views)
Solution
Accepted by topic author glstill

Did not delve into the first issue. The Knight will probably gallop up shortly.

 

For your second issue, after building the executable, you need to build the installer and include support for VISA. VISA is required for serial communications, and it won't accept American Express.

 

Hope it helps

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 10
(7,865 Views)

Hi

Visa is not making an error, its definition is: not adding the endcharacter to a message.

The reason I don't know and you are not the first to make this mistake.

The only reason could be that now multipart messages are possible, but that is only a guess.

 

succes and good luck

greetings from the Netherlands
0 Kudos
Message 3 of 10
(7,863 Views)

Thank you for the quick response.  I have never built an installer, do you think you can explain to me how to do this? and how to include support for VISA?

 

Thanks,

Gary

0 Kudos
Message 4 of 10
(7,856 Views)
I am not sure if I understand what you mean by its definition is making an error.  If I type the command and press enter, it does add on the LF regardless of the termination character that I have specified.
0 Kudos
Message 5 of 10
(7,855 Views)

The Enable termination character does nothing for a write. The data is sent exactly the way you entered it. The LF is sent because you use the enter key. The termination character is for a read. If the character is detected, the read will stop.

 

If you want to automatically append a character on a write, you need to write to the ASRL End Out property. Look at the shipping example called Advanced Serial Write and Read.

0 Kudos
Message 6 of 10
(7,846 Views)

is there an easier way to type in a carriage return instead of changing the string constant from normal to hexadecimal display and tacking on the 0D?

 

can someone also explain how to build an installer and provide support for VISA serial?

 

 

Thanks,

Gary

0 Kudos
Message 7 of 10
(7,828 Views)

There are several ways. One, is to use the technique I mentioned and as used in the shipping example. You don't have to type anything into your string control/constant. Another way is set the string control/constant for '\' Codes Dispay and use \r or \n (CR or LF). Another way is to place a concantanate string function on the block diagram and use one of the constants on the string palette.

 

In the project explorer, under build specifications, you add New Installer and for Additional Installers, at the very minimum you want to have the LabVIEW run-time, the NI-VISA run-time, the NI-VISA Configuration Support. I would also recomend MAX and going to the Hardware configuration and exporting your current config so that it can be imported to a new pc.

0 Kudos
Message 8 of 10
(7,823 Views)

Hi- I had the exact same experience as glstill when building an executable containing a serial port control. The executable simply connects to the serial port. No errors, no warnings, it just didn't work. I then spent much time trying to figure it out, coming to this board and trial and error. I think Dennis has answered the question (linking VISA in the installer), but now I have to go try it out and see if it works. My question is- Why is there no manual (or is there?) to read on how to do this stuff? Given that there was no error noted, how can NI expect someone to quickly fiigure stuff like this out to get the job done? Trolling the boards is not an efficient way to try to figure out every little question. After spending a thousand dollars for the installer SW, it sure would be nice if it came with a nice big digital manual that told us how to use it. Especially when things like this serial port are possible. Hopelly someone will laugh and send me a link to a manual I have never been able to find. If so, thanks very much.

 

0 Kudos
Message 9 of 10
(7,471 Views)

TryingOut,

 

While looking at the documentation for Application Builder, I saw that you are correct in that there is not a simple explanation for why one would include additional installers.  The reason that additional installers are often used is that the controller running the VI making driver calls needs to have that driver installed in order to be able to make the calls.  Often, when distributing applications, the client machines do not have necessary drivers and so those drivers can be put in the installer.

 

I will take this valuable feedback from you and look at how we can improve the documentation available.  I know that this is a question often posed by our customers.

 

I've listed the documents below that currently cover this topic.  Have you seen these?

 

LabVIEW Help

 

Including Additional National Instruments Installers in an Installer Build

 

Additional Installers Page (Installer Properties Dialog)

 

KnowledgeBase

 

How Can I Include Additional Installers with My LabVIEW Applications Installer?

 

Regards,

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer
0 Kudos
Message 10 of 10
(7,439 Views)