LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Analog Generation/measurements

hi,

i use win2k, labwindows CVI 7.0, and MAX 3.1.1

I want to realize multiple analog géneration and measurements.
I use the CArd PXI 6713 for the generation and PXI 6031 for the measurements.

In this way, i create two daqmx task with MAX, one for the two input channels, and an other for the two output channels.
Physically, i connect AI0 on AO0 and AI1 on AO1.

When i use the fénération task with MAX, i read the good values with CVI using the reception task (check with oscilloscope)

But, i can't succeed to read when i use the generation task with CVI, my programme doesn't work, and i can't find the error.
i think my buffer is not well defined but i did not find any exemple.

Does anybody could help me? (reading my code or send me an exemple)

thanks,

Nico.
0 Kudos
Message 1 of 10
(4,640 Views)
Hi,

It is difficult to point what is wrong in your code, as I don't know how your tasks are defined in MAX (finite or continuous generation, etc.).
Could you please tell me if an error code is returned by any of the DAQmx function and if the code inside your loop is executed?
Please also provide me the DAQmx tasks, which are configured in MAX. You can export these tasks in MAX with the menu "File>>Export..." and join the file to this thread.
I will be able to reproduce this behaviour and point out what is wrong.
Thanks.

Benjamin
National Instruments France
0 Kudos
Message 2 of 10
(4,608 Views)
hi benjamin,

thanks for helping me!

the tasks are well defined in continuous generation mode in MAX.
I don't have any errors returned by the DAQmx function.

Like you want, i join the task configuration.

Hope you could help me.
Thanks.

Nico.
0 Kudos
Message 3 of 10
(4,582 Views)
 
0 Kudos
Message 4 of 10
(4,570 Views)
Hi Nico,

I have some remarks, which can explain that your code doesn't work as you expect :
1. In a generation task, you generate samples from the write buffer. So you must call the DAQmxWriteAnalogF64(...) function to fill the buffer BEFORE starting the generation with the DAQmxStartTask(...) function.
2. You should initialize the phase variable to 0 before calling the SineWave(...) function, otherwise you might not onbtain the pattern expected.
3. You use the Strip Chart control as a Graph control. In a graph you plot arrays of samples, whereas in a Strip Chart, you add points to a plot. To plot two traces in a strip chart, you must set the number of traces to two by editing the strip chart control properties from the user interface. When you trace many plots, you pass an array to the PlotStripChart(...) function where the samples are interleaved. So you must turn the Fill Mode parameters in the DAQmxWriteAnalogF64(...) function into DAQmx_Val_GroupByScanNumber. You just have to call the PlotStripChart(...) function once to plot the two plots.
If you made these modifications, I think your code will work properly.

Best regards.
Message 5 of 10
(4,549 Views)
hi benjamin,

you were right, it 's work better now!
But with the modifications that i did, i can only write/read on one channel.
The second channel defined on my task with MAX is not used.

i try to use it configurating it with the command: "NIDAQmx_NewPhysChanAICtrl(..,..,1) et NIDAQmx_NewPhysChanAOCtrl(..,..,1), but it dosn't work and i am not sure it is teh better way to do that.

i don't find any example on the website or in the NI Exemple Finder...
Do you have an idea?

Thanks a lot.

Nico
0 Kudos
Message 6 of 10
(4,534 Views)
Hi Nico,

I think it is just because you have not enought samples in the buffer. Try to generate "2*samplesToReadPerChannel" samples instead of "samplesToReadPerChannel" with the SineWave(...) function.

Best regards.
Message 7 of 10
(4,531 Views)
Hi benjamin,

thanks for helping me, once again, you were right, and once again, i have another question!
I can write on the two channel now i corrected the number of sample in the SinWave(...) function.

But, i can not write with a différent amplitude on the différent channel.
i try to use the function DAQmxSetChanAttribute(...), but it doesn't work, so i try to use two SinWave function, but this is not better.

I would leke to find a solution easy to use because i only use two channel fort the moment but i will like to use more than 10 channel in a few time.

do you have another good idea for this problem?

Thank you a lot for your help.

Nico.
0 Kudos
Message 8 of 10
(4,511 Views)
Hi Nico,

You can call the SineWave function for each channel. It would enable you to specify a different amplitude for each channel. All you have to do is to pass the pointer to the buffer with an offset in the SineWave(...) function. You just have to pass "data+i*samplesToReadPerChannel" (where i is the channel number) instead of "data". In this case, you can generate only "samplesToReadPerChannel" points for each call to the function.

Best regards.
0 Kudos
Message 9 of 10
(4,502 Views)
Hi benjamin,


first, i want to thank you for your help, because my application woks fine now


but, i try to add another channel on my application, so i apply the same method.
and it works nearly fine, i have just a little problem with the repartion of the several point on the graph, and i don't know if the problem is on the writing, the reading or in the plot.

all is good but when i plot the tree graph with tree colors (one per graph), i saw à mixture of color.
do you have an idea?
i join my last code.


thanks again.

Nico.
0 Kudos
Message 10 of 10
(4,472 Views)