Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with understanding the programming of a 9481 Relay Output

I am confused about how to program a cDAQ NI 9481 module.  I have the lower two relays connected (of the four available).  In LabVIEW, I have an Initial Array function with boolean FALSE connected to element.  I'm guessing that the dimension size should be "four" because there are four channels, but the code that I inherited uses "one".  I follow that with two "Insert Into Array" functions, both with "new element set TRUE, one with index "zero" and one with index "one".  The inherited code uses indices "one" and "two".  I'm told the inherited code works.  I can't test it right now... no access to hardware.  Any thoughts on whether the inherited code is good or is my approach the correct method?

0 Kudos
Message 1 of 7
(3,765 Views)

Hi Dark Hollow-

 

     You can actually simulate your hardware by right-clicking on Devices and Interfaces in MAX and selecting Create New»Simulated DAQmx Device.  Then you can test your code as you develop it with a simulated 9481.

 

     The way you describe your code will create a 6-channel array.  When you use the Insert Into Array function, it will insert an element at the index you specify and simply push other elements out of the way (as opposed to just replacing it).  So inserting two elements into a 4 element array will make a 6 element array.  Instead what you can do is select the dimension size to be 0 and just insert the two trues into the array, then you can just pick the two channels you are writing to as your physical channel constants. 

 

     The way you describe the code you inherited seems to me that it would create a 3 element array, which would work, but you would just need to pick three of the four available channels as your physical channels.

 

     I hope this helps.  Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
Message 2 of 7
(3,747 Views)

I had no idea about the hardware simulator.  That's great.  I eventually got on some hardware today and played with the device.  I soon realized that the implementation was less than intuitive.  I changed the implementation to initialize a 4 element array and then used "subtitute array" instead of "insert array" to set the non-zero bits.  Much better.  I also carry the array forward and use it over and over, just switching bits when necessary.  The previous code actually recreated the array each time it was needed.

 

Is it possible to read the Relay Output module?  Must be, but I can't find a user guide that discusses software operation of the module.  It's all hardware stuff... mechanical / electrical specs.

 

DH

0 Kudos
Message 3 of 7
(3,741 Views)

Dark Hollow-

 

     Here is a blurb from the NI 9481 Operating Instructions and Specifications Guide:

 

 

Each channel has an LED that indicates the state of the channel.

When a channel LED is lit, the channel is on. When the LED is

dark, the channel is off. The LEDs are disabled when the chassis

is in sleep mode.

 

 

 

 

     Is this what you meant by 'reading' the output?  The outputs are either on or off, and the LED will indicate that.  I hope this helps.  Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(3,703 Views)

I would like to be able to "read" the state of the digital output via code.  I know that when I set it, I know what state it is in.  But there critical applications where I'd like the program to be able to verify the state of the relay.

 

DH

0 Kudos
Message 5 of 7
(3,686 Views)

Dark Hollow-

 

     There is unfortunately no way to programmatically read the output state of the channels.  You can read the output state if you have a digital input module and read the signal that way.

 

     Have a great day!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,668 Views)

Hi Dark Hollow,

 

You actually can read back the current output state.  You simply call read on your output task.  This will not work with simulated devices.  See this thread for details.

0 Kudos
Message 7 of 7
(3,663 Views)