Example Code

Use NI-DAQmx Digital Output Lines to Control Relays in NI Switch Executive.

Code and Documents

Attachment

Overview

The provided code allows for use of an NI-DAQmx Digital Output Lines to control relays in NI Switch Executive.

Description

The provided code is an IVI-Swtch compatible IVI wrapper for NI-DAQmx modules that have digital output lines. This will allow an NI-DAQmx digital output module to be used to control relays in NI Switch Executive and other IVI-Swtch applications. The user will need to set up an IVI Instrument Driver Software Module, an IVI Driver Session, and an IVI Logical Name in order to use this as an IVI device. The attached file contains the DLL required to run the IVI-Swtch device as well as additional images for implementing the code.

Steps to Implement and Execute Code

  1. Create a software module in MAX from the attached DLL
  2. Create a Driver Session for each DAQmx Digital Device
  3. Create a Logical Name to point to the Driver Session
  4. Create an NI Switch Executive Virtual Device pointing to your new logical name
  5. Make routes in NI Switch Executive
    • When you connect "ch0_0->com0_0" you are actually driving port 0 line 0 high, and when you connect "ch1_2->com1_2" you drive port 1 line 2 high. Disconnecting this connection drives the line_port combination low.

Requirements to Run

Software

NI Switch Executive

IVI-Swtch

MAX

**NI-DAQmx 9.8 or later**

Hardware

Any NI-DAQmx module with digital output lines.

Additional Information

  • If you are driving a physical relay coil, the NI-DAQmx device may not be able to supply enough current to physically drive the relay. A device such as an Industrial DIO device may be able to supply more current [example]
  • If the NI-DAQmx device is actually driving the relay coil, when we remove power from the relay coil we may experience a "Flyback Voltage". We should use a flyback diode if we are driving the relay coil as shown here [example].
Frank,
National Instruments
Software Group Manager

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

Comments
bigyo
Member
Member
on

Works fine with a PXI-6259 DAQ card.

Thanks for the support.

bigyo

acovian
Member
Member
on

Recieved the following error. Any suggestions?

An error has occurred while attempting to access device DIO

Primary Error: (Hex 0xBFFA011) Function or method not supported.

Elaboration: FunctionId:3, FunctionName:InitWithOptions

Frank-L
NI Employee (retired)
on

Where did this error come up? In Switch Executive configuration in MAX?

Can you export a copy of your IVI configuration to confirm that the correct configuration was made (IVI Logical Names, driver session, Software Module, etc). [Open MAX, Click My Computer >> IVI Drivers, Then Click Save IVI Configuration As]

Frank,
National Instruments
Software Group Manager
acovian
Member
Member
on

Yes, it happens when I try to add the IVI Switch in the Switch Executive in MAX.

Frank-L
NI Employee (retired)
on

acovian,

Thanks!

It appears that the issue may be that the Prefix appears to be incorrectly names as "DAQmxDitigal", where the t and g has been swapped. You should update the prefix and name to fix the typo. The error is likely that it cannot find a funcation called "DAQmxDitigal_InitWithOptions", because the dll only provides "DAQmxDigital_InitWithOptions"

Also if you don't mind updating the comment above to remove the XML you copied (it made loading the example take super long)

Frank,
National Instruments
Software Group Manager
acovian
Member
Member
on

Thats it! Thanks!

Atolino
Member
Member
on

Dear Frank-L,

Your IVI tool is works very fine with mine NI-6501 device. By the way, is it possible to share the source codes for this driver?

Thanks in advance!

pdrowlan
Member
Member
on

Dear Frank-L,

Was the source code in CVI, if so, can you share the source code?

Thanks in advance!

David_Jones
Member
Member
on

Is this .dll still supported with newer versions of Switch Executive / DAQmx?  I am trying to use this to control a PXI-6509 which will be driving TTL controlled RF switches.  I get an error when adding the logical device to the SW Exec virtual device.

 

Capture.JPG

 

I am using the following:

- Switch Executive 2015

- DAQmx 18.6

KamilKosAPT
Member
Member
on

Is there any chance for source code? Or for newer version with selectable DOuts (string like in LabVIEW) if I can't use all lines of device?

 

Thanks in advance!

Contributors