LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital Output Driver

Solved!
Go to solution

Hi,

I am using the Ni 6221 card and I am stuck with this problem.

I haven't figured out why it doesnt work.

 

So I am running 7 valves (solenoids) in my system. I wanted to added 2 more.

But I am facing a problem of controling the two new valves independantely.

 

Lets say that I have 3 out of 7 valves on, without turning those valves OFF, i want to turn on the two new valves.

When I run my code independately from the main vi, it is working as desired.

But when i put it back to the main program. the solenoid won't turn on when it command it.

I think its because my main program is using the NI 6221 and its port as well.untitled.PNG

 

 

Best regards,
Krispiekream
0 Kudos
Message 1 of 6
(2,925 Views)

ok..problem solved.

thanks!!!

Best regards,
Krispiekream
0 Kudos
Message 2 of 6
(2,917 Views)

Then please tell us how you solved your own problem.  That way if someone else searches the forum with a similar problem and discover your message, they may learn from your newfound knowledge.

0 Kudos
Message 3 of 6
(2,907 Views)

It all comes back to Local Variables/Global variables issue.

Since "switch setting" is called by the main vi, and set 3 out of 7 valves on, what I did was use the same "switch setting" and leave those 3 valves ON, and turn ON the other two valves.

I know it shouldn't do this, but it was the easiest fix. I set "switch setting" to be global so that MAIN VI and SUBVI calls for the same variable.

I am pretty bad at explaining my solution. But I hope that helps.

 

 

Best regards,
Krispiekream
0 Kudos
Message 4 of 6
(2,901 Views)
Solution
Accepted by topic author krispiekream

I'm glad you've got it working now.  But I'd counter that it isn't global vs. locals issue at all, but the problem is that you are using globals and/or locals.

 

You should be passing the data into your subVI's by wire.  And if you need to maintain the values of that wire between iterations of your while loop, you should be using a shift register.

 

But you've been on the forums for awhile, so I'm sure you've seen threads discussing this before, so I don't need to tell you all that.  Smiley Wink

Message 5 of 6
(2,898 Views)

The usual way to "protect" some bits while changing others is to use the AND and OR functions.  First AND the existing settings with a mask which preserves the desired bits and zeros those to be changed.  Then OR in the modified bits.  AND and OR work on integers as well as booleans.

 

And, as others have said, please use wires and shift registers rather than locals or globals.

 

Lynn

Message 6 of 6
(2,888 Views)