Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

about set clock rate and actual clock rate

Hi there,

  I am connecting the PFI pin to clock genrator which output clock signal at rate 1MHz (constant). But in the DAQmx Timing (Sample Clock).vi, I can set the sampling rate to anything other then 1MHz? So what happen if I set it to 1kHz instead? Will it use 1kHz or 1MHz actually?

 

What happens if I choose the rate to a numeber such that 1MHz is not dividible by that number?

 

The last quesiton. If I use the PFI as the source for timed sequence, will it really works at that high frequency? I doubt that becaue in windows, the time resolution interval is about 1ms, so what will happen if I use 1MHz clock to drive it?

0 Kudos
Message 1 of 12
(7,764 Views)

If you set the Samples/Channel to 1kHz, this will be your acquisition rate.  If you are using a software timed data acquisition device, then you are correct in assuming that about a 1ms time resolution from Windows will be the fastest rate that you can reliable capture data.  However, if you are using an external clock signal, you are likely using a hardware timed device in which the 1ms time resolution doesn't have direct effect on the rate of data acquisition.  What hardware are you using to acquire data?

Applications Engineer
National Instruments
0 Kudos
Message 2 of 12
(7,667 Views)

@SkyWalka wrote:

If you set the Samples/Channel to 1kHz, this will be your acquisition rate.  If you are using a software timed data acquisition device, then you are correct in assuming that about a 1ms time resolution from Windows will be the fastest rate that you can reliable capture data.  However, if you are using an external clock signal, you are likely using a hardware timed device in which the 1ms time resolution doesn't have direct effect on the rate of data acquisition.  What hardware are you using to acquire data?


I am using 6711. I know it supports only software-based clock but as shown in the manual I could use PFI to bind external clock for analog output. In my case, I only care the analog output but not the input. So my question is: if I have external clock of rate 1MHz which is connected to PFI, but in the code I set the timing clock rate to 1kHz, so s the actual sampling rate to be 1kHz or 1MHz?

0 Kudos
Message 3 of 12
(7,660 Views)

You should be able to use the 1MHz signal as long as you are specifying the input signal as a Sample Clock and not a Sample Clock Timebase as discussed in the Analog Output User Manual:

 

"You might use the ao/SampleClockTimebase signal if you want to use an
external sample clock signal, but need to divide the signal down. If you
want to use an external sample clock signal, but do not need to divide the
signal, then you should use the ao/SampleClock signal rather than the
ao/SampleClockTimebase. If you do not specify an external sample clock
timebase, NI-DAQ uses the Onboard Clock."

 

Using the Sample Clock Timebase, divides down the signal, in which case the 1kHz would apply.  Link to AO User Manual (pg 3-11):
http://www.ni.com/pdf/manuals/370735e.pdf

Applications Engineer
National Instruments
0 Kudos
Message 4 of 12
(7,626 Views)

@SkyWalka wrote:

You should be able to use the 1MHz signal as long as you are specifying the input signal as a Sample Clock and not a Sample Clock Timebase as discussed in the Analog Output User Manual:

 

"You might use the ao/SampleClockTimebase signal if you want to use an
external sample clock signal, but need to divide the signal down. If you
want to use an external sample clock signal, but do not need to divide the
signal, then you should use the ao/SampleClock signal rather than the
ao/SampleClockTimebase. If you do not specify an external sample clock
timebase, NI-DAQ uses the Onboard Clock."

 

Using the Sample Clock Timebase, divides down the signal, in which case the 1kHz would apply.  Link to AO User Manual (pg 3-11):
http://www.ni.com/pdf/manuals/370735e.pdf


Thanks. I read that before but it is confusing. In my case, I am connecting a 1MHz clock to PFI0 and use PFI0 to drive the analog output but in the code, I set the sample rate to 1kHz (not 1MHz). The code is shown as follows

 

clk.png

 

 

Based on the statement "If you do not specify an external sample clock timebase, NI-DAQ uses the Onboard Clock.", since I am not connecting the clock to timebase via RTSI, so does it mean even I choose PFI0 as the sample clock source, it will still use the onboard clock (i.e. software-based clock for 6711 card)? I just want to know how the above code work, will it use PFI0 as sample clock and work at rate 1kHz or will it use onboard clock and use 1MHz as sample  rate? Thanks.

0 Kudos
Message 5 of 12
(7,621 Views)

The DAQ card will output data based on the clock signal you have on PFI0.  The 1 kHz rate that you set in software doesn't do anything (the recommendation is to set it to match the rate of your external clock since in some cases it is used to determine buffer sizes etc.).  The sample clock timebase isn't used at all if you are using an external sample clock.

 

However... for this to work how you want it to, you also need to call DAQmx Write before starting your task.  Writing before the task starts allocates a buffer from which the samples will be clocked out.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 12
(7,615 Views)

@John_P1 wrote:

The DAQ card will output data based on the clock signal you have on PFI0.  The 1 kHz rate that you set in software doesn't do anything (the recommendation is to set it to match the rate of your external clock since in some cases it is used to determine buffer sizes etc.).  The sample clock timebase isn't used at all if you are using an external sample clock.

 

However... for this to work how you want it to, you also need to call DAQmx Write before starting your task.  Writing before the task starts allocates a buffer from which the samples will be clocked out.

 

 

Best Regards,


ok, so it does it mean for an external clock at fix frequency, the sample clock rate will be the same as the external clock rate if I connect it to PFI? If I need it work in different clock sample rate, I have to change the external clock frequency, right?

 

Ok, but if I connected the signal to the RTSI so use the external clock (1MHz) as the (RTSI) timebase, then I can freely change the sample rate (1kHz, 5kHz ...), is that correct?

0 Kudos
Message 7 of 12
(7,604 Views)

The sample clock and sample clock timebase can come from either PFI or RTSI (from the AO Series User Manual😞

 

AO Clock routing.png

 

If you use your external signal as the sample clock, then the sample clock rate will be the same as your external clock rate (since the sample clock is your external clock).

 

If you use your external signal as the sample clock timebase, you can specify a clock rate that is a divisor of the external clock.  The hardware will divide down your external clock to produce the rate you ask for in software (but you have to also specify the frequency of the external timebase).  If you pick a rate that is not an even divisor, the hardware will choose the closest available rate.

 

 

Best Regards,

John Passiak
0 Kudos
Message 8 of 12
(7,601 Views)

@John_P1 wrote:

The sample clock and sample clock timebase can come from either PFI or RTSI (from the AO Series User Manual😞

 

AO Clock routing.png

 

If you use your external signal as the sample clock, then the sample clock rate will be the same as your external clock rate (since the sample clock is your external clock).

 

If you use your external signal as the sample clock timebase, you can specify a clock rate that is a divisor of the external clock.  The hardware will divide down your external clock to produce the rate you ask for in software (but you have to also specify the frequency of the external timebase).  If you pick a rate that is not an even divisor, the hardware will choose the closest available rate.

 

 

Best Regards,


Thanks. I don't want to bugging this. But I try several time and still don't understand some concept here. In your figure, it shows few timebases (20MHz timebase, master timebase and ao/Sampleclock timebase) there. Here is my understanding: if I connect my external clock to PFI0, I can use PFI0 or RTSI to control two things: either ao/Sample clock timebase OR ao/Sample clock. To control the ao/Sample clock timebase, the clock rate is dividible. But if I set it as Sample clock, then the rate is constant (which is the same as the external clock frequency).

 

Before I don't know there is ao/Sample clock timebased. I keep trying to control the 20MHz timebase by the external clock, is that the right way to do so? (well I connect 1MHz clock to the 20MHz timebase pin of RTSI, but it behave pretty weird).

 

Anyway, what I need is to use constant frequency clock and can use any downconverted frequency from that clock to drive the sampling process (i.e. to use PFI as ao/Sample clock timebase not ao/Same clock).  In the manual, it reads:"

ao/SampleClockTimebase is not available as an output on the I/O connector. You might use ao/SampleClockTimebase if you want to use an external sample clock signal, but need to divide the signal down. If you want to use an external sample clock signal, but do not need to divide the signal, then you should use ao/SampleClock rather than ao/SampleClockTimebase." So how do we connect the PFI0 to ao/SampleClockTimebase?

 

 

0 Kudos
Message 9 of 12
(7,597 Views)

You could connect your signal to RTSI 7 and then use it as the Master Timebase if you wanted to.  I would just use it as the ao/SampleClockTimebase though unless you have counter tasks or something that need to use the same timebase.

 

Either way, you would set the source and rate of the timebase through a DAQmx Timing Property node.

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 10 of 12
(7,577 Views)