Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

GPCTR jumps every second count

Hi,

I'm quite new to programming DAQ cards so I hope you will forgive me if my question sounds a bit stupid...

My Card: AT-MIO-16E-10
My goal: I want to acquire data points in a regulary rhythm. For that I'm using GPCTR0 in the ND_SINGLE_PULSE_GNR-mode. The data acquisition is triggered by the GPCTR0 output. At the same time, I'd like to count the number of pulses given. For doing that I'm using the GPCTR1 counter in the ND_SIMPLE_EVENT_COUNT mode, with the ND_SOURCE = ND_OTHER_GPCTR_TC. Nearly everything is going fine, only that whan I'm reading the value of GPCTR1 with GPCTR_Watch, I got the Impression that the counter is increasing allways by two counts, leaving in my output file a coulumn with only odd numbers...

The Code (VB6.0):

GPCTR0:
Call GPCTR_Control(1, ND_COUNTER_0, ND_RESET) '????????
Call GPCTR_Set_Application(1, ND_COUNTER_0, ND_PULSE_TRAIN_GNR)
Call GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_SOURCE, ND_INTERNAL_100_KHZ)
Call GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_1, speed / 2)
Call GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_2, speed / 2)
Call GPCTR_Control(1, ND_COUNTER_0, ND_PROGRAM)

GPCTR1:
Call GPCTR_Control(1, ND_COUNTER_1, ND_RESET)
Call GPCTR_Set_Application(1, ND_COUNTER_1, ND_SIMPLE_EVENT_CNT)
Call GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE, ND_OTHER_GPCTR_TC)
Call GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE_POLARITY, ND_LOW_TO_HIGH)
Call GPCTR_Control(1, ND_COUNTER_1, ND_PROGRAM)

Thanks for any help
0 Kudos
Message 1 of 8
(3,646 Views)
When you listen to the counter output's TC, it will occur on every edge of a pulse train output. That is, every time the counter TCs the output is toggled when in toggle mode. So for a single pulse, you will get two TCs.

I hope this helps!
gus....
0 Kudos
Message 2 of 8
(3,639 Views)
So I was wrong when I thought the option:
Call GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE_POLARITY, ND_LOW_TO_HIGH)
meant that I'm only counting the changes from low to high?

And how can I change my code to do it right? (OK, I could calculate it with VB, just for interest...)

Thx for your help, Johannes
0 Kudos
Message 3 of 8
(3,637 Views)
I don't know the exact NI-DAQ syntax (I'm pretty much exclusively a LabVIEW programmer), but here's what you need to change. The source signal for counter 1 should be counter 0's output rather than its TC.

As gus mentioned, there are 2 TC's per pulse cycle, each one creating a minimum-width internal pulse. With counter 0 set up for pulse generation, each of these internal TC pulses will toggle counter 0's output. So by listening to the output, you'll count 1 rising edge per pulse cycle like you wanted.

-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 4 of 8
(3,622 Views)
Thanks a lot, I got it now. I didn't know that GPCTR_output and GPCTR_TC are 2 different signals.
I even succeed to what I wanted to do... but on a quite complicate way:
For data acquisition I use anyway the command :
Call Select_Signal(1, ND_IN_START_TRIGGER, ND_GPCTR0_OUTPUT, ND_LOW_TO_HIGH)
Now I added
Call Select_Signal(1, ND_PFI0, ND_IN_START_TRIGGER, ND_LOW_TO_HIGH)
Call GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE, ND_OTHER_GPCTR_TC)

Am I just to stupid or is it the way I have to do it?
If yes, why do I first have to define the GPCTR0_OUTPUT as In-start-trigger, then I can put the signal on the PFI0, and then finally I can choose it as my source??? Isn't this a bit strange?
Anyway, thx a lot
0 Kudos
Message 5 of 8
(3,613 Views)
Counters do not have a direct connection between a pair's counter output and the SOURCE pin of the selected counter. The only connection that is direct is from the paired counter's TC to the SOURCE pin of the selected counter. In order to make a connection between the pair's counter output (TOGGLE) and the SOURCE pin in traditional daq, you have to first connect the pair's output (TOGGLE) to another pin, like you've done. In DAQmx, we have implemented some routing ease of use features that would allow you to just select the desired source and destination and the driver will take care of finding a way to connect the two.

I hope this helps!
gus....
Message 6 of 8
(3,599 Views)
Ack! Sorry, I forgot that you were using an AT board, which is not supported under DAQmx. Just keep the DAQmx comments in mind if you move to a PCI board.
0 Kudos
Message 7 of 8
(3,598 Views)
Thanks a lot, I think this really helped.
0 Kudos
Message 8 of 8
(3,577 Views)