You need to set the Termination Character Enable, Termination Character, and Serial End Mode for Writes properties in the
NI-VISA driver.
- Create a VISA property node by right-clicking the block diagram and selecting Instrument I/O»VISA»Advanced»VISA Property Node.
- Expand the VISA Property Node to accommodate three properties.
- Right-click on the property node and select Change All to Write.
- To select a Property: right click on 'Property' and select Select Property»Message Based Settings»Termination Character Enable.
- Select second property by right-clicking and selecting Select Property»Message Based Settings»Termination Character.
- Select third property by right-clicking and selecting Select Property»Serial Settings»End Mode for Writes.
- Wire a True constant to the TermChar En property.
- Wire the decimal value of the ASCII character you want to append to the TermChar property. The decimal value for Linefeed is 10 and for Carriage Return is 13. The End of Line character is a combination of Carriage Return followed by Linefeed and is not supported as a termination character through this method. For an alternate approach that allows for multiple termination characters or if you are unsure of the ASCII value of the termination character, please see this white paper on Termination Characters in NI-VISA.
- Right-click the ASRL End Out property and select Create»Constant. This will create the enum of terminal character options. Select TermChar from the enum list.
All of your writes will now be automatically terminated with that character.
Additional Information
- Note: TermChar En and TermChar are for reading only, and TermChar En must be set to true in order to set the TermChar Property. Alternatively, ASRL End Out is for reading and writing.
Alternatively, you can use the Concatenate Strings function to build the string to send to the serial port. LabVIEW has three commonly used termination characters that are string constants in the Strings function palette: the Carriage Return Constant, the Line Feed Constant, and the End of Line Constant.
If you need something other than the pre-made LabVIEW constants, you can always create your own. Create a String Constant on your block diagram and right-click on it. Select '\' Codes Display from the pop-up menu. Now you can use the Codes Display format. See the Termination Character Codes Table below for more information.
Termination Character Codes Table
Termination Characters | Codes Display |
Linefeed (LF) |
\n
|
Carriage return (CR) |
\r
|
End of Line (EOL) |
\r\n
|
Form feed (FF) |
\f
|
- Keep in mind that termination on the physical hardware needs to comply with the appropriate Serial standard. If the termination on the physical component is incorrect then it will cause issues with termination characters on the software side.