Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple analog outputs simultaneously using PCI 6723

Hello,

 

I am using PCI 6723 for generation of Analog Outputs using VB.NET 2003. I am not able to generate multiple analog outputs simultaneously. I tried to modify code as provided in example (..\NI-DAQ\Examples\DotNET1.1\Analog Out\Generate Voltage, ContGenVoltageWfm_IntClk). I changed the AnalogSingleChannelWriter to AnalogMultiChannelWriter and instead of one dimensional array I supply two dimensional array. I got the output but the channel aO and a1 doesnot show up at same time (time difference, not simultaneously). Is this a right way of generating output?

 

I am also looking for example code that is compatible with VB.NET 2003 regarding multiple analog outputs.

 

Any programming manual regarding VB.NET (command and their operations) would be helpful.

 

With regards,

Bryan

0 Kudos
Message 1 of 6
(4,093 Views)
Hello Bryan,

I made the following changes to the ContGenVoltageWfm_IntClk example and I was able to successfully update multiple channels:

            ' Write the data to the buffer
            Dim d(1, 5) As Double
            d(0, 0) = 1
            d(0, 1) = 1
            d(0, 2) = 1
            d(0, 3) = 1
            d(0, 4) = 1
            d(0, 5) = 1

            Dim writer As New AnalogMultiChannelWriter(myTask.Stream)
            writer.WriteMultiSample(False, d)

When I change the "Physical Channels" to "Dev1/ao0:1" I am able to output a constant 1V on my ao0 and a constant 0V on my ao1. However, I am a little confused by your comments about the behavior of your channels. What do you mean when you say: "I got the output but the channel aO and a1 doesnot show up at same time (time difference, not simultaneously)."? Are you saying that your channels do not update with the values of your array? Are you sure that you have indexed your array correctly to update as you expect?

Finally, in regards to your questions about examples that are compatible with VB .NET 2003, the NI-DAQmx 8.5 driver Readme says the following:

"The .NET example paths for Windows XP and Windows 2000 are x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1 and x:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0."


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 2 of 6
(4,066 Views)

Hello Matt,

Thank you for your response.

I am not able to generate analog outputs signals simultaneously for different channels with different data.

If,         array(0,i) = 100 random numbers

array (1,I )= 100 random numbers

array(2,i)= 100 random numbers

  Dim writer As New AnalogMultiChannelWriter(myTask.Stream)
    writer.WriteMultiSample(False, array)

It will output 100 random numbers for all 3 channels; but I am not able to update oputput with different data. Do we need to repeat same process  ( from the beginning )each time to update output ?

What do you mean when you say: "I got the output but the channel aO and a1 doesnot show up at same time (time difference, not simultaneously)."?

            Well, when I created 2 channels,  the output point of first channel doesnot appear at same time with second channel. for example,

                        array (0, 1)=-2

                        array(1,1) =2 

then, isnt it the  channel 0 output (-2) and channel1 (2) output should apper at the same time?

With regards,

Bryan

0 Kudos
Message 3 of 6
(4,055 Views)
Hello Bryan,

You do not need to repeat the entire configuration of your NI-DAQmx task to update the output. You can just call the WriteMultiSample function again to update the output waveform. Is there a reason you cannot just append the new data to the end of the output array? As a note, you will need to place the second call to WriteMultiSample after the task has been started by the myTask.Start() function call. The first WriteMultiSample will place the first array into a buffer to be written out once the task has started. The second WriteMultiSample will write data to this buffer during execution. An example of this operation might look like this:

            writer.WriteMultiSample(False, d)

            'Start writing out data
            myTask.Start()
            writer.WriteMultiSample(False, d2)

In this code d is the first array to be written out and is loaded into the output buffer. After myTask.Start() the d2 array is written to the buffer to be generated continuously as the task runs.

I'm afraid I'm still a little unclear on your second question. Based on your posts, I assume that you are able to detect some sort of delay between the update on the first channel and the update on the second channel. How are you determining that there is a delay? Are you able to measure this delay? Do you know about how long it is? Could you post an image that shows the delay? To answer your specific question: yes, these updates should appear at the same time.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 4 of 6
(4,044 Views)

Hello Matt,

Thanks for your valuable response.

One last question,  instead of contineous samples I want to have fintie samples.

I changed my configureSampleClock as shown below.

myTask.Timing.ConfigureSampleClock("", 5000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 5000)

I want to clear all the previous samples (clear buffer)  while writing new samples onto it simeltaneously.  I tried different ways but

getting same error code: -200288 ( Property : NationalInstruements.DAQmx.Daqstream.WriteRelativeTo Corresponding Value: NationalInstruemnts.DaQmx.WriteRelativeTo.CurrentWritePosition .

Property :NI.DAQmx.DAQsteam.writeOffset Corresponding value.

How can we point the write position (buffer location)?  Any Vb.Net 2003 example will be too helpful.

About delay, it was my mistake, sorry for that.

 

With regards,

Bryan

0 Kudos
Message 5 of 6
(4,039 Views)
Hello Bryan,

There is a document here which discusses a common reason for the error you described. I believe the problem is that you are not stopping the task (as stated in the document). If you want to perform multiple finite generations you will need to stop the task and restart it for every generation. Finite generation outputs the number of samples you have specified and no more; if you wan to output more samples you will need to increase the number of finite samples or create a new task.

However, I'm not sure that you actually need to perform a finite generation. You should be able to perform a continuous generation and specify a new array any time you want to change the waveform (as described in my previous post). I suggest that you look at continuous generation based on your statement that:



@bryan81 wrote:

...

I want to clear all the previous samples (clear buffer)  while writing new samples onto it simeltaneously.

...




To clarify, the buffer is circular, so data is automatically "cleared" when it is written out. As you write new data into the buffer, it fills and then rolls over back to the start when it reaches the end. The driver keeps track of where the data is being written in the buffer and what data has been generated, so that you never have to manually clear the buffer. So long as you are not attempting to write data to the buffer faster than your device can generate the waveform, you should not have any problems. I hope this is clear, but let me know if you have any additional questions.


Matt Anderson

Hardware Services Marketing Manager
National Instruments
0 Kudos
Message 6 of 6
(4,033 Views)