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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single shot analog output: How to pulse this. Probably easy, I'm at a loss.

Solved!
Go to solution

Hello.

 

I have a piece of machinery that my system is connected to.  Every time it reaches a proximity sensor (It's a reciprocating unit), I need to do a single pulse of 5v out of my analog output.  It has to be fast, it has to stop until the sensor is reached again, and it can't stay 'on' for long.

 

I've attached my VI.  I'm using a voltage input via DAQ assistant, routed through some logic to produce a 'true' boolean every time that sensor is reached, and that boolean is connected to a case structure with voltage out tasks created in DAQmx.

 

My problem is that the machine won't reverse while the case is still true and there's still the 5v being called by the true case on the case structure.  It has to pulse, then stop, then be allowed to come back when the proximity sensor is reached again.  As it is now, the machine reaches the prox and then the whole system stops, as the 'true' condition on the case structure, and subsequent voltage output, remain high.

 

prox reverse.jpg

 

I've attached the VI and heirarchy as well.

 

I've tried a few different things here, as well as just using a DAQ assistant with N samples, but that would just retrigger when the loop repeats anyway.

I'd love to sit and bang my head against this til I get it, but I'm under a time constraint.  Help!

___________________________________________________________________
Still confused after 8 years.
Download All
0 Kudos
Message 1 of 20
(3,457 Views)

Ralph, without knowing the exact DAQ card that you are using, it is difficult to give you the best solution. If you want to continue with the solution that you currently have, try adding a shift register to the outer while loop to track the previous value of the boolean. In this way, we can keep multiple values that are above the threshold from causing multiple pulses. Next add a time delay after the DAQmx Write, then add another DAQmx Write to set the output back to your low value. Remove all code from your "false" case. See attached VIs. Please let us know what model of DAQ card you have as we may be able to do something clever like a retriggerable pulse train if your card can support it.

 

Charles Chickering

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Download All
0 Kudos
Message 2 of 20
(3,452 Views)
Solution
Accepted by topic author Ralph@NES

Try something like this.  Set the input to the "Time Delay" function to be however long you want your pulse to be (within reason).  You did not specify a value for "fast".  I initialize your analog output line to 0...it's a good idea but it's up to you whether you want to do that or not.

 

analog pulse.png

0 Kudos
Message 3 of 20
(3,448 Views)

First you don't need to convert your dynamic data in your subvi, since you are using the numeric data.  It will only give you one element, so what's the point of it.

 

What does "it can't stay on for long" mean?  How long do you want it to stay on.  We can't define that parameter for you.  You have to know this.

 

Turn the pulse on when a True is present on the output of your sub-VI.  Enable an Elapsed Time Express VI like the attached.  You may need to play around with this to get the timing right.  You will need to consider the 50ms delay as well.  The timer starts on the next iteration, so there will be at least a 50ms delay built into this.  The express VI is set to 100ms currently.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 4 of 20
(3,444 Views)

I suppose 'it can't stay on for long' really means 'just long enough to trigger the relay' which is probably somewhere around 50ms.

 

The card is PCI-6221.

 

I think that example with the time delay may work, but won't that cause it to keep returning the true condition and renewing the state, regardless of delay?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 5 of 20
(3,426 Views)

Ralph@NES wrote:
 

 

I think that example with the time delay may work, but won't that cause it to keep returning the true condition and renewing the state, regardless of delay?


What example are you referring to?  Three people have recommended the use of a time delay, including myself.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 20
(3,423 Views)
I suppose any of them, really.

It turns out that I was wrong in my request. According to the machine electrician, the default state needs to be +5v, the 'switch' occurs when power is dropped.

So, thanks for bearing with me, I suppose what I need is this:

Machine is between switch point, I get a false condition from my logic subvi (I changed it to go true on exceeding voltage of 2.5). During that false condition, the machine gets 5v from my analog output. That condition stays false until the limit switch is reached, which causes the logic to go true. The true case of the structure has the voltage momentarily drop to 0 or 1, then immediately return to 5v to power the machine the other direction. It maintains that false case until it gets another high input from the daq, and repeats, to create a constant run condition.
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 7 of 20
(3,415 Views)

Did you code up what I showed you in my earlier post and actually try it?  It would appear you didn't.

 

Since you actually had your conditions reversed (according to your last post), modify my code as follows:

 

Outside the loop, initialize your analog output channel to 5V.

 

In the "True" case of your case structure, wire a "0" (or "1", or whatever) to the first "DAQmx Write" function.  Wire "0.05" to the "Time Delay" function.  Wire "5" to the second "DAQmx Write" function.

 

In the "False" case of the case structure, just run the task and error wires through.

 

Your analog output will start at 5V.  When your logic subVI returns a "T" value, the "True" case will execute and you'll get your pulse.  When your logic subVI returns a "F" value, your analog output will just stay at 5V.

 

Create and clear your DAQmx tasks outside your loop, as I have shown.

 

I don't understand why you're confused when you've been given three solutions...?

0 Kudos
Message 8 of 20
(3,402 Views)

Diane,

 

I ended up trying a few different combinations of the options provided me in this thread, although I have to admit I did all of them with all the task work in the case structure.

 

I ended up not using shift registers (Shift registers seemed to make it so that there needed to be a double 'hit' of the 5v from the proximity switch in order to reverse the motion).  Ended up getting basic functionality, but either I have latency somewhere in the circuit or having all the task work in the case structure caused issues.

 

The machine is responding, just peculiarly (Seems like a big pause between direction switching) and not quickly.  I suppose I will give it a go with putting the task work outside the loop and see what I get.

 

By the way, the 'Really, really confused' line is my signature as it sums up my state of mind in 2006, when I first started, and to this very day.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 9 of 20
(3,390 Views)

Ah, I didn't realize that your "really, really confused" was your signature line.  Smiley Happy

 

Can you post your code?  I'm wondering how often your loop iterates.  If your logic subVI executes slowly, you'll obviously have a slow machine response.  Also, you'll probably want a small time delay in your "False" case so that you don't wind up with a greedy loop.  Greedy loops, which take up the entire CPU, will also cause problems.

 

The task creation / clearing does need to take place outside your loop.  Creating and clearing a task every time you run it is extremely inefficient and has been known to cause memory leaks, leading to a degradation in performance. 

0 Kudos
Message 10 of 20
(3,382 Views)