Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Read event in DAQmx with VB6

Hi,
 
I'm new to NI-DAQmx, I'll develop DAQ applications with VB.Net and DAQmx but feel maybe it's better to try with VB6 first. I've looked at the examples for DAQmx 7.5 using VB6, but have not been able to find an equivalent event to the CWAI_AcquiredData(,) event for the activeX controls in traditional NI-DAQ. My applications will continuously acquire analog data and should parse data in such an event if there is one.  
 
Look forward to your advice.
 
Thank you in advance,
 
LogicT
 
    
0 Kudos
Message 1 of 14
(9,594 Views)
Hello LogicT,

Even though DAQmx 7.5 has support for VB 6.0, it doesn't support the CWAI Measurement Studio controls.  I would suggest moving to VB.NET since there are more example programs and documentation.  Perhaps you will find what you need there.  The examples can be found here:
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx

Take a look at those at let us know if you have any other questions!
Eric
DE For Life!
0 Kudos
Message 2 of 14
(9,574 Views)

Thank you very much, E. Lee!

Yes, moving to .NET is the ultimate goal, but I feel VB6 might be a good starting point to get familar with the DAQmx functions since I dare not claim myself as a .NET pro.

May I discuss a little bit further with you about the VB6? I had a traditional NI-DAQ application with VB6 and AI activeX control, I used AcquiredData event to parse and process the acquired data. Now I'm using the NI-DAQmx 7.5 nidaqmx.tlb library and DAQmxReadAnalogF64 function to read data, but I have not found an event to notify me that the specified data has been acquired. Is there any such an event or any way round to do this?

I read another thread "How do I keep track of all samples acquired?" and the suggested solution was to use DAQmxGetReadAvailSampPerChan function, will that work for me? If viable, are there any examples to demonstrate it?

I haven't get into the .NET examples yet, but my concern is I may face similar situation when I use VB.NET and DAQmxReadAnalogF64 function.

Thanks again,

LogicT

 

 

0 Kudos
Message 3 of 14
(9,570 Views)

Hello LogicT

Microsoft provides a free book that will guide users who are upgrading to VB.NET. It's pretty comprehensive and can be downloaded for offline reading. See this link for more information. Get 'em while they're hot 🙂

For the VB 6.0 type library appraoch, you could use the DAQmxRegisterEveryNSamplesEvent function to register for a synchronous event to inform you when a certain number of samples have been acquired. You could then call the read function inside of this event. Or you could just call the read in a loop with Application.DoEvents. But this latter approach might cause UI delays,especially if your sampling rate is slow and it takes a while to acquire the data.

But honestly, if the ultimate goal is to move to VB.NET, then I would not recommend the approach you're taking. The DAQmx API for .NET is a native .NET library. The documentation for it is integrated into the Visual Studio Help system. There are alot more shipping examples and concept documents for the .NET library then there are for the VB 6.0 type library for DAQmx. Trying to make a direct conversion from the VB 6.0 type library application to a VB.NET app will not provide you with optimal results. If the end goal is to have a VB.NET DAQmx application, I would recommend starting in VB.NET. Use the book I mentioned above as a starting resource. The example you're looking for is under ..\DotNET\Examples\DAQmx\Analog In\Measure Voltage\ContAcqVoltageSamples_IntClk

PS: Even thought the path mentioned by E.Lee has Measurement Studio in there, you do not need to purchase Measurement Studio to get the .NET DAQmx API. It is available as part of the DAQmx driver for free. The Help and examples are all included.

I hope this helps



Bilal Durrani
NI
0 Kudos
Message 4 of 14
(9,553 Views)

Dear Bilal Durrani,

Thank you so much for your advice! I'll be looking into it.

LogicT

 

 

0 Kudos
Message 5 of 14
(9,551 Views)

Hello,

Can anyone tell me how to use the "DaqmxRegisterNsamplesEvent" in Visual Basic 6.0 ?

I would apreciatte some example code. I just can´t figure out how to use it...

0 Kudos
Message 6 of 14
(9,497 Views)
Hello pacheco,

You can find all the documentation you need in order to use "DAQmxRegisterEveryNSamplesEvent" in the NI-DAQmx C API Visual Basic 6.0 Help (Start>>All Programs>>National Instruments>>NI-DAQ).  Unfortunately there are no examples on how to use this function in VB 6.0, but if you want, you can take a look at the ANSI C example that uses the function.  If you installed support for ANSI C, the example should be located here: C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Events\Every N Samples\Cont Acq-Int Clk-Every N Samples Event
Eric
DE For Life!
0 Kudos
Message 7 of 14
(9,469 Views)
i also got a problem to use this function in VB6. the callback function is call on time when i first call DaqmxRegisterNsamplesEvent but after that it don't produce event as desire.
I think this is a problem of declaration of the parameter pass to the callback function i don't know how to convert the C example :
 
int32 CVICALLBACK EveryNSamplesCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
 
in VB6
 
Some help would be helpful
 
thanx by advance
 
0 Kudos
Message 8 of 14
(9,321 Views)
Hello,
 
I think  i solved my problem, I am attaghing a sample of my code.
It works fine for me..hope it works for you too.
 
 
0 Kudos
Message 9 of 14
(9,311 Views)
thank you for your answer. I am not at the ofice right now so i can't try that.
But one question ine the event subroutine you use stoptask. if you stop the task how will it generate the next event????
the things i want to do is get an event each time n sample are acquired but this as long as i want. here you only do it one time? am i wrong???
 
thank you
Olivier
0 Kudos
Message 10 of 14
(9,308 Views)