From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Advice on VI to Control and Count Solenoid Actuation along with Signal Correlation

First, I have no formal labview training and I'm using an USB NI-6210 DAQ.

 

I attached the VI I created that does (it works) the following:

 

-Read a voltage signal

-Count that signal when it passes a set point (ghetto counter)

-Output a digital square wave (0,5 V) actuation that will control a solenoid valve.

-Control the frequency of the square wave, (On/Off time will be the same)

-Stop the output at a set point (because test will be completed)

 

Now what I cant figure out:

 

You can see an LED that turns orange when the signal cannot hit the counter set point, meaning I want to stop the test and thus stop the digital output to the solenoid.

 

I cannot figure out how to create a time delay, say wait for 1 minute, if the signal cannot hit the target set point, shut down the digital output.

 

Idk if if because I'm in different while loops but I essentially did the same thing (and it works) with stopping the digital output when it hit a set point.

 

I think once I get this figured out Ill be set to clean up the front panel etc... let me know what you guys think

 

Thanks

 

Download All
0 Kudos
Message 1 of 10
(3,355 Views)

For those of you who need an earlier VI version...

 

I think I got some errors when I saved it in version 8.0 (Im running 2011)

 

Thanks..

0 Kudos
Message 2 of 10
(3,350 Views)

Alright using a case structure I have tried to accomplish the same thing... I added indicators to help my troubleshooting for the true and false conditions...

 

Ignore the different Version revs.. there both the same file but rev f is for previous LV

Download All
0 Kudos
Message 3 of 10
(3,337 Views)

Current BD

 

LCT_2.JPG

0 Kudos
Message 4 of 10
(3,330 Views)

Hi work3r,

 

I'm a little confused with your question so let's take a step back and look at your overall goal. What exactly are you trying to do with your program? From your posts, I believe that you are hoping to have your program stop running when the signal (the square wave) crosses below a certain value. Is this correct? 

 

Mychal F

Applications Engineer
National Instruments
0 Kudos
Message 5 of 10
(3,310 Views)

Yes that is correct.

 

The program will ultimately control a solenoid valve using the digital square wave (on/off) that controls airflow to an actuator.

 

The actuator will generate a force / pressure that i will be monitoring and counting; if a part fails (cannot obtain a set signal value) then I need the digital output to stop, or the whole program for that matter.

 

Thanks

0 Kudos
Message 6 of 10
(3,295 Views)

Hi work3r,

 

It sounds like what you want to do is have a threshold set that when crossed, will stop your program. Here is a link to a community example that shows you how to set a threshold for a value. I have also attached a link here that shows you how to programmatically stop a VI. Combining these examples should allow you to achieve your desired results. Hope this helps!

 

Mychal F

Applications Engineer
National Instruments
0 Kudos
Message 7 of 10
(3,285 Views)

Mychal F,

 

I appreciate your help, I will let you know how my editing turns out

 

Thanks

0 Kudos
Message 8 of 10
(3,279 Views)

Thanks for the help, I decided to start over and simplify things by having "better" program flow; I used the DAQmx functions along the way.

 

My program currently outputs a digital Boolean (high/low) signal low control a solenoid valve, on and off times along with the "for" loop work great. This gives me control of my cycle frequency and cycle count.

 

I can also monitor an analog signal, say a force transducer, that is is changing its value as a result of the digital output.

 

My goal (almost there I think) is to shut down the digital output if the analog signal cannot reach a certain value after say 10 seconds, this would stop a "test" and allow a person to record the number of cycles a part went if something failed.

 

I'm having a hard time extending my analog signal outside of the while loop and still having a signal to work with, I'm lost....

 

Thanks Again

 

 

 LCT_DAQmx.JPG

 

Download All
0 Kudos
Message 9 of 10
(3,267 Views)

When you want analog input and digital output to run in parallel with one being modified or controlled by the other you need parallel loops (which you have) and a means of communicting between the loops without creating a data dependency (which you do not have).

 

Look at the Producer/Consumer Design Pattern which ships with LV. It uses a queue to pass the data from the analog loop to the digital loop.

 

Other comments: 1. Since you want to stop the digital output under two conditions, one of which is not predetermined, you need a while loop rather than a for loop. (Well, you could use the condtional for loop, but I think a while loop is a better fit in this case.) The stop conditions for the while loop would be (i > Set Cycle Count - 1) OR (Raw Data passes Threshold).

2. The Waits in the sequence structure may run before, after, or during the Digital Writes.  Put them in separate frames.

3. Having the Stop Task inside the for loop will cause a problem on all iterations after the first.  The Writes will find that the task is not running.  Move it outside the loop.

4.  Connect your error in and error out wires and handle the errors.

5. When loops run in parallel with other parts of the code, each loop should have a Wait or delay of some kind to allow sharing of CPU resources.  The For loop has Waits, but the while loop does not.  Possibly the Analog In may perform a wait, but it may not since you are reading only one sample at a time.

6. Consider a state machine in your digital loop.

 

Lynn

0 Kudos
Message 10 of 10
(3,258 Views)