Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select destinations for the counter/timer signals in NI-DAQmx?

Solved!
Go to solution

In document DAQ M Series
M Series User Manual
NI 622x, NI 625x, and NI 628x Devices
M Series User Manual
July 2008
371022K-01

is written on page 7-30:

Default Counter/Timer Pinouts
By default, NI-DAQmx routes the counter/timer inputs and outputs to the PFI pins, shown in Table 7-4.
Table 7-4. 68-Pin Device Default NI-DAQmx Counter/Timer Pins
Counter/Timer Signal        Default Connector 0 Pin Number (Name)
CTR 0                                 OUT 2 (PFI 12)

You can use these defaults or select other sources and destinations for the
counter/timer signals in NI-DAQmx. Refer to Connecting Counter Signals
in the NI-DAQmx Help or the LabVIEW Help in version 8.0 or later for
more information about how to connect your signals for common counter
measurements and generations.

I could not find any hint to the appropriate DAQmx command in the "NI-DAQmx C Reference Help" to select other destinations for the counter/timer signals in NI-DAQmx.
Please can you tell me the right DAQmx command ? Thank you very much.
I use the device NI USB-6259 M Series DAQ Device, BNC Term.

0 Kudos
Message 1 of 7
(9,962 Views)

Hi,

 

I am not sure if I got your problem correctly, but I suppose you want to do a Counter Measurement using PFIx as a trigger, where x stands for the number of the PFI Input.

After looking into the routing table, for the PCI- 6259, I saw, that theres a direct connection between the PFI channels as a source and the counter channel as a destination. If his is, what you want to do, I could do an IO trace of the DAQmx commands.

 

Also have you had a look at the examples for programming DAQmx with C?

 

The command for connecting two channels is:

DAQConnectTerminals ("/Master/PFI8", "/Master/PFI0", "InvertPolarityNo", "")

Where Master is the Name of my Card.

But as I said: the connections can only be routed manually for the routes that are marked with a yellow square.

 

Could you please specifiy your problem further, so I can have a better look at it. What is it, you want to do?



Remember Cunningham's Law
0 Kudos
Message 2 of 7
(9,955 Views)

An even better way to do counter output signal routing is using the DAQmxExportSignal function. The reason is the route is bound to a particular task. If you use DAQmxConnectTerms, the route you set is active until you explicitly do a DAQmxDisconnectTerms for that route or reset the device. This is even the case if you run a completely different piece of DAQ code. By using DAQmxExportSignals, once the task is destroyed, the route from the output to the PFI is also removed. Below is the function definition. You can also find this in the NI-DAQmx C Reference Help.

 

 

DAQmxExportSignal

int32 DAQmxExportSignal (TaskHandle taskHandle, int32 signalID, const char outputTerminal[]);

Purpose

Routes a control signal to the specified terminal. The output terminal can reside on the device that generates the control signal or on a different device. Use this function to share clocks and triggers between multiple tasks and devices. The routes created by this function are task-based routes.

Parameters

Input
NameTypeDescription
taskHandle TaskHandle The task used in this function.
signalID int32 The name of the trigger, clock, or event to export.
Value Description
DAQmx_Val_AIConvertClock   Clock that causes an analog-to-digital conversion on an E Series or M Series device. One conversion corresponds to a single sample from one channel.
DAQmx_Val_10MHzRefClock   Output of an oscillator that you can use to synchronize multiple devices.
DAQmx_Val_20MHzTimebaseClock   Output of an oscillator that is the onboard source of the Master Timebase. Other timebases are derived from this clock.
DAQmx_Val_SampleClock   Clock the device uses to time each sample.
DAQmx_Val_AdvanceTrigger   Trigger that moves a switch to the next entry in a scan list.
DAQmx_Val_ReferenceTrigger   Trigger that establishes the reference point between pretrigger and posttrigger samples.
DAQmx_Val_StartTrigger   Trigger that begins a measurement or generation.
DAQmx_Val_AdvCmpltEvent   Signal that a switch product generates after it both executes the command(s) in a scan list entry and waits for the settling time to elapse.
DAQmx_Val_AIHoldCmpltEvent   Signal that an E Series or M Series device generates when the device latches analog input data (the ADC enters "hold" mode) and it is safe for any external switching hardware to remove the signal and replace it with the next signal. This event does not indicate the completion of the actual analog-to-digital conversion.
DAQmx_Val_CounterOutputEvent   Signal that a counter generates. Each time the counter reaches terminal count, this signal toggles or pulses.
DAQmx_Val_ChangeDetectionEvent   Signal that a static DIO device generates when the device detects a rising or falling edge on any of the lines or ports you selected when you configured change detection timing.
DAQmx_Val_WDTExpiredEvent   Signal that a static DIO device generates when the watchdog timer expires.
outputTerminal const char [] The destination terminal of the exported signal. You can specify a string containing a comma-delimited list of terminal names.

Return Value

NameTypeDescription
status int32 The error code returned by the function in the event of an error or warning. A value of 0 indicates success. A positive value indicates a warning. A negative value indicates an error.

 

Steven K.
National Instruments
Software Engineer
0 Kudos
Message 3 of 7
(9,950 Views)

Hello Steven and Peter ,
thanks for your answers. However they did not yet solve my problem. I only want to release PFI 12 and use it as a normal digital output instead of having the clock of CTR 0 driving PFI 12. I don't want to see that clock at all.
In my code I use ctr0 to internally clock a digital input bus. Now I inserted the following code as proposed by Steven:
    DAQmxErrChk( DAQmxExportSignal ( _taskHandleCounterInput,
        DAQmx_Val_CounterOutputEvent , "/Dev1/PFI7" ) );

Now /Dev1/PFI7 also drives the clock, together with PFI 12.

For the command DAQmxDisconnectTerms is written:
int32 DAQmxDisconnectTerms (const char sourceTerminal[], const char destinationTerminal[]);
Purpose
Removes signal routes previously created using DAQmxConnectTerms. DAQmxDisconnectTerms cannot remove task-based routes, such as those created through timing and triggering configuration.

However I don't have previously used DAQmxConnectTerms.

With which DAQmx command  can I release PFI 12 and use it as a normal digital output instead of having the clock of CTR 0 driving PFI 12 ?

Thanks and kind regards
datafriend

0 Kudos
Message 4 of 7
(9,925 Views)
Solution
Accepted by topic author datafriend

datafriend,

 

If I remember correctly, you can 'free' the default counter output terminal by calling DAQmxSetCOPulseTerm and passing an empty string in for 'data'.

 

Hope that helps,

Dan

 

Edit: You can also set this to any other valid terminal (ie... "Dev1/PFI0") and send the output there.

Message 5 of 7
(9,909 Views)

Did this resolve the issue?

 

Please let me know if you need further assistance.



Remember Cunningham's Law
0 Kudos
Message 6 of 7
(9,882 Views)

Hello Dan and Peter,

thank you very much. Dan's proposal solved my problem:

With DAQmxSetCOPulseTerm PFI 12 will be freed and can be used as a normal digital output instead of having the clock of CTR 0 driving PFI 12:

 

    DAQmxSetCOPulseTerm( _taskHandleCounterInput, "Dev1/ctr0", "" );

 

Thanks and kind regards

datafriend

0 Kudos
Message 7 of 7
(9,878 Views)