From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

6602, .NET, concepts, documentation....

Hello Ram,

Do you have a specific question about the Select_Signal() function? Are you receiving an error message?

If you are looking for a similar function in NI-DAQmx, you should examine the function called DAQmxCfgDigEdgeStartTrig(). The NI-DAQmx C Reference Help describes the DAQmxCfgDigEdgeStartTrig() function as follows:




DAQmxCfgDigEdgeStartTrig

int32 DAQmxCfgDigEdgeStartTrig (TaskHandle taskHandle, const char triggerSource[], int32 triggerEdge);

Purpose

Configures the task to start acquiring or generating samples on a rising or falling edge of a digital signal.

Parameters

Input
Name Type Description
taskHandle TaskHandle The task used in this function.
triggerSource const char [] The name of a terminal where there is a digital signal to use as the source of the trigger.
triggerEdge int32 Specifies on which edge of a digital signal to start acquiring or generating samples.
Value
Description
DAQmx_Val_Rising
Rising edge(s).
DAQmx_Val_Falling
Falling edge(s).

Return Value

Name Type Description
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.
   



I think this function should perform the operation you are looking for. If you have more questions about this, or any of the other NI-DAQmx functions, I would recommend that you examine the NI-DAQmx C Reference Help. On Windows XP, you can find this document at Start>>All Programs>>National Instruments>>NI-DAQ.

Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 21 of 30
(3,003 Views)
Hello Matt,
 
Thanks for your help. It was useful but I have some other functions used in traditional DAQ. Is there any examples for buffered event counting in VB or .Net? bcoz I have some part of code in traditional DAQ using Synchronous buffered event counting.
 
' ====[Counter 0 setup]====
        ' Reset counter 0:
        i6602Status = GPCTR_Control(i6602DeviceNum, ND_COUNTER_0, ND_RESET)
        ' Set the application (pulse-train generation):
        i6602Status = GPCTR_Set_Application(i6602DeviceNum, ND_COUNTER_0, ND_PULSE_TRAIN_GNR)
        ' Set the source for counter 0 to the maximum timebase (80MHz):
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_0, ND_SOURCE, ND_INTERNAL_MAX_TIMEBASE)
        ' Load the low count for the square wave:
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_0, ND_COUNT_1, ulLOWcount)
        ' Load the high count for the square wave:
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_0, ND_COUNT_2, ulHIGHcount)
        ' Note - no gate is required for counter 0
        ' Route output of counter 0 to RTSI_0:
        i6602Status = Select_Signal(i6602DeviceNum, ND_RTSI_0, ND_GPCTR0_OUTPUT, ND_LOW_TO_HIGH)
        ' Enable GPCTR output - is this required?
        i6602Status = Select_Signal(i6602DeviceNum, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT, ND_LOW_TO_HIGH)
        ' Setup the sync in:
        If (iMCSMode <> 1) Then
            ' Handshake or slave mode:
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_0, ND_START_TRIGGER, ND_ENABLED)
        Else
            ' In master mode we use a software trigger:
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_0, ND_START_TRIGGER, ND_AUTOMATIC)
        End If
 
 

        ' ====[Counter TAC start/stop setup]====
        ' Reset:
        i6602Status = GPCTR_Control(i6602DeviceNum, lCounter, ND_RESET)
        ' Set up for a buffered event counting application:
        i6602Status = GPCTR_Set_Application(i6602DeviceNum, lCounter, ND_BUFFERED_EVENT_CNT)
        ' Set the source for the counter:
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_SOURCE, ND_DEFAULT_PFI_LINE)
        ' Set the gate (counter 0 output via RTSI_0):
        ' Each time a pulse arrives in the gate, a new value will be latched into the counter and sent to the data buffer.
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_GATE, ND_RTSI_0)
        ' Load initial count (0):
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_INITIAL_COUNT, 0)
        ' Enable single buffer mode:
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_BUFFER_MODE, ND_SINGLE)
 

        ' Use synchronous counting:
        i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_COUNTING_SYNCHRONOUS, ND_YES)
        ' Setup the sync in:
        If (iMCSMode <> 1) Then
            ' Set start trigger - note must come before config buffer command:
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_START_TRIGGER, ND_ENABLED)
        Else
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_START_TRIGGER, ND_AUTOMATIC)
        End If
        ' Configure the DMA buffer:
        i6602Status = GPCTR_Config_Buffer(i6602DeviceNum, lCounter, 0, Int(MCS_ChannelsPerSweep.Text), pulBuffer(1))
        ' ====[Set up the sync out, master and handshake modes]====
        If (iMCSMode <> 2) Then ' <> slave
            i6602Status = GPCTR_Control(i6602DeviceNum, ND_COUNTER_7, ND_RESET)
            i6602Status = GPCTR_Set_Application(i6602DeviceNum, ND_COUNTER_7, ND_SINGLE_PULSE_GNR)
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, ND_COUNTER_7, ND_SOURCE, ND_INTERNAL_20_MHZ)
 
Thanks
0 Kudos
Message 22 of 30
(2,990 Views)
Hello Matt,
 
Now I will explain abt the problem
 
1) Buffer operation
 
I would like to do single buffer operation (finite)
 
function in traditional DAQ is
 
  i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_BUFFER_MODE, ND_SINGLE)
 
Is there any function in DAQmx to set up single buffer operation?
 
2) I would like to configure the buffer
 
function in traditional DAQ is
 
i6602Status = GPCTR_Config_Buffer(i6602DeviceNum, lCounter, 0, Int(MCS_ChannelsPerSweep.Text), pulBuffer(1)
 
Shd I configure the buffer when i do buffer operation or will be done automatically when calling the buffer operation? If not is there any function in DAQmx to configure buffer operation?
 
3) Setting up hardware trigger and software trigger
 
traditional DAQ function:
 
            Hardware trigger:
 
            i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_START_TRIGGER, ND_ENABLED)
 
           Software Trigger:
 
           i6602Status = GPCTR_Change_Parameter(i6602DeviceNum, lCounter, ND_START_TRIGGER, ND_AUTOMATIC)
 
Is there any function in DAQmx to set up different trigger?
 
 
Thanks
0 Kudos
Message 23 of 30
(2,994 Views)
Hello Ram,
 
There are several examples for .NET that install with NI-DAQmx. For more information about where they are located, you can view this KnowledgeBase online. Specifically, for .NET 2.0 in Windows XP, there is an example called "CountDigEventsBuffContinuous_ExtClk.2005.vbproj" located at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Counter\Count Digital Events\CountDigEventsBuffContinuous_ExtClk\Vb. For .NET 1.1 in Windows XP, the example called "CountDigEventsBuffContinuous_ExtClk.vbproj" is located at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1\Counter\Count Digital Events\CountDigEventsBuffContinuous_ExtClk\vb.
 
The NI-DAQmx C Reference Help file describes the NI-DAQmx Library functions. You can use this document to determine which functions would perform the functions that you have specified. You can find the NI-DAQmx C Reference Help in Windows XP by selecting Start>>All Programs>>National Instruments>>NI-DAQ>>NI-DAQmx C Reference Help. One important thing to note is that the NI-DAQmx driver defines and enforces a state model rather than individual functions for every configuration operation. For more information about this distinction, you can check out this tutorial on the advantages of NI-DAQmx and this FAQ on the difference between Traditional NI-DAQ (Legacy) and NI-DAQmx. Some functions that you might find useful include:
 


DAQmxCreateCICountEdgesChan

int32 DAQmxCreateCICountEdgesChan (TaskHandle taskHandle, const char counter[], const char nameToAssignToChannel[], int32 edge, uInt32 initialCount, int32 countDirection);

Purpose

Creates a channel to count the number of rising or falling edges of a digital signal and adds the channel to the task you specify with taskHandle. You can create only one counter input channel at a time with this function because a task can include only one counter input channel. To read from multiple counters simultaneously, use a separate task for each counter. Connect the input signal to the default input terminal of the counter unless you select a different input terminal.

Parameters

Input
Name Type Description
taskHandle TaskHandle The task to which to add the channels that this function creates.
counter const char [] The name of the counter to use to create virtual channels.
nameToAssignToChannel const char [] The name(s) to assign to the created virtual channel(s). If you do not specify a name, NI-DAQmx uses the physical channel name as the virtual channel name. If you specify your own names for nameToAssignToChannel, you must use the names when you refer to these channels in other NI-DAQmx functions.

If you create multiple virtual channels with one call to this function, you can specify a list of names separated by commas. If you provide fewer names than the number of virtual channels you create, NI-DAQmx automatically assigns names to the virtual channels.
edge int32 Specifies on which edges of the input signal to increment or decrement the count.

Value Description
DAQmx_Val_Rising Rising edge(s).
DAQmx_Val_Falling Falling edge(s).
initialCount uInt32 The value from which to start counting.
countDirection int32 Specifies whether to increment or decrement the counter on each edge.

Value Description
DAQmx_Val_CountUp Increment the count register on each edge.
DAQmx_Val_CountDown Decrement the count register on each edge.
DAQmx_Val_ExtControlled The state of a digital line controls the count direction. Each counter has a default count direction terminal.

Return Value

Name Type Description
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.


(Continued in next post...)


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 24 of 30
(2,967 Views)

(...Continued from previous post)

 


DAQmxCfgSampClkTiming

int32 DAQmxCfgSampClkTiming (TaskHandle taskHandle, const char source[], float64 rate, int32 activeEdge, int32 sampleMode, uInt64 sampsPerChanToAcquire);

Purpose

Sets the source of the Sample Clock, the rate of the Sample Clock, and the number of samples to acquire or generate.

Parameters

Input
Name Type Description
taskHandle TaskHandle The task used in this function.
source const char [] The source terminal of the Sample Clock. To use the internal clock of the device, use NULL or use OnboardClock.
rate float64 The sampling rate in samples per second per channel. If you use an external source for the Sample Clock, set this value to the maximum expected rate of that clock.
activeEdge int32 Specifies on which edge of the clock to acquire or generate samples.
Value Description
DAQmx_Val_Rising Acquire or generate samples on the rising edges of the Sample Clock.
DAQmx_Val_Falling Acquire or generate samples on the falling edges of the Sample Clock.
sampleMode int32 Specifies whether the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.
Value Description
DAQmx_Val_FiniteSamps Acquire or generate a finite number of samples.
DAQmx_Val_ContSamps Acquire or generate samples until you stop the task.
DAQmx_Val_HWTimedSinglePoint Acquire or generate samples continuously using hardware timing without a buffer. Hardware timed single point sample mode is supported only for the sample clock and change detection timing types.
sampsPerChanToAcquire uInt64 The number of samples to acquire or generate for each channel in the task if sampleMode is DAQmx_Val_FiniteSamps. If sampleMode is DAQmx_Val_ContSamps, NI-DAQmx uses this value to determine the buffer size.

Return Value

Name Type Description
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.


You can find ANSI C examples for NI-DAQmx at C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C. Again, you may be most interested in the example called Cnt-Buf-Cont-ExtClk.c located at C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Count Digital Events\Cnt-Buf-Cont-ExtClk.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 25 of 30
(2,965 Views)
Hello Matt,
 
Thanks for your response. What is the difference between software trigger and hardware trigger? How can we define that in DAQmx ?, in Traditional DAQ it can be defined by using ND_AUTOMATIC for software trigger and ND_ENABLED for hardware trigger.
 
Cheers
0 Kudos
Message 26 of 30
(2,950 Views)
Hello Ram,

To answer your question, software triggering is when the trigger to start a task is given and determined by the code. It might be at a particular moment in your code sequence you want to trigger the task. Hardware trigger on the other hand is waiting for a physical trigger edge or level trigger from an signal measured or generated on the hardware/device..

With DAQmx programming, a great resources to look for the function calls or properties is the NI DAQmx C Reference Help. There is a whole section for all the the function calls and parameters for the different types of triggering. I think it is worth while to take a look at it. The Help file can be found if you go to Start>>All Programs>>National Instruments>>NI-DAQ>> NI DAQmx C Reference Help. Take a look at DAQmxSendSoftwareTrigger and the other types of hardware triggers. Let us know if you have a specific question on the different types.

I also recall earlier on this thread I had also posted some example code for triggering. Did you run into issues with running those examples?

Regards,
  Sandra T.

Applications Engineer | National Instruments


0 Kudos
Message 27 of 30
(2,941 Views)

Hello Matt,

I have tried the function DAQmxErrChk DAQmxCfgDigEdgeAdvTrig(taskHandlePulse, "Dev1/PFI31", DAQmx_Val_Edge1_Rising) , for selecting the signal to start the trigger but getting an error as "Specified property is not supported bu the device or is not applicable to the task ", I have used the same task for both generation of pulse and for configuring the task.

 

Thanks

0 Kudos
Message 28 of 30
(2,915 Views)
Hello Ram.

If I am correct you are using a PCI-6602 Counter/Timer board. These boards do not support digital edge advance triggering. The available trigger method is arm start trigger. The arm start trigger allows you to synchronize multiple counters. Refer to the following examples:

Hardware Counter Start Trigger for Counter Synchronization

Take a look at the NI-DAQmx C Reference Help for the function calls for the Arm Start Trigger.

Regards,
  Sandra T.

Application Engineer | National Instruments
0 Kudos
Message 29 of 30
(2,897 Views)
Hi Sandra,
 
Yes I am using PCI-6602, but if you refer my previous posts I have asked about specifying Software trigger, So Advance trigger was the only option for it. So now if 6602 will not support Advance trigger function, is there any trigger function to specify it?
 
Thanks
0 Kudos
Message 30 of 30
(2,847 Views)