Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Use one counter to trigger another

Hello

I would like to use ctr0 as a trigger source for ctr1, i.e. ctr1 should begin to run every time ctr0 produces a rising edge. This works good as long as I produce only one puls with ctr0, however I Iike to retrigger ctr1.

The code I am using yet is attached, but it works only for a single puls of ctr0.

Does anybody know how to implement this in LabVIEW?

(used hardware board: PCI-6025E)


0 Kudos
Message 1 of 15
(5,528 Views)
Hi MG83,

To do this function you must only change some settings on your program.

1. To change your counter 1 retriggerable, have a look to the example program: "Generate-Dig Pulse-Retriggerable.vi" from the Find Example in LabVIEW.
2. To generate a continuous Pulse train, you must change the counter 0 to Frequency generator and configure it with the Frequency and the Duty Cycle inputs. It's exactely what is made in the "Gen Dig Pulse Train- cont.vi" from the LV examples.

It will help you to solve your question.

Have a great Day.

Matthieu
National Instruments Switzerland
0 Kudos
Message 2 of 15
(5,519 Views)
Hi Matthieu

I have now inserted a "Start.Retriggerable" property node and have set it to "true" (as in the "Generate-Dig Pulse-Retriggerable.vi"-example).

Additionally i have added a sequence structure to be sure that counter 1 starts accepting trigger events before counter 0 sends those and that counter 1 stops after counter 0 has already stopped.

However the VI still does not work as expected. As soon as the number of pulses is greather than 1, I get the following error message:

"Error -50103 occurred at DAQmx Start Task.vi:1

Possible reason(s):

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

Task Name: _unnamedTask<29>"



Changing the create virtual channel VI from time to frequency does not affect this error.


0 Kudos
Message 3 of 15
(5,514 Views)
Hi MG83,

The error explanation is explicit...
If you received this error you did not right configure your program.
You receive this error because you configure the two generation on the same counter.

Your programmation is not a really good programation. What you want to do is really start the two exemples on your machine and let the two runs parrallel...your programation made one after the other...

Please check you program...

Regards.

Matthieu
0 Kudos
Message 4 of 15
(5,511 Views)
Hi Mathieu

I don't see your point.

I assumed that I have to be sure that counter 1 (which receives the trigger from counter 0) starts and goes to the "armed" state before counter 0 starts. Further I assumed that I have to stop counter 1 after counter 0 has stopped to be sure that counter 0 does not send any trigger puleses, when counter 1 has already stopped.

However between start and stop of counter 1 both counters run simultaneously!

If I simply run both counters independently, I can not assure that counter 1 does not stop, when there are still pulses produced by counter 0.

Please let me know, if I am wrong with these reasoning or how I can program this better.
0 Kudos
Message 5 of 15
(5,505 Views)
Hi MG83,

Your 2 counters does work simulatenously but only one second because the counter (bottom) only run once... to understand the problem, try to run you programm and debug it in "Highlight mode".

I made for you an example where it's really well programmed. I only put the two examples together in one VI.
I made that to better explain how to program a function like this one but you did not made it yourself and I think that is not a solution.

If you start to program with labVIEW and Data Acquisition you will lose a lot of time to programm function like this one.
I think that for you will be better to follow a LabVIEW Basics I course and a DAQ (Data Acquisition) course to really understand how really works LabVIEW and the Data Acquisition software.

I helped you this one and made this function for you but think about one of our courses whhich are really good.
You can find our courses here:
http://digital.ni.com/worldwide/switz.nsf/web/all/F731D8E711C23C438625701B005BFD04?OpenDocument&node=168480_d

I think it's help...
Have a great evening.

Matthieu
0 Kudos
Message 6 of 15
(5,501 Views)
Hi Matthieu

Thank you for your code.

I have done some minor modifications. First I have changed from frequency / duty cycle back to high time / low time control.
Further I I tried to change the upper counter (actually counter 0) from the "continous samples" mode to the "finite samples" mode, because I want to produce only a finite number of pulses (e.g. 10), but then I get exactly the same error as yesterday.

Is it possible that I simply do not have enough hardware resources for this purpose on the PCI-6025E-Board? Or where is the problem?

Another question: You use the "is task done"-VI for the lower counter. However this counter is cofigured to be retriggerable, so I wonder, if the "is task done"-VI can ever return TRUE? Or in other words: How should this task know, if there are no further trigger events so that it is done?

PS: I have already passed the LabVIEW Basics I course some weeks ago.
0 Kudos
Message 7 of 15
(5,485 Views)
Hi MG83,

I will try to respond to your question:
I have done some minor modifications. First I have changed from frequency / duty cycle back to high time / low time control.
Further I I tried to change the upper counter (actually counter 0) from the "continous samples" mode to the "finite samples" mode, because I want to produce only a finite number of pulses (e.g. 10), but then I get exactly the same error as yesterday.
If you let the configuration like I made with your card number, you will not receive any error message.
If you want to generate 10 Pulses you must start the task again after each generation.
If you receive the same error as yesterday, you don't configure the counters correctly.
First try to generate pulses on the counter0 without counter1 and after that try to do the both simultaneously...
PS: Take care that you don't have the test panel open at the same time.

Is it possible that I simply do not have enough hardware resources for this purpose on the PCI-6025E-Board? Or where is the problem?
No there is here no problem, I try with a 6025 and it work exactly as on my 6040...

Another question: You use the "is task done"-VI for the lower counter. However this counter is cofigured to be retriggerable, so I wonder, if the "is task done"-VI can ever return TRUE? Or in other words: How should this task know, if there are no further trigger events so that it is done?
It's te same method as in the example...You must hold the task open...and you use this function to chack if an error occure, if you don't use function in the loop, you don't check the errors and don't have informations...

Try first to use my example and if the a problem come, post your question with a screen shot of the error that you receive.
Please take care that the counter are right configured and that you did not open tasks on the same ressources...

Regards.

Matthieu

0 Kudos
Message 8 of 15
(5,482 Views)
Hi Matthieu

Probably I have not been accurate enough in my last posting. I did the following steps in the following order:

1) I tried your VI without any modifications and the following settings:
upper counter: Dev1/ctr0
lower counter: Dev1/ctr1
Trigger Source: Dev1/Ctr0InternalOutput

This works.

2) I changed the control from frequency and duty cycle to high time and low time.

This works too.

3) I tried to change the upper counter (actually counter 0) from the "continous samples" mode to the "finite samples" mode.

Then I get the same error as discribed yesterday.


To the other question:

I have been mistaken. I assumed that you are using the
"task done" terminal of the "is task done. vi", but now I have seen that this terminal is left open. Nevertheless, am I right, that the "task done" terminal would always return FALSE for a retriggerable task?
0 Kudos
Message 9 of 15
(5,479 Views)
Hi MG83,

I'm agree with you on you on all the point that you explain except one.

If I follow what you explain, I receive the error attached on the point 3, did you receive the same?

If you want to generate 10 Pulses you must start the task again after each generation and you don't have to configure a timing.

Let me know if it's OK for you.

Regards.

Matthieu


0 Kudos
Message 10 of 15
(5,476 Views)