NI Home > Community > NI Discussion Forums

Measurement Studio for VB6

Showing results for 
Search instead for 
Do you mean 
Reply
Member
AndrzejS
Posts: 8
0 Kudos
Accepted Solution

parallel execute writing and reading

Hello,

I'm using DAQmx NI-USB-6259

I have problem with with parallel execute writing analogue signal (for example 1000 points per 1second) on physical channel Dev1/ao0 and at the same time read 1000 points  per 1second from physical channel Dev1/ai0 how to do this?
I've tried to use DAQmxExportSignal but it doesn't work well or simply I don't know how to do it properly :smileysad:  Maybe should I use another function?

 

Best regards,

AndrzejS

Active Participant
dobarni
Posts: 260
0 Kudos

Re: parallel execute writing and reading

Hi Andrzej,

 

You should be able to find DAQmx examples for VB6 under the following folders:

 

Visual Basic 6.0

NI-DAQmx 8.5 and Later

Windows Vista examples are located at:

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\...

Windows XP or 2000 examples are located at:

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\...

NI-DAQmx 8.3.1 and Earlier

Examples are located at:

C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\.. 

 

 Synchronizing an analog output and analog input task using the DAQmx driver API should be done same way as in LabVIEW, thus check this link to see the synchronization concept. 

 

I hope this helps!

 

Regards,

Barna

National Instruments 

Member
AndrzejS
Posts: 8
0 Kudos

Re: parallel execute writing and reading

Thanks to everyone :smileyhappy:
I've used function (in VB6):
int32 DAQmxCfgDigEdgeStartTrig (TaskHandle taskHandle, const char triggerSource[], int32 triggerEdge);
and its work well :smileyhappy:

But now I have problem how to put a delay between two this two task :smileysad:

In my project I write (e.g. 1000 values) using the DAQmxWriteAnalogF64 function and at the same time I read response using the DAQmxReadAnalogF64 function. And it's work.
But I think It's not good idea to write and read exactly at the same moment. The response signal hasn't enough time to stabilize :smileysad:

I've tried to use:
DAQmxErrChk DAQmxGetStartTrigDelayUnits(taskHandle_X_Read, 10364) ' set units - seconds
DAQmxErrChk DAQmxGetStartTrigDelay(taskHandle_X_Read, 0.04) ' 0s start write function, 0.05s next set value
But it doesn't work :smileysad:

Anybody know how to put the small delay between this two tasks?

BR,
Andrzej
Active Participant
dobarni
Posts: 260
0 Kudos

Re: parallel execute writing and reading

Hi Andrzej,

 

I am glad you managed to synchronize the analog output and analog input tasks.

 

Can you be more specific on what it means "doesn't work". Do you receive an error? Or the delay is not there? How do you trigger the two tasks? Try to triggering the AO task than start the AI task with either a different trigger type (i.e. Analog edge and set level to close to stabilized value) or with the Start.Trigger.delay function calls.

 

Let me know how it works.

 

Regards,

Barna Dobai

National Instruments 

 

PS. Have you checked this page: Getting Started with NI-DAQmx: Main Page

 

Member
AndrzejS
Posts: 8
0 Kudos

Re: parallel execute writing and reading

Hi Barna,

I don't receive any errors. Simply, I can't observe any delay. I'm using a code which part is bellow:

' I trigger task using function:
        DAQmxErrChk DAQmxCfgDigEdgeStartTrig(taskHandle_X, "ai/StartTrigger", clockEdge) 'trigger the two task

' here I try to put to the code Start Trigger delay:
        DAQmxErrChk DAQmxGetStartTrigDelay(taskHandle_X, 0.04) ' 40 milisecond delay
        DAQmxErrChk DAQmxGetStartTrigDelayUnits(taskHandle_X, 10364) 'delay units = second

'the Write Task writing 10samples e.g. 1V, 2V, 3V...10V. It takes exacly 0.5s:  
        DAQmxErrChk DAQmxWriteAnalogF64(taskHandle_X, numSampsPerChannel, True, 10#, _
                                        DAQmx_Val_GroupByScanNumber, Data(0), sampsPerChanWritten, ByVal 0&) ' writing samples to AOchannel

'at the same time program read values from Read Task:      
        DAQmxErrChk DAQmxReadAnalogF64(taskHandle_X_Read, (numSampsPerChannel + Me.zgranieOI.Text), 10#, _
                                        DAQmx_Val_GroupByScanNumber, DataRead(0), (numSampsPerChannel + Me.zgranieOI.Text), _
                                        (numSampsPerChannel + Me.zgranieOI.Text), ByVal 0&) ' reading samples from AIchannel
'This function read e.g. 0.5V, 1V, ....5V in response on writing values. These values aren't stabilized (because writing input and reading response from detector at the same time)
'I know that this not working because when (for checking) I set 75 millisecond delay I should read values something like:
'1V, 1.5V, ....5V, 5V =>the response should be shifted.

Yes I check this page. I've found a good example http://zone.ni.com/devzone/cda/epd/p/id/905. But it is for .NET and I don't know how to do it under VB6 :smileysad:

Best regards,
Andrzej
Active Participant
dobarni
Posts: 260
0 Kudos

Re: parallel execute writing and reading

Hi Andrzej,

 

You've found a great example actually. Now you just need to implement it in VB6 :smileyhappy:. Basically what you'll have to make sure is that you configure the analog output task first than the analog input task. Thank you'll have to trigger the analog output task than configure the analog input task trigger to start with delay, as you can see in the picture below. Try to implement the trigger delay in the same way as in the screenshot below (note: the dark green wire - error wire - will indicate the order of calling the DAQmx functions in the Labview VI)

 

aoai_startdelay.png 

 

I hope this helps.

 

Regards,

Barna D.

National Instruments 

Member
AndrzejS
Posts: 8
0 Kudos

Re: parallel execute writing and reading

Hi Barna,

one year ago you helped me with synchronization of the analog output and analog input tasks. Your help was very useful.
During this time my project groves and now, I have similar (but more complicated) problem :smileysad: and I hope that again you give me a smart solution...
I'm using DAQmx NI-USB-6259. I have to read not one but three AI voltage at the same time (or with very small delay) triggered by the analog output task.

Could you help me with this problem?
It is possible to read and storage three independent voltages at the same time (or with very small delay)?

Best regards,
Andrzej

Member
Virdzs
Posts: 16
0 Kudos

Re: parallel execute writing and reading

Hi Andrzej,

 

Yes it's possible, but with your device not at the same time, just with a small delay (about 1 us).

The way is almost the same, you have to add 2 more analog input channels to your task, and use the read function for multiple samples. Just check the Acq-Int Clk VB example.

 

I can't help with particular code, because I'm not familiar with VB, but daqmx functions are very similar, so if this modification is 3 click in LabVIEW, then it must be very easy in VB too. You handle tasks, if your task contains more ai channels you will get back samples for all channels.

 

I hope this helps, or just let me know if I misunderstood something.

 

Gabor