Skip to content Skip to navigation

Connexions

You are here: Home » Content » Serial Write & Read VI

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

    • External bookmarks
  • E-mail the author

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • National Instruments

    This module is included in aLens by: National InstrumentsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "A full introductory course on programming with LabVIEW."

    Click the "National Instruments" link to see all content affiliated with them.

Also in these lenses

  • Printable Books

    This module is included inLens: Connexions Books Available for Print on Demand
    By: ConnexionsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "This book is available through the Connexions beta version of print-on-demand from online materials."

    Click the "Printable Books" link to see all content selected in this lens.

Recently Viewed

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Serial Write & Read VI

Module by: National Instruments

Summary: For this exercise, the objective is to build a VI that communicates with an RS-232 device. Complete the following steps to use the Instrument I/O Assistant to build a VI that communicates with the NI Instrument Simulator.

NI Instrument Simulator

  1. Power off the NI Instrument Simulator and configure it to communicate through the serial port by setting the following switches on the side of the box.
    Figure 1
    Figure 1 (simserial.png)
    These switch settings configure the instrument as a serial device with the following settings:
    • Baud rate=9,600 Baud rate 9,600
    • Data bits=8 Data bits 8
    • Parity=no parity Parity no parity
    • Stop bits=1 Stop bits 1
    • Flow control parameters=hardware handshaking Flow control parameters hardware handshaking
    Handshaking is a means of data flow control. Software handshaking involves embedding control characters in transmitted data. For example, XON/XOFF flow control works by enclosing a transmitted message between the two control characters XON and XOFF. Hardware handshaking uses voltages on physical wires to control data flow. The RTS and CTS lines of the RS-232 device are frequently used for this purpose. Most lab equipment uses hardware handshaking.
  2. Make sure the NI Instrument Simulator is connected to a serial port on the computer with a serial cable. Make a note of the port number.
  3. Power on the NI Instrument Simulator. The Power, Ready, and Listen LEDs are lit to indicate that the device is in serial communication mode.

Block Diagram

  1. Open a blank VI and build the block diagram shown in Figure 2.
    Figure 2
    Figure 2 (Serialbd.png)
    1. ioassist.png Place the Instrument I/O Express VI, located on the Functions>>Input palette, on the block diagram. Complete the following steps in the Instrument I/O Assistant dialog box that appears to configure the Express VI.
      1. Choose COM1 (or COM2 depending on the connection port of the NI Instrument Simulator) from the Select an instrument pull-down menu.
      2. Click the Add Step button and click Write. In the command field, type *IDN? and select \n as the Termination character.
      3. Click the Add Step button and click Read and Parse.
      4. Click the Add Step button and click Read and Parse again.

        Note:

        The Instrument Simulator returns the byte size of the response, the termination character, the response, then another termination character. Therefore, after *IDN? is sent to the instrument, the response must be read twice.
      5. Click the Run button (not the Run this step button). The Run button runs the entire sequence.
      6. Return to the first Read and Parse step.
      7. Click the Auto parse button. The value returned is the size in bytes of the query response.
      8. Rename Token to String Length in the Token name text box.
      9. Select the second Read and Parse step.
      10. Click the Auto parse button. The value returned is the identification string of the NI Instrument Simulator.
      11. Rename Token to String in the Token name text box. The configuration window should be similar to the Figure 3.
        Figure 3
        Figure 3 (IOSerial.png)
      12. Select OK to return to the block diagram.
    2. Right-click the String output and select Create>>Indicator from the shortcut menu.
    3. Right-click the String Length output and select Create>>Indicator from the shortcut menu.

      tip:

      Since LabVIEW is set to handle errors automatically, there is no need to connect a Simple Error Handler VI to error out.
  2. Display the front panel and run the VI.
  3. Save the VI as Serial Communication.vi in the C:\Exercises\LabVIEW Basics I directory.
  4. Close the VI when finished.

Comments, questions, feedback, criticisms?

Send feedback