Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6210 on Linux - is DAQmxBaseCfgAnlgEdgeStartTrig supposed to work for this device?

Solved!
Go to solution

I've got two USB-6210 devices that I need to sync up so that they both gather data at exactly the same time. I'd like to trigger the data gathering for each device by sending a trigger out of Dev1/PFI6 and having both devices receive the trigger on PFI0.

 

I''ve tried using the ai example program that receives an analog start trigger and it doesn't seem to work. Here's the code I tried:

 

 

/*********************************************************************
*
* ANSI C Example program:
* acquireNScans-AnlgStart.c
*
* Example Category:
* AI
*
* Description:
* This example demonstrates how to acquire a finite amount of data
* using the DAQ device's internal clock, started by an analog edge
* condition.
*
* Instructions for Running:
* 1. Select the physical channel to correspond to where your
* signal is input on the DAQ device.
* 2. Enter the minimum and maximum voltage range.
* Note: For better accuracy try to match the input range to the
* expected voltage level of the measured signal.
* 3. Set the number of samples to acquire per channel.
* 4. Set the rate of the acquisiton.
* Note: The rate should be AT LEAST twice as fast as the maximum
* frequency component of the signal being acquired.
* 5. Set the source of the start trigger. By default this is
* analog input channel 0.
* 6. Set the slope and level of desired analog edge condition.
*
* Steps:
* 1. Create a task.
* 2. Create an analog input voltage channel.
* 3. Set the rate for the sample clock. Additionally, define the
* sample mode to be finite.
* 4. Define the parameters for an Analog Slope Start Trigger.
* 5. Call the Start function to start the acquistion.
* 6. Read all of the waveform data.
* 7. Call the Clear Task function to stop the acquistion.
* 8. Display an error if any.
*
* I/O Connections Overview:
* Make sure your signal input terminal matches the Physical
* Channel I/O Control. In this case wire your signal to the ai0
* pin on your DAQ Device. The analog start trigger must be connected
* to PFI0.
*
* Recommended Use:
* 1. Call Configure and Start functions.
* 2. Call Read function.
* 3. Call Stop function at the end.
*
*********************************************************************/

#include "NIDAQmxBase.h"
#include <stdio.h>

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

int main(int argc, char *argv[])
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
int32 i;

// Channel parameters
char chan[] = "Dev1/ai0";
float64 min = -10.0;
float64 max = 10.0;

// Timing parameters
char clockSource[] = "OnboardClock";
uInt64 samplesPerChan = 1000;
float64 sampleRate = 10000.0;

// Triggering parameters
//orig char triggerSource[] = "PFI0";
char triggerSource[] = "/Dev1/PFI0";
uInt32 triggerSlope = DAQmx_Val_RisingSlope;
float64 triggerLevel = 1.0;

// Data read parameters
#define bufferSize (uInt32)1000
float64 data[bufferSize];
int32 pointsToRead = bufferSize;
int32 pointsRead;
float64 timeout = 10.0;


DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));
printf("Calling CfgAnlgEdgeStartTrig with %s...\n", triggerSource);
DAQmxErrChk (DAQmxBaseCfgAnlgEdgeStartTrig(taskHandle,triggerSource,triggerSlope,triggerLevel));
printf("Done with StartTrig.\n");
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,bufferSize,&pointsRead,NULL));

printf ("Acquired %d samples\n", pointsRead);

// Just print out the first 10 points
for (i = 0; i < 10; ++i)
printf ("data[%d] = %f\n", i, data[i]);

Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if(taskHandle != 0) {
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}
if( DAQmxFailed(error) )
printf ("DAQmxBase Error %d: %s\n", error, errBuff);
return 0;
}

 

 

and here is the result from running the program:

 

  $ ./acquireNScans-AnlgStart
  Calling CfgAnlgEdgeStartTrig with /Dev1/PFI0...
  DAQmxBase Error -200428: Value passed to the Task/Channels In control is invalid.

The NIDAQ-mx README.txt file says this is supported for USB-621X. Can anyone tell me why this isn't working?

 

0 Kudos
Message 1 of 5
(3,076 Views)

Hello Tom,

 

Looking at your response to your other post the DAQmx Base that you have installed was released in June 2010, is this the one for July 2010 or did you use another version?

 

This looks like it is the same issue as you are having in your other post.  In the July 2010 DAQmx Base readme file for this driver it does not mention support for CentOS 5.  Since you are getting the same error code 200428 for this code, I believe that the issue is the same for both applications. 


Regards,

 

Justin

 

Justin
National Instruments
Product Support Engineer - Conditioned Measurements
0 Kudos
Message 2 of 5
(3,055 Views)

Hi Justin,

 

Yes, the DAQmx Base version is the same. The date I supplied is the date listed in the README.txt file.

 

CentOS 5 is a direct copy of Red Hat Enterprise Linux Version 5, which is listed as a supported OS. CentOS takes the freely available source code that Red Hat supplies and compiles and links the OS and releases it for free. For all intents and purposes, it is Red Hat Enterprise Linux Version 5.

 

Do you have a example program where the DAQmxBaseCfgAnlgEdgeStartTrig function works on RHEL5 with a USB-6210? If so, I'd like to try it with CentOS 5 as well.

 

Thanks,

 

-Tom

0 Kudos
Message 3 of 5
(3,048 Views)
Solution
Accepted by topic author ase-tom

Tom,

 

Analog Start and Reference Triggering are only supported on PCI,PCIe,and PXI form factors of the NI-6210.  The readme has a list of the functions that are available for USB.

 

Regards,

 

Justin

Justin
National Instruments
Product Support Engineer - Conditioned Measurements
0 Kudos
Message 4 of 5
(3,014 Views)

I guess I'll have to look at using a counter to try to synchronize these devices.

 

Thanks for your help.

0 Kudos
Message 5 of 5
(3,008 Views)