Example Code

Operate Relays on NI Switch Modules by Relay Number

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Modular Instrumentation

    Software

  • LabVIEW

    Driver

  • NI DAQmx
  • Other

Code and Documents

Attachment

Overview

The attached VIs allows you to control relays on NI switch modules using their unique relay numbers.

 

Description

These VIs allow relays to operate by number, rather than by the assigned software names. This could be useful to assign relay positions as part of a large array.  This is useful for all topologies, but is especially useful for SPDT relays. Both NI-DAQmx and NI-Switch compatible VIs are provided.

  

Requirements

Software

  LabVIEW 2012 (or compatible)

  NI Switch Driver 4.6 (or compatible), or DAQmx 9.6 (or compatible)

Hardware

  NI switch module

 

Steps to Implement or Execute Code

  1. Download the attached Zip File
  2. Extract the files from the Zip File
  3. Decide if you are using the NI-DAQmx or NI-Switch Driver. The following pictures and steps describe using the NI-Switch, although the steps are similar for using the NI-DAQmx
  4. Open the NI-Switch folder
  5. Open the Example.vi there:
    • Select your NI-Switch Module and the Relay Number and Run the VI.
    • Note you do not want to run the example each time you need to open and close a relay.  In your specific application open a switch session and then call the Opencloserelaybynumber.vi. For DAQmx simply drop the open close really whenever you need it. 
  6. If you are unsure of what relay numbers correspond to what channels, please use the attached LookupRelayNumber.vi
    • To Use this VI simply select your NI-Switch module and run the VI.

 

Refer to the NI Switches Help for the valid channel names for your switch module.

 

I/O Connections Overview:

Refer to the NI Switches Getting Started Guide and NI Switches Help for information about connecting signals to your switch module.

 

 

Additional Information or References

  NI-Switch Example Block Diagram

153-1.png

 

NI-Switch Open Close Relay by Number Block Diagram

153-3.png

 

NI-Switch Look Up Relay Number Block Diagram

153-2.png 

Note: This page includes switch code written with the switching palette of the NI-DAQmx driver. In the past, you were able to program NI switches with either the NI-DAQmx or NI-SWITCH driver. As of 2015, the NI-DAQmx switching palette is not recommended for new designs and NI strongly recommends using the NI-SWITCH driver for new designs. For more information, please review the following document: What Drivers Can I Use to Program My NI Switch Modules?

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

-John Sullivan
Problem Solver

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.