05-15-2020 08:24 AM
Hi all,
Again a couple of possibly naive questions concerning a NI USB-6212 device
run with NIDAQmx imported as a static library in a C code:
1) Is there an equivalent in NIDAQmx of the native NIDAQ 'NIDAQdelay()' function ?
2) I am trying to run the sample code 'VC_WriteDigChan_ExtClk.c' provided by NI with the NIDAQmx software (in the "...\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values\Write Dig Chan-Ext Clk" folder). The aim is to output a given number of binary
values onto a digital IO line, at a given rate, according to the ticks of an external clock.
It compiles fine, but produces the following runtime error:
------------------------------------------------------------------------------
DAQmx Error: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_SampTimingType
Requested Value: DAQmx_Val_SampClk
Possible Values: DAQmx_Val_OnDemand
Task Name: _unnamedTask<0>
Status Code: -200077
End of program, press Enter key to quit
-----------------------------------------------------------------------------
For the sake of completeness, the 'VC_WriteDigChan_ExtClk.c'
example code is reproduced below:
----------------------------------------------------------------------------------
/*********************************************************************
*
* ANSI C Example program:
* WriteDigitalChannel_ExtClock.c
*
* Example Category:
* DO
*
* Description:
* This example demonstrates how to output a finite digital
* waveform using an external clock.
*
* Instructions for Running:
* 1. Select the Physical Channel to correspond to where your
* signal is output on the DAQ device.
* 2. Select the Clock Source for the generation.
* 3. Specify the Rate of the output Waveform
* 4. Enter the Waveform Information.
*
* Steps:
* 1. Create a task.
* 2. Create a Digital Output Channel.
* 3. Call the DAQmxCfgSampClkTiming function which sets the sample
* clock rate. Additionally, set the sample mode to Finite.
* 4. Write the waveform to the output buffer.
* 5. Call the Start function to start the task.
* 6. Call the Clear Task function to clear the Task.
* 7. Display an error if any.
*
* I/O Connections Overview:
* Make sure your signal output terminal matches the Physical
* Channel I/O Control. Also, make sure your external clock
* terminal matches the Clock Source Control. For further
* connection information, refer to your hardware reference manual.
*
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
uInt8 data[1000];
uInt32 i=0;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0/line0","",DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI0",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
for(;i<1000;i++)
data[i] = (uInt8)(i%2);
/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Wait Code
/*********************************************/
DAQmxErrChk (DAQmxWaitUntilTaskDone(taskHandle,10.0));
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
------------------------------------------------------------------------------------
Many thanks in advance !
With my warmest regards...
J.P.
05-15-2020 11:29 AM
The error is telling you that your device doesn't support a hw sample clock for DIO, only on-demand static DIO. The USB-6212 spec sheet also mentions only static DIO.
-Kevin P
05-15-2020 01:50 PM
Kevin,
Again, many thanks for your very clear answer
With my best regards
J.P.