Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger on position two counters

Solved!
Go to solution

Hello,

 

I have an application where I want to compare the results of two counters (used as position x4). One(C#1) is connected to a system under test , and the second (C#2) connected  to a reference system. I use an USB 6221.

 

My main goal is to obtain a good synchronization between them. I want to generate a trigger signal for the C#2 when the system under test reaches a certain position. For example:

1. C#1 = 0 -> Trigger for C#2

2. C#1 = STEP -> Trigger for C#2

3. C#1 = 2*STEP -> Trigger for C#2

................

N+1. C#1 = N*STEP -> Trigger for C#2

 

The STEP size is variable and depends by the input frequency for C#1. The frequency range is very big. The maximum frequency is to high and it is not possible to acquire all the samples and to make a software processing.

 

The system under test is not providing a constant speed and can count forward and backward; so, it is not possible to calculate a sample rate based on the input frequency/system speed.

 

Thanks,

KPanda

0 Kudos
Message 1 of 9
(5,864 Views)

Hi Panda,

a couple of questions to make sure I understood the issue. C#1 counts continuosly the edges of signal coming from a system under test and by certain edges  (that you called STEP) a start trigger for the C#2 must be generated so that it starts to count the edges of the signal coming from the reference system. Is that right? Od u have to stop the C#2 counting after a certain amout of edges?

 

What does this sentence exactly mean ?->: "The maximum frequency is to high and it is not possible to acquire all the samples and to make a software processing"

 

Best regards.

 

Andrea

 

0 Kudos
Message 2 of 9
(5,733 Views)

Hi Andrea,

 

Sorry for the delayed answer. My outlook sent the email with NI notification that I have an answer to junk folder.

 

I will try to explain it with a particular case.

 

I have:

- a test system whit lower accuracy/resolution -> provides 20 counters / 1 meter.

- a reference system with a higher accuracy/resolution -> provides 100 counters / 1 meter

 

I don't need all the counts. I just want at a certain position (e.g. from 4 counts to 4 counts) provided by the test system (connected to C#1) to read the reference system counter (C#2).

For a test system without an error I should have:

C#1   

1 -> don't read

2 -> don't read

3 -> don't read

4 -> read counter #2- value should be 20

5 -> don't read

6 -> don't read

7 -> don't read

8 -> read counter #2- value should be 40

and so on

 

They can count in positive and negative direction. C#1: 1, 2, 3, 3, 2, 1, 1, 2, 3, 4 (! Here is the first reading of C#2), 5, 6,7 ...  

 

Both counters are configured as encoder (x4 edge).

 

What I meant by maximum freq is to high is that I cannot read all the samples and than to take every 4 (2, 8, 10, 20, etc) sample that I need. 

 

Regards,

Paul

Message Edited by KPanda on 09-24-2009 03:02 AM
0 Kudos
Message 3 of 9
(5,656 Views)

Hello,

 

Have you found an issue for this problem?

I am doing now my master thesis.

i have almost the same problem. I want to trigger on the definte egde (second, or third edge), which can be set from the user with contro button.

I have a compact DAQ 9178 chassis with NI 9401.

thank you.

 

0 Kudos
Message 4 of 9
(4,825 Views)
Solution
Accepted by topic author PaulieQ

Hi,

 

I found a solution for it. Though, it's very complicated.

 

Here it is:

- Define two counters: one for reference and one for measurement system

 

Configure the Reference counter as follow:

-> CI - Position Measurement

-> DAQmx Timing - Sampling Clock and at the Source use TC (Terminal Count - see documentation)

 

Configure the Measurement counter as follow:

->CI - Position Measurement

-> Use Index Enable

-> Set the Start Position and Position after Index to max(U32)-STEP. Where (max(U32)=2^32). The STEP is as described in my first post

-> Set the PropertyNode - DAQmx for CI.Encoder.ZInput to TC(Terminal Countt)

-> Set the PropertyNode - DAQmx - Export Singal to: CounterOutput - Terminal Count

 

Also set for the both counter the same time base.

 

Now it should work Smiley Happy.

 

Unfortunately I don't think I have to code no more so I cannot share it.

 

Paul

0 Kudos
Message 5 of 9
(4,819 Views)

damin,

 

It's nice to solve the problem in hardware when practical, and the method PaulieQ described will do that as long as you only want to sample for *positive* motion increments of N*STEP.  Net negative motion would *not* produce  samples the same way because the terminal count wouldn't be reached.

 

That said, there are times when it's simpler to oversample and then do the grunt work in software.  I'm not totally familiar with your cDAQ hardware but I *think* you have both digital change detection and quadrature encoder capabilities there.  If so, here's an approach you might try:

 

1. Wire the encoder A,B signals both to counter inputs and to digital change detection inputs.

2. Create a DI task based on change detection that's sensitive to both rising and falling edges of both inputs.

3. Use the change detect event/pulse as a sample clock for your encoder measurement task.

4. Start the counter task before starting the DI task -- this will keep your measurements sync'ed.

 

What happens: on every transition of either A or B, you'll get a counter sample of quadrature position *AND* you'll get a DI sample of the digital states of A & B.  Once you have all the data associated with every edge, it's relatively easy to extract only the data corresponding to states of interest.  Note that by capturing everything, you leave yourself options for post-processing the same data set in different ways, which can be pretty handy.

 

-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 9
(4,813 Views)

Kevin,

 

You are right. It works only in one direction. It is also possible to change inputs between them (A <-> B) and it will work also in negative direction. But not simultaneous.

 

I know that I also wanted to do it software but in my case it didn't fit. I needed high accuracy at different speeds and resolutions. Having different speeds (from 0.1mm/s up to 100mm/s) and resolution (0.02um up to 250um) to many variables had to be taken into account.

 

Paul

0 Kudos
Message 7 of 9
(4,809 Views)

Thank you all for your help.

I have called the Ni hotline support. I have attached the soltuion "Event triggering".

With "initial delay" you can configure on which edge the trigger have to react.

What do you think about?

I have question about this example:

Schall I set retriggerable to true? or is this uneeded?

How can I configure retrigerable mode with NI9401 in Digital Input or Edge counter?

Can I use the counter control output for more than on task as trigger source?

 

Thank you

 

0 Kudos
Message 8 of 9
(4,798 Views)

I have forget another question.

If i change the time delay during the program execution, will the trigger change dynamicly?

thank you very much

0 Kudos
Message 9 of 9
(4,796 Views)