Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set up 4 square pulses (10us period) every 2ms?

Hello everyone,

I'll start off by saying that I am new to LabVIEW, but am learning its functions fairly quickly.

I want to have 4 short square pulses outputted from my DAQ board (with a period of 10 microseconds) every 2ms.  That is, 4 '1-shots' every 2 ms.  I know the basics of using the DAQ board, and can get a square wave to output.  I also know how to set the simulator to output 'n' (in this case, 4) square pulses.  The problem arises with having it do this <i>consecutively</i> every 2ms.

Is there some sort of enable or disable line that I don't see on the DAQ Assistant VI?

Thank you in advance for any help.

-Paul
0 Kudos
Message 1 of 17
(5,722 Views)

Hi Paul,

 

Thank you for posting to the NI forums.  Which DAQ device are you using?  You application is a little bit too complex to use just the DAQ Assistant.  I would recommend getting started with one of the DAQmx examples, namely “Cont Write Dig Port-Ext Clk-Non Regeneration.vi”.  This can be found by going to Help >> Find Examples >> Hardware Input and Output >> DAQmx >> Digital Generation.

 

You will have to modify the example to output your particular waveform, but it should be enough to get you started. 

 

I hope this helps – post back if you have further questions.  Thanks!

 

Ed W.

Applications Engineer

National Instruments

0 Kudos
Message 2 of 17
(5,707 Views)
Ed W,

I am using the NI 6034E DAQ board.  The break-out board is a SCB-68.

I've tried using those examples but have had some problems with them.  I was thinking I could set up a 500 Hz pulse and use its rising edge to trigger a set of 4 much smaller pulses. 

The two examples I've worked with are: "Gen Dig Pulse Train-Continuous" and "Gen Dig Pulse Train-Finite-Retriggerable".  I want to use the former to trigger the latter.

I can get each one to run independently, but when I cut and paste the block diagrams into one Labview block diagram, I get an error.  The error is the following:

            Error -50103 occurred at DAQmx Start Task.vi
            Possible reason(s):

            The specified resource is reserved. The operation could not be completed as specified.

            Task Name: _unnamedTask<0>

I'm assuming I need to modify them to run together, perhaps under the same while loop or something like that.  I don't really know how.

Can someone help me out?

Thanks a ton,

-Paul



0 Kudos
Message 3 of 17
(5,693 Views)

Any finite pulse train will end up using both the counter you ask for and its "pair".  On your board, counters 0 and 1 are all you've got so the finite pulse train needs them both.  You can't do that at the same time that you use one for a continuous pulsetrain.

There's a sneaky trick though.  Instead of using a counter to generate a 500 Hz pulse train, create a dummy continuous AI task that samples at 500 Hz.  (You may need to configure the AI task to allow unread samples to be overwritten.  It's in one of the DAQmx property nodes, I don't recall which right now.)  When you specify the retriggerable finite pulse train's trigger signal, you would pick the one with a name like "AISampleClock".

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 17
(5,689 Views)
Is it really this complicated to do what I want?

If need be, I can set up two finite pulse trains, but have the 500 Hz train at a very high number of pulses (I'm not sure if there is a limitation on the number of pulses, though).  I probably don't need the 500Hz train to be outputted by the DAQ board either; it is just to control the frequency of the 4 short bursts.

Can anyone please suggest an easy step-to-follow solution?  Honestly my knowledge of LabVIEW is extremely limited.  I went through some basic tutorials with Express VI's, but I don't know much beyond that.

Thank you for your patience and help.

-Paul
0 Kudos
Message 5 of 17
(5,681 Views)

I'm pretty sure my earlier idea is the simplest way to do what you want with the 6034 board you have.  I *do* know another technique that could work but I would consider it more complex conceptually and a larger departure from using a shipped example.  [Basic idea: 1 continous 500 Hz pulse train with a high time of 40 microsec and low time of 1960 microsec.  Also 1 continuous square pulse train with a period of 10 microsec.  The second counter task is configured for "pause triggering" in a way that makes it generate pulses only while the first counter output is in the "high" state.]

I'm not near an LV PC now, but will try to whip up a quick example or two for you soon.  I understand how it can be hard to figure out where to get started when you're new to data acq.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 17
(5,672 Views)
Thank you Kevin, an example would be great so I can see how everything is connected together.  What you suggest makes sense, I simply don't know how to set it up.
0 Kudos
Message 7 of 17
(5,667 Views)

Hi Paul,

 

You can use a pause trigger with the two counter outputs of your E Series board to perform the pulse generation.  I’ve attached a screenshot of what the block diagram would look like for this type of application. 

 

You will be using two counters for this – one to generate the high frequency pulses, and a second counter to enable/disable the output by using a pause trigger.

 

I hope this helps.  Please post back if you have further questions.

 

Ed W.

Applications Engineer

National Instruments

Message Edited by Ed W on 03-13-2007 09:39 AM

0 Kudos
Message 8 of 17
(5,659 Views)

Just chiming in quickly.  I put together a couple examples last night, but they are presently on a thumbdrive halfway across town.  Smiley Sad   

One of them created an otherwise useless AI task solely for the purpose of generating a 500 Hz clock signal that could in turn re-trigger a finite pulsetrain generation task.

The other one is virtually the same as what Ed posted, except for one small but possibly important change.  As shown in the screenshot, the upper counter task produces the 4 pulse output burst signal.  The lower task is a helper that doesn't send any signals out into the external world.

As drawn, there's a chance that the upper task will immediately start producing continuous 10-microsec period pulses until the lower task gets configured and takes on the duty of regulating it.  It all depends on the default state of the pin that the lower task hasn't yet started to control. 

What I did was to start the lower task first and then start the upper task.  This sequence gives you a small but non-zero probabillity of producing <4 pulses for only the very first burst.  It just depends whether the upper task happens to start during the 40 microsec of ON time or the 1960 microsec of OFF time.  About once in 50 runs.

A method that should be even more robust would be:

1. Config, start, and stop the 500 Hz task.  Do NOT clear the task.  This should leave the "pause trigger" pin in the idle state (probably LOW).

2. Config and start the 10 microsec pulse task.  Nothing will happen yet because the "pause trigger" is in the state that blocks output.

3. Re-start the 500 Hz task.  Now you'll get bursts of 4 pulses having 10 microsec period, repeating every 2 msec (500 Hz).  All bursts will have exactly 4 pulses.

I'll post anyway when I get the chance, but I'll probably firsrt modify my example to follow the 3 steps above. 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 9 of 17
(5,648 Views)
Ed, thank you for your help.  I am still a bit confused as how to configure the block diagram you have provided for me.  Sorry if the questions are elementary, but I've barely used LabVIEW before.

Let's say I want to have CTR1 generate the 500 Hz pulse and CTR0 to generate the very short pulses (say 20 microseconds period) for 4 times at the beginning of each 500 Hz pulse.

1.  Would the top part of the block diagram correspond to CTR0 or CTR1?  My instinct says CTR0 since it has the pause trigger.
2.  What do I configure for the Pause Trigger Source?  I would think that it would be CTR1 in this case, but when I built the block diagram, I could only select PFIO 0 through 9, RTS 0 through 7, SampleClock, StartTrigger, ReferenceTrigger, and 20MhzTimebase.
3.  Do I pause when High or Low?
4.  Where would I connect a graph to to see if I am getting the correct signal out?  Will the graph show only 4 pulses, or continuous ones since they are going so quickly?  I have a hardware (real) old analog oscilloscope as well, so if that will work, I can check with that.

I am getting it to run, but it constantly outputs 20 microsecond pulses, at least as far as I can tell with my hardware oscilloscope.

Thanks a ton,

-Paul
0 Kudos
Message 10 of 17
(5,645 Views)