Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Gen Digital Pulse Train Finite Retriggerable - Initial Delay is only for first trigger

I've downlaoded the NIDAQmx 8.1 and tried the commands that you mentioned. Here are the errors that I am getting -

DAQmx Error: Specified property is not supported by the device or is not applicable to the task.
Property: DAQmx_StartTrig_Delay

Task Name: _unnamedTask<0>

Status Code: -200452

Here is my code that I use to generate finite pulse train -

DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    //Create Pulse output channel and configure rate, frequency, and duty cycle
DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandle,"/Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,20000000,0.5));
    //Configure Trigger terminal and polarity
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI34",DAQmx_Val_Rising));
DAQmxErrChk (DAQmxSetStartTrigDelay(taskHandle, 1.0)); //Newly added
DAQmxErrChk (DAQmxSetStartTrigDelayUnits(taskHandle, 20)); //Newly added
    //Configure start trigger as retriggerable
DAQmxErrChk (DAQmxSetStartTrigRetriggerable(taskHandle, TRUE));
    //Set the number of pulses to generate
DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandle,DAQmx_Val_FiniteSamps,549));

DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

So, where/what am i doing wrong??

thanks,
-Pavan
0 Kudos
Message 11 of 32
(4,226 Views)

Hello Pavan,

I check to see of 6602 supports this property, and it actually does. So, our problem lies somewhere else.

Your code looks almost right. Try and call the DAQmxSetStartTrigDelayUnit function before you define the delay. Also, I dont think you are putting a valid value for your Delay Units. Please refer to the attached image for the acceptable values for this property.

 

0 Kudos
Message 12 of 32
(4,219 Views)

Hello Pavan,

I checked to see if 6602 supported this property, and it actually does. So, our problem lies somewhere else.

Your code looks almost right. Try and call the DAQmxSetStartTrigDelayUnit function before you define the delay. Also, I dont think you are putting a valid value for your Delay Units. Please refer to the attached image for the acceptable values for this property.

Regards,

Chetan K

Application Engineer

0 Kudos
Message 13 of 32
(4,205 Views)
Hi Chetan,
I have tried it again by rearranging the commands and changing the values as you suggested, but still it is giving me the same error as I mentioned earlier. Do you have any code which you think worked well with 6602?? anyway herewith I am attaching my code for your reference. It would be great if you can go through it and lemme know if I am doing anything wrong.
thanks,
-Pavan
0 Kudos
Message 14 of 32
(4,203 Views)

Hello Pavan,

Actually, the resource that I was referring to earlier which made me believe that the 6602 supported this property, was incorrect. That explains the reason why you were getting the error message. As far as your original question goes, you would need to follow the VI that was suggested earlier in this thread. You should be able to translate the block diagram into your .cpp file. In the case you don’t have LabVIEW installed; I have attached an image file containing the block diagram for your quick reference.

Regards,

Chetan K

Application Engineer

0 Kudos
Message 15 of 32
(4,181 Views)
Hi Chetan,
Thanks for your reply. I did get the program working using 2 counters and Laura from your technical support group has helped me with this problem by using 2 counters and loosely traslated the VI solution above into C functions.

For someone who needs in future, here is the code. Change the parameters according to your situation, for me I need to get 20MHz finite pulse train of 540 pulses using a 15.16kHz input trigger signal
Thanks,
-Pavan
0 Kudos
Message 16 of 32
(4,175 Views)

For Alan,

This was the original problem that I had put up
I am trying to generate n pulses right after getting a trigger. The gen dig pulse train -retriggable gives me all the flexibilty i want however i cannot find a way of introducing a delay between the trigger and when my n finite pulses get triggered. As i understand the start option is only applicable for Analog I/P function .
 
I read your previous message and am trying to use 1) a Gen Dig pulse retriggable to delay my trigger that is to take an external trigger and get a signal which is delayed then ..I/p for this is PFI0 and O/P is Ctr0 out (I have a NI 6251)
2) I use a Gen dig pulse finite retriggable to get the finite pulse train i want..I would therefore like to use Ctr 0 as an input  since it would now act as an trigger however Ctr0 is not given as a possible trigger source ; there are other options but I need to use this particular one..Please advise..
 
Ams
 
 
 
0 Kudos
Message 17 of 32
(3,969 Views)
Couple things I should mention.  First, any finite pulse train uses two counters.  So, with a 6251, you can not have a re-triggerable (delayed) single pulse AND and finite pulse train task running at the same time.  The 6251 only has two counters.  Therefore, the solution I mentioned in my first couple posts uses a pause-triggered continuous pulse train (continuous pulse trains use only one counter).  And it uses as the source of the pause trigger the output of the other counter, which is performing a re-triggerable single pulse. 
 
If you haven't yet, take a look at the code I posted earlier.  I think it does what you are looking for, essentially a re-triggerable finite pulse train, with an initial delay from the instant of the trigger to the first pulse.
 
Also, it might be helpful to post your code so I can take a look at it if you have anything further.
 
-Alan A.
0 Kudos
Message 18 of 32
(3,964 Views)

Alan ,

I am facing the following issues

1) With the pause trigger u have attached (and any other desirable configuration) the “2nd trigger”  remains high between the pulses . This is not a show stopper since I would be using the edge of this second trigger. ( This is the attached VI 1)

2) Since I want to use this second trigger I need to use it’s output that is ctr 0 as the trigger parameter for my finite train of pulses  ( This is the attached VI 1). However that drop box in the trigger parm does not have a ctr0 as an option so I will try using ctr0 gate/source.

3) I want to use the second trigger for generating pulses for various devices (still trying to get the first one working) . However your previous post seems to state that cannot be done. I thought that the counters refer to the physical ports on BNC-2110 which are two but as u will see in the VI attachments I need only Ctr0.  I don’t see the difference in using the pause trigger and the retriggerable pulse in terms of physical resources being used (please explain this counter business).

Is it alright if I can speak with you , should make it much easier for me  to understand.

Thanks

Ams

 

 

0 Kudos
Message 19 of 32
(3,882 Views)

Couple things:
First, I'd suggest using the VI in my third post (it combines the two VIs from the first post into one nice, clean VI).  So the gating counter (in the example, Ctr 1) will remain high while the output counter is producing the pulse train.  That is how this program is designed to work, using the pause trigger.  The output counter stops (pauses) the pulse train output when the gating counter is low. 
As far as your question about not having ctr0 as an option, I'm assuming that you are trying to use "/DevX/CtrYInternalOutput".  If you don't have this option, then you probably just need to right-click on the control and select I/O Name Filtering, then select the check box for "Include Advanced Terminals".
Let me try to explain the counter stuff again.  With current Multifunction DAQ device (M Series included), when you choose to run a finite pulse train, two counters are needed.  This is a physical property of the counter hardware.  It is true that you only select one counter, but the other is being used.  (Feel free to test this out by running a finite pulse train on counter 0 and trying to perform any operation on counter 1 at the same time.....and notice the "resource reserved" error)
Additionally, NI-DAQmx does not support the "Initial Delay" for re-triggerable finite pulse trains.  So, to solve the problem, we have to use some other method to apply an initial delay from an external trigger.  One way to do this is to set up a re-triggerable single pulse with an initial delay, and use that single pulse as a trigger (single pulse requires one counter).
So, with your device, 6251, which has two counters, it is not possible to use one counter to produce a finite pulse train, and use the other to do anything. 
However, continuous pulse trains only require one counter.  So we can produce a continuous pulse train and simultaneously use another counter to produce a delayed pulse to trigger (or gate) the continuous pulse train.  That is exactly what my example does.

Hope this clears things up.

-Alan

Message Edited by Alan [DE] on 08-22-2006 07:15 PM

Message 20 of 32
(3,859 Views)