Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

generate trigger on n counts of quadrature counter?

Hi,
 
I have 6212 card. I use one counter to produce pulse train that drives a motor. The second counter reads position with quadrature encoder. Is there a way to configure the encoder counter to automatically send a pause/reference trigger to the first counter after a specified number of quadrature counts?
 
Thank you
0 Kudos
Message 1 of 10
(5,401 Views)

igor79,

You could first initialize the terminal count of ctr0 to its maximum value minus the specified number of quadrature counts.  This will cause the terminal count to exceed its maximum value and output a pulse on ctr0internaloutput when the specified number of quadrature counts is reached.  If the trigger source of ctr1 is specified as ctr0internaloutput then ctr1 will pause when the terminal count of ctr0 is exceeded.  If you wanted this to be a re-triggerable application then you would have to reset the terminal count of ctr0 to its maximum value minus the specified number of quadrature counts every time the maximum terminal count is exceeded.

0 Kudos
Message 2 of 10
(5,384 Views)

Thank you for reply G Lo,

Unfortunately, It does not seem to work for me. The closest what I found to initialize terminal count for position encoder counter (it is ctr1 in my case, configured as X1 linear) is to specify initial position. By polling position counter ctr1, I can see that position approaches and crosses zero as driver approaches and reaches destination, so I seem to calculate difference right (2^32/[counts/m] - distance2go_m), but ctr0 (motor pulse train) does not pause.

I also tried to configure ctr1 as usual edge counter and specify initial count accordingly. Still it crosses maximum value and continues through zero without issuing signal.

I know that I can pause the ctr0 all right, as I do that in another part of my program (proximity sensor issues pause trigger to ctr0 if no-no zone is entered, and it works). Is it possible that ctr1 pinout is not right (I use pfi13 as default ctr1-out)?

Thank you for your time,

Igor

0 Kudos
Message 3 of 10
(5,368 Views)

Igor79,

I tested the simple edge counter case that you described and it seems to work fine.  You mentioned that PFI13 is connected to ctr1-out but you would need to set the source for the pause trigger as "Ctr1InternalOutput".  No external connections need to be made between these two counters if the trigger source  utilizes the internal output.   

0 Kudos
Message 4 of 10
(5,350 Views)

G Lo,

I am afraid I'm missing something obvious here. I set up pause trigger using Daqmx_Trigger_Property_Node, where Pause.DigLvl.Src can take values PFI0..15, Onboard clock etc. , but ctr1InternalOutput is not on the list there.  I know that no external connections are needed, I just assumed (probably naively) that PFI13 refers to ctr1InternalOutput because it's marked as ctr1 output for 6212.

My another assumption that might also be naive is that ctr1 outputs a signal when maximum counts is reached automatically. Do I actually have to set-up additional CO Pulse Ticks task or something like to arrange that?

Thanks a lot!

Igor

 

 

 

 

 

0 Kudos
Message 5 of 10
(5,341 Views)

Igor,

I have attached the two VIs that I was using to test the simple count edges case.  You should run the Gen Dig Pulse Train-Finite-Retriggerable.vi first and then run the Count Digital Events.vi because it will send the pause trigger when the terminal count is reached.  I also looked at the Device Routes for the 6212 and you should be able to route ctr1internaloutput or ctr0 internaloutput to its respective trigger source terminal.  Please let me know if you are succesful.

0 Kudos
Message 6 of 10
(5,322 Views)

G Lo,

 

I have LV8.2.1 - could you please save the vi's for older version?

 

 

0 Kudos
Message 7 of 10
(5,317 Views)

Igor,

Not a problem.  Please let me know if these VIs don't open in 8.2. 

0 Kudos
Message 8 of 10
(5,299 Views)
G Lo,
 
 
I opened the vi's. They are just like I expected them to be from your initial explanation and what I have in my program (apart from the fact that I have 1 "pulses to generate" in the train, instead of 5, and I use 32 bit counters, instead of 24).
I see in your second Vi (pulse train) you have a control called "trigger source" wired to the "daqmx trigger" property node. That control contains /dev1/ctr1InternalOut as an option. When I wire a constant or a control to the "daqmx trigger" in my program I don't have such an option (as I mentioned before, only PFIxx and some other stuff, like ai triggers).  I blatantly copy/pasted your "source" control to my program and wired to the trigger source of "daqmx trigger" property node. And it works! I don't now why it would not show in my program to begin with, but thanks a lot for your help and patience!
 
-Igor
0 Kudos
Message 9 of 10
(5,289 Views)

I *think* I know why you couldn't find the option for /dev1/ctr1InternalOutput.  It's due to a "feature" that I've found kind of annoying.

By default, those controls only show the options that NI has pre-determined as the most common choices.  Many of the internally-routeable timing signals didn't make the list.  What you need to do is right-click on the constant and pick the menu choice to "show advanced terminals".  THEN you get to see the complete list.  Unfortunately, to the best of my knowledge there is no global setting to change this.  It needs to be done on each individual control/constant 1 at a time.

-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 10 of 10
(5,280 Views)