Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Read at the same time 4 counters and measure the phase between two

Hi, how can I read at the same time two signals, to measure the phase between them, I'm using the 6602
I'm using the example to read at the same time 8 counters, but if I put the same signal input the 4 counters, it works.
But if I put two signals ( different phase), gives wrong values or the correct or the error, see attachments.

The goal for this application is test optical encoders.
Download All
0 Kudos
Message 1 of 4
(3,364 Views)
Hi,

The error is associated with your buffered signals on your counters being in the 10s of kHz. If you have that many counters all buffering data at a high speed, you will eventually overrun the bandwidth of the PCI bus. This is why you receive the error.

As for getting bad data, what I suggest is to use the counter application "two signal edge separation measurement". If you take a look at the shipping example "Two Edge Separation Measurement (NI-TIO).vi", it is measuring the number of source edges that occur between the two signals. This will essentially give you the phase in terms of a time value. If you need to know the phase in terms of the period of one of your signals, you would also need to use another counter to perform a period measurement.
Therefore you will have 1 counter performing the two signal edge separation and another counter performing the period measurement.

As for your current measurement system, it would seem like the idea is correct. You should be able to perform semi-period measurements on each of your signals to obtain a correct value. The problem could be occuring because of the lack of DMA channels. You have 3 DMA channels to use and they are used by the first 3 counters. This means that the forth counter will have to use interrupts which are much slower and less efficient than DMA. This could cause you to get incorrect data.

Is there a reason you are using 2 counters for each of your 2 signals? Why not use 1 counter for the one signal and a second counter for your second signal. This will ensure they both get DMA channels.

Anyway, hope this helps you out. Have a good day.

Ron
0 Kudos
Message 2 of 4
(3,364 Views)
Tank you Ron,
now I'm using only 3 counter, the first one
to measure two edge separation (phase)
and the others two for measure semi-periods (two semi-periods = period),
its working but if I put the same signal in
the 3 counters gives me in average 2.5msec phase and should be cero, or very close to cero.
What else can I do?
Regards, JLV
0 Kudos
Message 3 of 4
(3,364 Views)
Hi JoseLuisValera,

If your two signals are simultaneous (0 phase) then the two edge separation measurement will not reflect that. It will be expecting to see an edge further on and it is probably measuring the difference between the first group of edges and the next group of edges which is probably 2.5ms later.

I am assumiung that everything is measuring correctly if you have a phase difference that is detectable by the 80MHz timebase.

What I suggest doing is creating an "artificial" phase difference of known value. Therefore, I would setup a 4th counter for retriggerable pulse generation. What you will want to do is apply one of your two signals to the gate of this 4th counter. You would use the 80MHz timebase as the source. Then
you would set the pulse specs of the counter (see the shipping examples for this type of application) such that it creates a pulse on its output that is a phase delay of "known" width. Then you can measure the two edge separation between this new signal and your first signal. Your phase will be artificially larger by exactly the pulse delay of your 4th counter, which you can subtract out. This will now allow you to measure 0 phase. It is important to choose a delay for the counter such that it will never cause the two edges applied to the two edge separation counter to be exactly in phase. Otherwise, it will defeat the purpose of this workaround anyway. It would be best if you knew that one of your signals would always lag the other so that you can apply the delay to it without worrying that the resulting signal will be equal in phase to your main signal.

Anyway, I hope I was clear in explaining this method to you. Hope it helps and have a good day.

Ron
0 Kudos
Message 4 of 4
(3,364 Views)