Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

changing clock frequency in pci-6602 and number of pulses

Hi,
I am trying to modify our exsisting program which takes a square wave at 15.723kHz as input and generates a pulse train of 1024 pulses at 20MHz in each timeperiod of the square wave, which looks like-

__|||||...1024..|||____^|||||...1024..|||____^||||...1024..|||____^ (The [^] represents the starting of next time priod of input signal).

For this generation, since the maximum internal timebase for 6602 is 80MHz, I am using COUNT_1 as 2 and COUNT_2 as 2, so that the final output frequency is 20MHz (80/4).
Now I need to modify this to generate a 16MHz output frequency which is (80/5) COUNT_1 is 2 and COUNT_2 is 3 and to generate 1024 pulse I need to use 5120 as COUNT_2 in pulse train generation code. While using this value I am missing a time period of the input signal as the pulse train goes into the next time priod. To demonstrate here is how it looks-

__||||...1024..|||||||||||||||^||_____________^||||...1024..||||||||||||^||_____________ (The [^] represents the starting of next time priod of input signal)

The code goes like this -
        GPCTR_Control(deviceNumber, gpctrNum0, ND_RESET);   
        GPCTR_Set_Application(deviceNumber, gpctrNum0, ND_PULSE_TRAIN_GNR);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum0,ND_SOURCE,ND_INTERNAL_MAX_TIMEBASE);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum0, ND_COUNT_1, 2);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum0, ND_COUNT_2, 2); <----- changed to '3' in case of 16MHz
        Select_Signal(deviceNumber, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT,ND_LOW_TO_HIGH);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum0, ND_OUTPUT_POLARITY, ND_LOW_TO_HIGH);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum0,ND_GATE,ND_OTHER_GPCTR_OUTPUT);
        GPCTR_Control(deviceNumber, gpctrNum0, ND_PROGRAM);
   
        GPCTR_Control(deviceNumber, gpctrNum, ND_RESET);   
        GPCTR_Set_Application(deviceNumber, gpctrNum, ND_RETRIG_PULSE_GNR);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum,ND_SOURCE,ND_INTERNAL_MAX_TIMEBASE);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum, ND_COUNT_1,0);
        GPCTR_Change_Parameter(deviceNumber, gpctrNum, ND_COUNT_2,4096); <----- changed to 5120 in case of 16MHz
        GPCTR_Control(deviceNumber, gpctrNum, ND_PROGRAM);
It would be great if someone can help me out in generating a 1024 pulse train at 16MHz on PCI-6602.

thanks,
-Pav.
0 Kudos
Message 1 of 3
(3,474 Views)

It appears to me that your timing specs are incompatible.  To produce 1024 cycles at 16 MHz requires 1024/16e6 = 64 microseconds.  Meanwhile your incoming 15.723 kHz trigger signal represents an interval of 63.601 microseconds between triggers.   My calculator says you've only got time enough to produce 1017 full cycles in that time period, causing you to catch triggers 1,3,5,... while missing triggers 2,4,6,...

Since you mathematically cannot fit 1024 cycles of a 16 MHz pulsetrain inside one period of a 15.723 trigger pulsetrain, something's gonna have to be traded off.  As you know, you CAN get exactly 1024 cycles if you stick with a 20 MHz pulsetrain.  Or you could get fewer cycles (1017) if you need the 16 MHz rate.  Finally, can you control the trigger freq?  It would appear that you could get 1024 cycles at 16 MHz if your trigger freq was <15.625 kHz.

What is your app?  Can one of these tradeoffs work for you?

-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 2 of 3
(3,472 Views)
Hi Kevin,
We have just figured it out that it is impossible to generate 1024 pulses at 16MHz. So we are now trying to get 1200 pulses at 20MHz frequency, which seems will work for us. Now I have to play with other board (strategic board) to work with 1200 pulses. Thanks though for your reply.
-Pav
0 Kudos
Message 3 of 3
(3,470 Views)