Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring frequency with NI-6221

Solved!
Go to solution
Solution
Accepted by Rafi2003

I don't mean that the measured frequency will be inaccurate, just that doing this test is not a valid way to test the accuracy of the board.  The measured frequency will actually be more accurate than it really is, since the timebase of the generated and acquired signal would be identical.

 

I would use whatever frequencies you want that are close to your expected signals which are obtainable by 1MHz / N where N is an integer.  If you want a 50% duty cycle, you might add the restriction that N must be an even number.

 

 

Best Regards,

John Passiak
Message 11 of 20
(2,338 Views)

I John,

 

It appears that I have more lines than I thought.

 

Right now, I'm looking to measure :

    10 digital wave inputs (freq 200Hz - 12Mhz).  One line at a time.

    3 encoders.  One encoder at a time.  Each encoder will use 3 wave outputs.

 

My plan is to use the device as follow:

     PFI for 10 inputs wave signals

     PFI  for 6 wave output (2 encoders).

     DO for 3 wave output.

 

I understand theat the DO wave output has a limit of 1MHZ, which the PFI does not have.  Am I correct?

Is there any problem to use the DO to generate encoder wave?  (2 waves shifted by 90 degrees + index pulse)

 

Thanks

Rafi

 

 

0 Kudos
Message 12 of 20
(2,309 Views)

Hello Rafi,

 

I understand theat the DO wave output has a limit of 1MHZ, which the PFI does not have.  Am I correct?

 

The DO limitation of 1MHz that John was referring to is the max digital output sample clock rate for the board in question.  At a rate of 1MHz, the fastest clock rate you can achieve would be to alternate from 0 to 1 repeated.  This would achieve a rate of 500 KHz.  As mentioned by John, the 635x and 636x support digital output rates of up to 10 MHz.  So, if you need to generate faster frequencies, you could use one of these boards to generate a clock at 5MHz.  

 

Is there any problem to use the DO to generate encoder wave?  (2 waves shifted by 90 degrees + index pulse)

 

No.  For example, at a rate of 10MHz, you could generate 1,0,1,0,1,0 on one line and 0,1,0,1,0,1, and they would be 90 degrees out-of-phase at a frequency of 5MHz.  You define the waveforms and thus you can create any waveform you want, but remember that these waveforms are controlled and outputted at the same digital output sample rate.

 

Regards,

Paul C.

0 Kudos
Message 13 of 20
(2,300 Views)

Hi,

 

Attached is the exact encoder signal I need to produce.  I need to simulate 3 encoder, thus, 9 lines.  However, I output only 1 encoder at a time.

Which signals do I need to use?  I have 6 PFI pins available + 3  DO.  Can I use a combination of DO and PFI?

Please elaborate as much as you can...

 

The DAQ card is NI  PCIe-6321

 

Thanks

RK

I

 

 

endoder signal.JPG

0 Kudos
Message 14 of 20
(2,209 Views)

Hi

 

Another question regarding Frequency Measurements.

1.  Must I use the PFI signals for this measurement or P0 (port 0 Digital In/Out) can also be used?

2.  What is the maximum frequency that can be measured with NI 6321?

 

Thanks

RK

0 Kudos
Message 15 of 20
(2,206 Views)

Hi Rafi,

 

You should use the PFI lines to measure your frequencies.  These give access to the on-board counters.  Port 0 is used for clocked digital IO, which could technically be made into a frequency measurement through some software processing.  However, the max sample rate for DI on the 622x and 632x is only 1 MHz so this wouldn't give you a very good resolution for your frequency measurement.

 

Using the PFI lines, the max frequency that can be measured is 25 MHz (cited in the 632x specifications as "External base clock frequency").  You would need to ensure the signal is clean however, and I would recommend a BNC terminal block as opposed to screw terminals.  You would want to use the sample clocked frequency method mentioned earlier in this thread, with a slow enough sample clock rate to ensure the accuracy you require.

 

As far as simulating encoders goes, do you have at least two counters available?  What I would do on the 632x is run a clocked DO task at 400 Hz.  This gives you the 2.5 ms resolution that you need for your z index pulse signal (it looks like it's a 5 ms pulse that occurs 2.5 ms after the edge of A).  Run two counter output "ticks" tasks, and use the DO sample clock as the source of your ticks.  One counter would have an initial delay of 2 ticks (which is the minimum) and the other counter would have an initial delay of 4 ticks, giving the 5 ms (90 degree) offset between A and B.  Since the pulses are 10 ms wide, you would want to use 4 ticks high, and 4 ticks low.  The waveform for the DO task would be [0011 0000 ...] with enough 0s at the end to bring the total to 40 samples, which would complete the 100 ms period (given 2.5 ms per sample).  You would need to start the CO tasks before the DO task to ensure they are armed when the first sample clock occurs.

 

 

Best Regards,

John Passiak
0 Kudos
Message 16 of 20
(2,189 Views)

Hi John and thank again,

 

Regarding the Encoder simulation task.

 

1.  I have all the 4 counters available for the task.  

 

2.  Can you explain the sentence  "What I would do on the 632X is run a clocked DO task at 400 Hz" ?
     I understand that we want to use a 400Hz clock for the time base of this task.  
      Why a DO task? What does it mean?
      Isn't it something  we do internally?   (I may misunderstand something here.....)

 

3.  From the drawings, I see that A and B are 100Khz == 10 usec cycle == 5 ms High & 5 ms Low
     Wave B is shifted  2.5ms from A (not 5 ms as you said).  Am I right?
     Also, the index seems 2.5ms and not 5 ms as you mentioned?  Am I right?

 

4.  How do I produce the A&B 100 Khz waveform?
     Does it take one counter for each?  
     Is the counter "ticked" by the 400Hz we set?

 

5.  Since the index is 2.5ms wide, don't we need to update the DO with 100000000000 (39 0s) in order to get it
     once every 100ms?

 

6.  Having established the 3 waveforms, I'm now confuse as to how to establish the delay between them.
     Who is the Master?
     Why both A and B get a delay (according to you..).?
      Isn't A the master waveform, thus, only B need a delay of 1 "tick" which is 2.5ms?

 

7.  It seems that Index is 2.5ms after the rising edge of A.
     If A is the Master (no delays), can I shift the index with reference to A by defining it 01000000000 (38 0s) ?

 

8.  As I mentioned in my mail, I have 6 PFI outputs and most of the DO available.

     I need to allow for 3 endoders (9 lines) 

     I thought to perform this task with 6 PFI lines and 3 DO lines.
     Should A & B be the PFI outputs and index the DO or a different combination?

      Does it matter if I use DO or PFI?  
      I thought that the best combination is to establish Waveform A with DO and make it the Master reference.
      Establish Waveform B and Index with PFI outpus using the same 400Hz time base we established.
       what do you think?

 

 

 

 

Please advice

 

Thanks and many apologies for the many questions.

 

RK

0 Kudos
Message 17 of 20
(2,174 Views)

Hi Rafi,

 

1.  This is good.  You have enough counters to output all 3 signals, but it sounds like you only have 6 PFI lines available and you need to have 9 total different outputs without having to change your external connections.  This is why you need to use DO (digital output) for at least one of the three encoder signals.

 

2.  Digital Output tasks can generate a sample clock on the 63xx boards.  So, you can write an arbitrary digital waveform, set the clock to 400 Hz, then use this clock as the basis for timing your counter outputs.

 

3.  Thanks for pointing that out, I didn't notice the 100 kHz label on the left and was instead going off of the label on the top that indicates 100 msec between your index pulses (10 Hz).  There are 5 periods of A and B that occur in between the index pulses, which would imply that A and B are only 50 Hz signals (10 msec high and 10 msec low).  My suggestion is still the same, but your waveform and timing might be different depending on what the actual signal you want to output is.  I could give more specific advice with an accurate, consistent diagram.

 

4.  It would indeed take 1 counter to output each of your A and B signals (you only have 3 DO lines available for 6 signals, so it makes more sense to use the counters for A and B to be able to use your 6 available PFI lines).  I had assumed (incorrectly) that A and B were only 50 Hz, not 100 kHz.  To generate the 100 khz signals you would need to update your DO at 400 kHz (which is still achievable).  I can't tell from your diagram what the phase of the z index needs to be relative to A and B.  If the transition does not need to occur in the middle of A and B, you could instead use the counter output as a sample clock for DO and get away with a much lower update rate.  The 632x can clock DO waveforms at 1 MHz so it shouldn't be a problem either way.

 

5.  Yes.  From my last post, "the waveform for the DO task would be [0011 0000 ...] with enough 0s at the end to bring the total to 40 samples".  I put the 0s in the front to achieve the offset from the counters, but like I mentioned earlier I didn't realize the frequency of the A and B lines was not to scale with the rest of the drawing so you'll need to change this depending on what the acutal signals need to be.

 

6.  You can't have a delay of "0" on a counter output task.  The counter will not pulse high until the 2nd tick of the timebase that is being used.  If the DO is the master task, then this 2 tick delay is significant.  If CO is the master, then 2 ticks of the internal timebase (100 MHz) is only 20 ns and probably doesn't matter.  You have drawn the z index pulse going high during the middle of a counter output pulse, so if this is a requirement it makes the most sense to use the DO as the master.  If not it might make more sense to use the CO task as the master.

 

7.  If you use the A output as the master, defining 010000... would put your index pulse on the 2nd rising edge (or falling edge if desired) of the A signal.  This is not how the diagram is drawn.

 

8.  You mentioned that you ahd 6 PFI and 3 DO lines available.  Thus is seems to make the most sense (to me at least) to use the counters on 2 PFI lines for A and B, and use 1 DO for the Index.  This way you could implement all 3 encoders (1 at a time) without having to change external connections.  You could do it another way if it makes more sense to you, but I think it would be easiest to use the counters for A and B and DO lines for Index.

 

 

Best Regards,

John Passiak
Message 18 of 20
(2,145 Views)

Hi John

 

You assistance is very useful and most appreciated!

 

I rechecked the encoder waveform requirements with my client and would like to present it to you in order to get it right this time...

 

REQUIREMENTS

1.  A & B are 100 Khz and shifted by 2.5 usec (B after A) as was shown in the diagram.   (10 usec cycle waveform,  5 usec high, 5 usec low)

2.  Index is 2.5 usec (not ms as I wrongly indicated before)

3.  Index is unsynchronized with A or B.  All we need is 2.5 usec every 100 msec  (10 hz)

4.  I have 6 PFI lines and 3 DO lines.

5.  I have 3 encoders but need to implement just 1 at a time.

6.  All the card (NI 6250) counters are available.

 

 IMPLEMENTATION

6.  As you previously recommended I will use PFI outputs for generating A and B and DO for index.  (if you still think this is the best configuration)

7.  Can you specify, based on the above data, how to implement this task?    (this is my first waveform generating task, therefore, I feel a little unsure as to how to set up the timing...)

8.  General question:

        a)  Is there a relationship between the DO and the counters timings?

        b)  Can you use all the 4 counters for tasks and still get a waveform out of DO?  (I know there is the 1MHz time base clock for generating the DO waveform, but isn't this 1MHz part of the counters resources?)

 

Thank you very much

 

RK

 

0 Kudos
Message 19 of 20
(2,121 Views)

Hi Rafi,

 

Thanks for the clarification, and for pointing out that you're using a 6250 instead of an X Series card.  This changes things slightly, but I still think you should use the counters to output A and B and the DO to output the Index, given that this fits the lines that you have available.  The fact that Index is not synched with A and B makes this a bit easier:

 

 

Here's how I would implement the task:

 

 

A:  Use a continuous counter output task.  Simply configure the counter output task to be 100 kHz, 50% duty cycle.

 

B:  You have two options (in either case, start this counter task before you start the counter task above):

        i)  Use a retriggerable, single pulse counter output task.  Trigger this off of the internal output of the first counter.  The initial delay and low time would be set to 2.5 us, the high time would be set to 5 us.

        ii) Use a continuous counter outupt task with the same pararameters as A.  Use the arm start trigger from the other counter to start this task.  Set initial delay to 2.5 us.

 

        I personally like option i) above, but you could configure the task either way.

 

Index:    Implement a clocked DO task with the appropriate waveform.  Since you're on M Series the clock has to come from another subsystem, so I suggest to use FREQ OUT.  It is programmed the same as a continuous counter output task.  You would need a clock output at 400 kHz (1/2.5 us), but frequencies availalbe on FREQ out are 10 MHz (or 100 kHz) / (1:16).  So, you can set Freq out to 2 MHz (10 MHz / 5), and just output a higher number of samples to be able to generate your index signal.  The 6250 can update DO at up to 10 MHz so this should be acceptable.  The waveform to be generated would be [1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 ...] with enough 0s at the end to make the array 200 000 points long (updated at 2 MHz this would be equal to 100 msec of data).

 

 

To answer your general questions:

 

All of the internal clocks on your M Series are derived from an on-board 80 MHz oscillator, which may be PLL'ed to a 10 Mhz reference clock if desired.  So, in the above case the DO timing is somewhat related to the counter output timing (i.e. it won't drift) but the timebases would be different.

 

The 6250 only has 2 counters (+ FREQ OUT).  The 63xx boards (which I thought you were using before) have 4 counters.  On X series boards Digital Output tasks can generate their own sample clock, while on M Series DO tasks must use a clock from another task (or from external). So, on M Series you need to use some other resources to generate your clock for DO, but on X Series you do not.

 

 

Bet Regards,

John Passiak
Message 20 of 20
(2,109 Views)