Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure DAQmx_Val_Cfg_Default for differential voltage

Dear friends:

I'm trying to adquire analog samples with a NiDaqPad6015 in VB6 in differential mode from two different channels. To create de AI channel I use:

DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0:1", "", DAQmx_Val_Cfg_Default, "-5","5", _
                    DAQmx_Val_VoltageUnits1_Volts, "")

After that I use the DAQmxCfgSampClkTiming statement , and finally the DAQmxReadAnalogF64 statement.

Afeter taht I get an array full of values , but I think ( I'm sure) that those are not the real voltage values.

How can I configure the channel for differential mode adquiring? What am I doing wrong?

Thanks
0 Kudos
Message 1 of 9
(14,459 Views)
Hi there,
 
the normal structure for example for a continous acquisition are the next functions:
 
CONFIGURATION OF THE TASK/CHANNELS/CLOCK:
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));                /*Create Task*/
 DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));           /* Add channels to the task */
 DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));              /* Configure the timing/ sample clock*/
 
START THE TASK:
DAQmxErrChk (DAQmxStartTask(taskHandle));         /*Start the task*/
 
READ THE DATA (WHILE LOOP IN CONTINOUS ACQ)
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByScanNumber,data,1000,&read,NULL));   /*Read the data from the buffer*/
 
STOP AND CLEAR THE TASK:
DAQmxStopTask(taskHandle);                     /*Stop the task*/
DAQmxClearTask(taskHandle);                    /*Clear the task. Free resources*/
 
 
Please check your code has this correct structure,

Regards,

Jaime Cabrera

NI Applications Engineering Spain


Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Message 2 of 9
(14,443 Views)
Thanks a lot , That's exactly the structure I use. I don't get error messages-
 
But , i need to scan channel0 and channel1 simultaneosly , and in differential mode. So i use the CreateAIChannel as it follows:
 
DAQmxErrChk   DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0:1", "", DAQmx_Val_Cfg_Default, -5.00, 5.00,                  
                                                                            DAQmx_Val_VoltageUnits1_Volts, "")
 
And it creates it without errors , but the readed values are not the correct values. How can I confugure the channel for differential voltage readings?
0 Kudos
Message 3 of 9
(14,434 Views)

Probably the problem is on the read function. The documentation of the function is the next one... be carefull when using more than one channel if u group by scannumber (in the result vector is 1 sample for each channel interleaved )and group by channel (first all the samples of one channel and then the other ones... in blocks not interleaved).

Regards,

 

DAQmxReadAnalogF64

int32 DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);

Purpose

Reads multiple floating-point samples from a task that contains one or more analog input channels.

Parameters

Input
Name Type Description
taskHandle TaskHandle The task to read samples from.
numSampsPerChan int32 The number of samples, per channel, to read. The default value of -1 (DAQmx_Val_Auto) reads all available samples. If readArray does not contain enough space, this function returns as many samples as fit in readArray.

NI-DAQmx determines how many samples to read based on whether the task acquires samples continuously or acquires a finite number of samples.

If the task acquires samples continuously and you set this parameter to -1, this function reads all the samples currently available in the buffer.

If the task acquires a finite number of samples and you set this parameter to -1, the function waits for the task to acquire all requested samples, then reads those samples. If you set the Read All Available Samples property to TRUE, the function reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.
timeout float64 The amount of time, in seconds, to wait for the function to read the sample(s). The default value is 10.0 seconds. To specify an infinite wait, pass -1 (DAQmx_Val_WaitInfinitely). This function returns an error if the timeout elapses.

A value of 0 indicates to try once to read the requested samples. If all the requested samples are read, the function is successful. Otherwise, the function returns a timeout error and returns the samples that were actually read.
fillMode bool32 Specifies whether or not the samples are interleaved.
Value Description
DAQmx_Val_GroupByChannel Group by channel (non-interleaved)
DAQmx_Val_GroupByScanNumber Group by scan number (interleaved)
arraySizeInSamps uInt32 The size of the array, in samples, into which samples are read.
reserved bool32 * Reserved for future use. Pass NULL to this parameter.
Output
Name Type Description
readArray float64 [] The array to read samples into, organized according to fillMode.
sampsPerChanRead int32 * The actual number of samples read from each channel.

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.

Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Message 4 of 9
(14,431 Views)
How to configure gain in PCI6013 PGIA FOR DIFFERENTIAL MODE MEASUREMENT.
0 Kudos
Message 5 of 9
(14,369 Views)
HI,
 
You dont need to configure the gain manually with NI products.
 
Just saying which are the ranges of your input signal the driver automatically calculates the optimal gain and use it.
 
So just saying which are the input ranges (for example if your signal is  between 0 and 100 mV) the card gets correctly configured for the best acquisition.
 
Regards,
 
Jaime Cabrera
NI Applications engineering spain
Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Message 6 of 9
(14,320 Views)

Hi Jamie,

I was reading this tread in the hope that it will tell me how to configure DAQmx_Val_Cfg_Default for differential voltage. This question still is not answered. How do I select two single ended measurement on AI0 and AI4?  How do I select single differential measurement to measure difference between AI0 and AI4? Sorry but this is not obvious to me.

0 Kudos
Message 7 of 9
(12,025 Views)

Re : How letskick configure live copa america 2011 Qmx_Val_Cfg_Default for differential voltage  

letskick  copa america

 

 

0 Kudos
Message 8 of 9
(11,893 Views)

When you call "DAQmxCreateAIVoltageChan", you need to set the "terminalConfig" to the proper value. You can find the values on the NIDAQmx.h header.

 

For example, if you need single differential measurement, set it to 10083 .

 

So, instead of using "DAQmx_Val_Cfg_Default", you set it to the correspondent terminalConfig integer.

 

Extracted from NIDAQmx.h :

 

DAQmx_Val_RSE = 10083
DAQmx_Val_NRSE = 10078
DAQmx_Val_Diff = 10106
DAQmx_Val_PseudoDiff = 12529

 

Reference: http://zone.ni.com/reference/en-XX/help/370471W-01/daqmxcfunc/daqmxcreateaivoltagechan/

0 Kudos
Message 9 of 9
(10,775 Views)