Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Status of Digiatal output lines

I've written a vi to control 6 solenoid valves, via their associated solid state relays. I am using port 0, line 0-5.  I want to turn on Solenoid 1 for a given time (i.e 30 seconds), then turn it off and turn on solenoid 2, etc.  I'm using a stacked sequence to acomplish this.  The problem is that with this approach, I can't figure out how to monitor the status of the solenoids.  If I place an indicator on the first solenoid signal in frame 0 and the second solenoid signal in frame 1, etc, the indicator obviously won't shut off when the sequence frame is done, even though when the vi advances to frame 1 (2nd frame), the output 0 goes to 0V.  Any ideas?
0 Kudos
Message 1 of 32
(5,843 Views)
That is an awfully complex VI for such a simple task. Look at the attachment and see if it does what you want. You will also notice that the program does not create and start a DAQmx task umpteen times and that you can actually write all lines at once.
0 Kudos
Message 2 of 32
(5,829 Views)
Dennis,

Great suggestion - much more efficient! In addition, if you wish to verify that your digital lines are not being pulled away from the state you are driving, you can perform a digital read on that same task. It doesn't just read from a register - it reads the actual state of the lines. You can also program LabVIEW to make sure that the data is the same, and signal you if it is not.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 3 of 32
(5,818 Views)

Dennis and Ryan, thanks for all of your help.  I've actually not encountered a situation where I needed to build a boolean array, so this was new ground for me.  I still have a couple of questions though:

Dennis:

When I run your vi, it faults out after the 6th iteration.  I get the message:    Error – 200324 occurred at DAQmx Start Task.vi.  Device not available in NI-DAQmx.  It is possible that the device is being used by Traditional NI-DAQ or that the device is being reset.  I thought I just needed to modify three things.  I altered the Lines input to the DAQmx Create Channel, changing it from 0:7 to 0:5, as well as deleting the 6th and 7th columns from the array, since I only need outputs on lines 0-5 (6 total solenoids).  Additionally, I deleted the last two Data Written indicators, again because I only need 0-5.  No luck.  I still get the same error.

 

Ryan

 

When I run your vi, I can’t see anything at all happening.  None of the LEDs illuminate, and the vi faults out after about 12 seconds (I have the measurement duration set for 2 seconds in order to test the vi.  I’ve also saved a version of each of your vis, having replaced the Boolean controls with an array.  Again, this is the first time I’ve used a Boolean array as an input.  I’m just embarrassed to be struggling with what you two are proving is a VERY simple application.  Please forgive my extreme ignorance.

0 Kudos
Message 4 of 32
(5,811 Views)
One more question guys...how DO you create a boolean array in the first place?  I can't find any help on this?
0 Kudos
Message 5 of 32
(5,810 Views)
OK, the "Stupid alarms" are going off all over the place.  My mistake.  I had to change deveice 1 to deveice 2 in the vi.  So that is sorted out. Ryan, I'm not sure why your vi worked differently than Dennis' (the LEDs did not illuminate on your's until I changed the device number, while in Dennis' they did, even though both faulted out at the same point. ANYWAY, both seem to work ok now.  My only questions are...again, how did you build the boolean array in the first place?  Where is there an example that shows how to do this (for example explaining that the columns represent bits, while the rows represent iterations).  The other main question I have is:  is there a simple way to set the last bit (5) low before ending the vi, so that the LED goes out?
0 Kudos
Message 6 of 32
(5,804 Views)
Idiot alert...again!  OK, I figured out that columns are bits and rows are iterations, so I created another iteration and set all bits to 0, so that all LEDs are dark at the end.  The only problem with that is that if I'm measuring for 30 seconds per iteration, there will be a 30 second delay between when I am done and when the vi stops.  Any hints for a cleaner approach? 
0 Kudos
Message 7 of 32
(5,802 Views)
Dan,

To create a boolean array, simply drop a button into an array shell (on the front panel) or a boolean terminal into an array constant (on the block diagram).

Are you using Traditional NI-DAQ (Legacy) at all with your device? Do you have any other programs running at the same time? Perhaps it would help to reset the Traditional driver in MAX (Right click on Traditional NI-DAQ Devices and select Reset Driver). Then, reset your device in NI-DAQmx (Right click on the device under NI-DAQmx Devices and select Reset Device). You should then be able to run a Self Test from the same location. If this passes, you should be good to go.

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 8 of 32
(5,800 Views)
Dan,

You could conditionally execute the wait and not do so on the last iteration of the loop. You could compare the iteration of the loop (the blue "i") with the size of the array minus one (size starts at 1, while loops are 0 indexed). If they are not equal, then execute the wait (put it inside of a case strucutre), and if they are equal, don't.

Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 9 of 32
(5,796 Views)

Hi dan,

I am doing something similar to what you have done, and because I am new to labview, I am bit confused on how to go about it.

I tried looking at your code you attached, but it would not open cos mine is labview 7.0.

I am trying to control 6 solenoids and dont have a clue on how to use D/O function, can you or anyone else help me out

Many Thanks

Yemi

0 Kudos
Message 10 of 32
(5,761 Views)