Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling retriggerable pulse (NOT pulse train) generation

Hi,

 

I am using LabVIEW 2009 with PCI 6602 to do pulse generation (not pulse train!) according to an external trigger signal (say the pulse freqency is around 20Hz, but it is not a constant).  My thought was to use a switch turn "on" the generation, and there should be no generation from the counter output if the switch is toggled "off".  I modified the example "Gen Dig Pulse-Retriggerable.vi" to try to control the generation, but it was not successful.  What I did was simply applying a case structure to the example code.  The problem I encountered was that before I turned on the switch (namely, the boolean is false) there was no pulse generation, and once the switch was on (true) the counter output sent out the pulses; however, if I click the boolean again, the generation does not stop until I hit the stop button.  Is there a right way to turn the pulse generation on or off?

 

The attachment is my VI.

 

Thanks,

Bobby

0 Kudos
Message 1 of 8
(6,650 Views)

Hello Bobby,

 

What is wrong with the regular Gen Dig Pulse-Retriggerable.vi? The only thing that you'd need to change is make it a Counter Output Pulse Time task. This way, you have more control on how long your high and low times will be. You will only generate a single pulse for every trigger you receive.

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 2 of 8
(6,646 Views)

Hi Daniel,

 

That is not my question.  What I want is to add a switch so that I could "turn on" the pulse generatoin whenever I need and "turn off" whenever I do not need it while the program is still running.  My idea was to use a case structure, but my vi did not turn off while I clicked my switch back to OFF (false) condition.

 

Thanks,

Bobby

0 Kudos
Message 3 of 8
(6,644 Views)

Hi Bobby,

I am a little bit confused. Didn't you say you wanted to trigger off from an external signal, as opposed to a soft panel switch? If you have an external signal that you want to trigger of from, you'd want to use the DAQmx Trigger VI. If you are going to base your generation from a button in LabVIEW (software timed), you are not going to need it. Remember that this switch will be software timed, meaning there is a considerable delay (depending on your application) between when you turn on or off your task. Here is an example that I think does what you want.

 

 

Retriggerable 03 engine control mod.png

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 4 of 8
(6,641 Views)

Hi Daniel,

 

I might have explained it unclearly.  I understand the example VI and know how to use it with either external trigger siganls or internal ones (my application requires the former), so my problem is not whether using external signals or internal timing.  It is that I want to add a switch on my fornt panel so that I could turn "on" or "off" the generation while the program is still running, which does not require me to click the stop button to terminate the whole program.  

 

I used to work with LabVIEW 5.0, and to apply a turn-on/-off function is fairly easy by just adding a case structure.  However, I failed in LabVIEW 2009 by doing so.  When I start my VI, there is no pulse generation due to the off(false) condition of the switch and I could start the generation by clicking the switch, which is what I want.  However, once the pulse generation is turned on (true), it will not stop the work even though I click the switch again to put it back to the off(false) mode unless I click the stop button, which will terminate the whole program and is not what I want.

 

The VI I posted is fairly plain since I do not want to add other things to complicate my problem, but I do need the retriggerability since the trigger signals are generated continuously from my engine.

 

Thanks,

Bobby

0 Kudos
Message 5 of 8
(6,637 Views)

Hi Bobby,

 

1) I fail to see how this is a single pulse, as opposed to a train pulse. In your application you specified an array of high and low ticks, as opposed to just one low and high number of ticks.

2) You say your application uses an external trigger. So I understand that you want to generate a pulse repeated times, as long as an external trigger is received and your soft panel switch is on. Did I understand correctly?

 

On the attached VI the program generates a 1 ms pulse as long as the button is pushed and you receive an external trigger. If you just want to generate as long as the button is pushed, just delete the DAQmx Trigger VI. I hope this is what you are looking for.

 

Retriggerable 03 engine control mod2.png

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 6 of 8
(6,626 Views)

Hi Daniel,

 

I thought pulse train is defined as several pulses per trigger pulse, so in my application there is only one pulse generated per trigger signal.  The reason I use "ticks" instead of "time" is that my engine does not run on "exact" constant speed; it is therefore better to use "ticks" to clock.  For example, say I am going to generate a high pulse with a certain delay, and it is more accurate with ticks than time because the former is crank-angle-based (position based) and the latter is time based.  If my clock is one tick per degree, 180 ticks is always equal to 180 degrees; however, 0.01s does not always give me 180 degrees because of the real engine speed: if mathematically 0.01s = 180 deg, which means 3000 rpm, it may actually vary as 185 deg or 177 deg depending on the actual speed (30XX or 29XX rpm).  

 

I will try your solution, and it seems feasible.  I also came up with one, which has an additional determination to stop generation (say after 20 pulses are generation).  The only problem with my method is that when I "turn off" the switch, there could be one extra pulse generated due to the logic of my code.

Thanks a lot for your help,

Bobby 

0 Kudos
Message 7 of 8
(6,621 Views)

Hi Daniel,

 

I changed your vi a little bit because I noticed that your vi does not retrigger when it receives a new trigger signal.  It now works as I wanted.  Thanks a lot for your help!

 

Bobby

0 Kudos
Message 8 of 8
(6,617 Views)