LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate N-pulses repeatedly

Hi,

 

Of course I looked at the example VI you posted! However when I run the below VI nothing happens. The trigger is generated internally on the CO0 while the desired pulse is generated on CO1. The CO1 is connected to an analog input channel so that I can display the signal being generated. At the moment nothing seems to happen and I honeslty don't know why...Untitled.png

0 Kudos
Message 11 of 25
(1,866 Views)

You'll have to bear with me as well, since I don't have any hardware to test this with. One change you do need to make - you need to start BOTH counter tasks. If you only start the one that's waiting on the trigger, and never start the one you're using as the trigger, then there's never a trigger and nothing happens.

 

If you have an oscilloscope available, it would be worth putting both counter channels on the scope so you can see that they're both firing.

0 Kudos
Message 12 of 25
(1,851 Views)

Hi,

 

Have tried to make some modifications to the previous VI as to ensure that the triggering CO0 starts before the second counter C01, which I think it does, but still don't have any output. I some sense this was my initial problem, namley how do I internally trigger one counter using another couter. Take a look at the attached file, maybe you have some suggestions on what I'm doing wrong!

 

Thank you for your time.

0 Kudos
Message 13 of 25
(1,824 Views)

My apologies, looks like I've misled you a bit - I can't find a way to get a simulated device of your hardware to allow the counters to be used this way. A finite pulse train requires two counters: one to generate the pulse train, and a second one to gate it. However, what you can do instead is make two infinite pulse trains, with one as the pause trigger for the second (one counter gates the other).

 

I highly recommend that you put indicators on your error outputs, or probe them, or enable automatic error handling, or in some way look at the error values and strings, since I think that would have indicated earlier in this discussion that there is a problem.

Try something like this and see if it works.

PulseTrainWithPauseTrigger.png

0 Kudos
Message 14 of 25
(1,805 Views)

No need to apologize! It seems as the first configuration, where a finite pulse train i generated by the use of two counters - one to generate the pulse train and a second one to gate it, is more suited for my future application. The question here is how do I achieve this? Do I need to physically connect a wire from the CT0 Out to CT1 Gate? Will also try the code you suggested previoulsy!

0 Kudos
Message 15 of 25
(1,781 Views)
No, you don't need to physically connect the channels, they can be routed together internally. In fact h that's what happens now with your finite pulse train - one counter is automatically used to gate the other in that configuration. That's why you get an error (at least I did) when trying to start the second counter channel after starting the finite pulse train generation - the error said the channel was already in use.
0 Kudos
Message 16 of 25
(1,775 Views)

Hi again,

 

The example VI did not work as expected, for some reason the output was distorted! Also, I find it difficult the to follow the workflow due to unfamiliarity with the property nodes. Thank you anyway! Can't help woundering wheter there exists a simpler solution to the problem. Do you think that the desired functionalty can be achieved using the DAQ-assist or some other straightforward method?

0 Kudos
Message 17 of 25
(1,759 Views)

In what was was the output distorted? Can you provide an image?

 

I never use the DAQ Assistant, so I haven't investigated what you can do with it. It's worth learning the DAQmx functions so you can use the full capabilities of your device. That said, it's possible that there simply isn't a way to do exactly what you want with your current hardware.

 

The sample code I provided is a snippet - you can drag that code directly into a block diagram (or possibly to the desktop first, then into a block diagram, depending on your web browser). You don't need to recreate it, although you will need to modify the parameters and device names to match your setup.

 

What my example code attempts to do (and again, I can't test this because I don't have any counter hardware available at the moment, so all I can do is verify that it doesn't generate any errors) is use the Counter 1 output as a Pause Trigger for Counter 0. When the Pause Trigger condition is met, the counter output stops (but the counter keeps running). You'll need some way to synchronize these two counters (I suspect the distortion you describe is because the counters are not synchronized) but I don't know how you would do that, as it seems there is not another output available on your board to trigger both counters simultaneously. Perhaps you can find some way to use one of the analog timing signals to do this.

0 Kudos
Message 18 of 25
(1,750 Views)

Hello,

 

nathand,

 

Going back to your initial question,

 

You said, "But, simply inserting this into a while loop will not solve the problem as the associated loop-delay is in the order of 70ms."

 

What is causing the 70ms delay? Does the pulse generation sequence take 70ms to complete?

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding. Proverbs 4:7
0 Kudos
Message 19 of 25
(1,741 Views)

Hi (hmarcano),

 

During my first approach to solve the problem I used the DAQ-assist as to generate a finite burst of 8-pulses with 50% duty cycle at 40kHz (or T = 25us) at the CO1 of the NI USB-6211 and this worked just fine. Now I wanted to repeat this cycle (say for example every 2ms), that is, once the 8 pulses are generated the counter output should stay on a low idle state for 2ms and then generate the same 8 pulses again and so on... In some sense this can be viewed as a custom counter output sequence! To achieve this I tried to put the DAQ-assist inside a loop along with a time-delay = 2ms. This simply did not work as the CPU-time it takes to loop i much greather than the 2ms time-delay. This seems to be a limitation of the DAQ-assist the task i recreated every loop and this takes a certain amount of time. Hope you now understand my confusion. Feel free to give suggestion, possibly example VI's! 

0 Kudos
Message 20 of 25
(1,721 Views)