Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

SG04: why the displayed data is wrong?

Question (1):
SG04 does work in DAQmax Explorer. However, following show all data as 0.00000, how to display correct data?

iStatus=DAQmxCreateAIStrainGageChan
(0, //TaskHandle taskHandle,
"SCC1Mod1/ai0", //const char hysicalChannel[],
"ai0", //const char nameToAssignToChannel[], ???
-0.001, //float64 minVal,
0.001, //float64 maxVal,
1, //int32 units,
DAQmx_Val_FullBridgeI, //int32 strainConfig,
DAQmx_Val_Internal, //int32 excitSource,
2.5, //float64 excitVal,
2.0, //float64 gageFactor,
0.0, //float64 initialBridgeVoltage,
120, //float64 nominalGageResistance,
0.285, //float64 poissonRatio,
0.0, //float64 leadWireResistance,
NULL //const char customScaleName[]
);

for (int i=0; i<1024; i++)
{
iStatus=DAQmxReadAnalogF64 (
0, //TaskHandle taskHandle,
1024, //int32 numSampsPerChan,
10000, //float64 timeout,
DAQmx_Val_GroupByScanNumber, //bool32 fillMode, ???
data, //float64 readArray[],
10000, //uInt32 arraySizeInSamps,
NULL, //int32 *sampsPerChanRead, ???
NULL //bool32 *reserved
);

sprintf(buff,"%f",data[i]);
GetDlgItem(IDC_BUFFER)->SetWindowText(buff);
GetDlgItem(IDC_BUFFER)-> UpdateWindow();
}


Question (2)
Suppose sampling rate is 1000 samples per second, number of 1024x2 data acquired every time, SG04 has two channels (0,1), how to let chan0 and chan1 get the data at the same time, i.e., DataChan0[i] and DataChan1[i] acquire data at the same time? What is their relationship with data[i] as defined above?
0 Kudos
Message 1 of 7
(3,799 Views)
Hi mwibm,

The code you have to create the strain channel looks good. Do you have code in your program which creates the task, configure the timing parameters, and start the task to read from the strain channel?

For an example of the code structure, try looking at the following example:
C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Strain\Cont Strain Samples

Currently, you're reading from analog input channel 0 only, so your data array will consist of 1024 points acquired from that channel. If you want to read from both channels, you should create a strain channel for both ai0 and ai1, then include both channels into the task. Since the "fillMode" you've selected is "DAQmx_Val_GroupByScanNumber", the samples from the two channels will be interleaved (e.g. sample 1 from ch0, sample 1 from ch2, sample 2 from ch 0, ...).

Hope this helps,
Lesley Y.
Message 2 of 7
(3,790 Views)
Hi, Lesley, Many thanks!

I am not familar with creates the task, configure the timing parameters, and start the task to read from the strain channel, could you please give me an example? The file may be large, so please send me an email to hollychen16@yahoo.ca

Thanks again for your help!
0 Kudos
Message 3 of 7
(3,787 Views)
iStatus = DAQmxStartTask (0);
iStatus = DAQ_Start(iDevice, iChan, iGain, piBuffer, ulCount,iSampTB, uSampInt);
//iRetVal = NIDAQErrorHandler(iStatus, "DAQ_Start", iIgnoreWarning);
DAQmxCfgSampClkTiming (
0, //TaskHandle taskHandle,
"", //const char source[],
1000, //float64 rate,
DAQmx_Val_Rising, //int32 activeEdge,
DAQmx_Val_ContSamps, //int32 sampleMode, DAQmx_Val_FiniteSamps
1000); //uInt64 sampsPerChanToAcquire);
0 Kudos
Message 4 of 7
(3,771 Views)
Hi mwibm,

Some examples have been installed with your DAQ driver. If you navigate to the following path, you will be able to find it. This example will show you how the task is created.

C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog In\Measure Strain\Cont Strain Samples

Also, I noticed from a different post that you encountered a link error. Try to run this example and see if you encounter the same problem still.

Thanks,
Lesley
0 Kudos
Message 5 of 7
(3,767 Views)
Hi, Lesley,

The NI's example (ANSI C) can run without any error. But if I run my code in VC6, it has the error. I had included the *.h and *.lib. I do not know what is the real reason of the error.

Thanks.
0 Kudos
Message 6 of 7
(3,760 Views)
Hi mwibm,

To keep things simple, I will respond to the other thread created, since both postings are referring to the same issue:

http://forums.ni.com/ni/board/message?board.id=300&message.id=1729

Thanks,
Lesley
0 Kudos
Message 7 of 7
(3,746 Views)