LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxCreateCOPulseChanTicks divide by 2

I have a similar problem to the one described in the post "Divide by 2 with PCI-6602".  I am using a USB-6251.  An encoder is wired to PFI0 and is used to drive the analog acquisition.  In some cases the encoder frequency is too high for the USB-6251 or the user would prefer a lower acquisition rate than provided by the encoder.  The most commonly desired divider ratio is 2 but that appears to be impossible with DAQmxCreateCOPulseChanTicks( ) and the suggestions in the previous post don't seem practical in this case because the second counter in the USB-6251 is used to count the encoder pulses to report shaft RPM. 
 
Its a little hard to convice my users that divide by 2 is impossible since most of them are well aware of hardware dividers and counters that can do so. 
 
Is there any other solution I can try?
 
0 Kudos
Message 1 of 8
(4,365 Views)

Hi CreviceDweller,

The smallest you can divide by is four when you use one counter. If dividing by four is not an option some other possibilities would be to use a lower pulse/rev encoder or a higher pulse/rev encoder and then divide by four. I understand that dividing by two is very easy using a hardware counter. However due to the architecture of NI cards which have to support using the counters for multiple functions it is just not possible to divide by two. I’d be happy to help you work out a solution if you can tell me a little more about your application.

1. How many ai channels are you acquiring? This will let us figure out your maximum sampling rate.

2. How many pulses/rev is your encoder and what is the rpm range of the shaft?

Let me know if you have any questions. Have a great week.

Thanks,

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 2 of 8
(4,346 Views)

Thanks for the response Nathan.  Sorry for the delay on my part, I've been out of the office since 3/5/08. 

When I used Traditional DAQ, with E series cards, I  could divide by 2 using the following code:

 

0 Kudos
Message 3 of 8
(4,308 Views)

Thanks for the response Nathan.  Sorry for the delay on my part, I've been out of the office since 3/5/08. 

When I used Traditional DAQ, with E series cards, I  could divide by 2 using the following code:

  

0 Kudos
Message 4 of 8
(4,308 Views)

Thanks for the response Nathan.  Sorry for the delay on my part, I've been out of the office since 3/5/08. 

When I used Traditional DAQ, with E series cards, I  could divide by 2 using the following code:

    SCAN_Start (devnum, piBuffer, numPoints, -3, arg5, 0, 2);

where arg5 depended on the specific E series card. 

It would seem that the equivalent should be possible with E series cards in DAQmx even if not with the USB-6251. 

While my original post mentioned the USB-6251, many of our customers still use E series cards and would like to retain the divide by 2 capability. 


0 Kudos
Message 5 of 8
(4,304 Views)

Hi CreviceDweller,

I believe I have a way to do what you want in DAQmx and it doesn’t even use a counter. You need to import your encoder signal as an AI sample clock timebase instead of as the AI sample clock. Then you can set the AI sample clock timebase divisor to 2. This will cause the card to generate one pulse on the AI sample clock for every two pulses of the AI sample clock timebase.

You can set the source of the time base using the DAQmxSetSampClkTimebaseSrc function and the divisor can be set using DAQmxSetSampClkTimebaseDiv. You can add these two functions after your call to DAQmxCfgSampClkTiming.


Here is an example of how I would set up the timing for a continuous acquisition that uses the signal at PFI0 divided by 2 for the sample clock.

DAQmxCfgSampClkTiming( taskHandle, NULL, MAX_expected_rate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, BufferSize);


DAQmxSetSampClkTimebaseSrc( taskHandle, “/Dev1/PFI0”);


DAQmxSetSampClkTimebaseDiv( taskHandle, 2);

Let me know if you have any more questions and have a great week.

Thanks,



Message Edited by Nathan_R on 03-18-2008 07:09 PM
Nathan
NI Chief Hardware Engineer
0 Kudos
Message 6 of 8
(4,278 Views)

Thanks Nathan, that works perfectly. 

By using PFI0 for the sourceI can "divide" by 1 and by using your code I can divide by 2,4, 8, etc. with BOTH E series and the USB-6251.  PLUS both counters are available to count frequency (RPM).  I was never able to divide E series by 1 with traditional DAQ.

I guess I see how the code works.  I had experimented with similar code but using the "onboard clock" seemed counter intuitive so I hadn't tried that.  Obviously I don't fully understand the hardware - software interface.  Is there a good document to help me understand this?

 

 

0 Kudos
Message 7 of 8
(4,264 Views)

Hi CreviceDweller,

I’m glad to hear everything is working for you. The code I showed you takes uses DAQmx properties to give you access to some more advanced uses of the hardware. The Getting Started with NI-DAQmx: NI-DAQmx Property Nodes Developer Zone article covers some uses for the DAQmx properties. This article is part of the Getting Started with DAQmx series. They cover everything from basic to advanced usage of the drivers.

Descriptions of all the DAQmx properties can be found in the NI-DAQmx C Reference Help under NI-DAQmx C Properties. This help file is installed with the DAQmx drivers and can be found in the Start menu under Programs\National Instruments\NI-DAQ. Let me know if you have any questions and take care.

Thanks,

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 8 of 8
(4,250 Views)