Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

do other events while reading (daqmxread...) in VB6

Hello,

I am new to using VB6 with NI-DaqMX (with C API).  I am trying to modify old VB6 code to work with a newer USB daq device (USB-6259).  I will eventually convert app to .net however the DAQ code I use is probably less than 1% of the total code.

I want to be able to do a read (DAQmxRead...(binaryI16, analogF64) of an analog signal for 3 seconds (300 samples).  Within that 3 second time I want to turn on and off some digital lines while the analog acq is taking place.

I tried the acqintclk sample (from VB6 examples), the code works, however VB6 does not continue on to the next line (which is PopulateListView... in the example).  I am used to using a CWAI control from Measurement Studio, that once the complete acq happens the acquireddata event would fire.

I was able to download another sample from the NI website (Cont Acq-Int Clk-Every N Samples Event (VB6)) filename: 200036.  This seems to work however I have a problem with it:

It seems alot more complicated than I need.  I don't necessarily need continuous, after I do the 3 second sample I will be done,  I can Start the task again later.  Is this

In the UI if I put in 300 (or anything a multipe of 3), I get the following error: Run-time error  '-200877 (fffcef53) - Requested Every N samples Event Interval is not supported for the given Data Transfer Mechanism and buffer size.
0 Kudos
Message 1 of 4
(7,532 Views)
Hi,

Please see this forum post. It address the error you are seeing with the second code.


Abhinav T.
Applications Engineering
National Instruments India

LabVIEW Introduction Course - Six Hours
Getting Started with NI-DAQmx
Measurement Fundamentals
0 Kudos
Message 2 of 4
(7,506 Views)
Thanks for the info:

I found the solution earlier this week:  I used: DAQmxSetBufInputBufSize(taskhandle, 1200)

I have the following code in my app, I show you this to make sure it is in the right order.  It is working so I am just double checking with someone else.  Also, I am grabbing 300 samples from 4 analog (voltage) channels for 3 seconds.  I had my buffer at 3000 just to have some high number, but today I put it at 1200 just to fit exactly 1200 data points.  After I have the 1200 I save them to a file (and other arrays).

   DAQmxErrChk (DAQmxCreateTask("", taskhandle))
   
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskhandle, channel, "", DAQmx_Val_Cfg_Default, minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts,    vbNullString))
   
    DAQmxErrChk (DAQmxSetBufInputBufSize(taskhandle, 1200))
   
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskhandle, "", SampleRateTextBox.Text, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, samplesPerChannelPerRead))
   
0 Kudos
Message 3 of 4
(7,508 Views)
Your code looks correct to me. The order of the DAQ function calls also are correct.
Regards,

Ima
Applications Engineer
National Instruments
LabVIEW Introduction Course - Six Hours
Getting Started with NI-DAQmx
0 Kudos
Message 4 of 4
(7,481 Views)