02-18-2014 04:06 AM
Hello all!
I'm new for C# and also for measurement studio. Now I have a task to implement the current (frequency signal) generation with 2 channels.
I found this example in my computer C:\Documents and Settings\All Users\Documenti\National Instruments\NI-DAQ\Examples\DotNET4.5\Analog Out\Generate Current (my OS is Win XP), which allows me generate frequency signal for only one channel.
I tried to copy all the components of the first channel and added corresponding classes in mainform.cs, which obviously doesn't work. When I run the program an error message saying "the resource is preseverd for another task" shows out.
I'd like to know if it's possible to add another channel under the task, or add another task to implement my goal, and how.
Thanks in advance!
Chao
02-18-2014 04:44 AM
Hi jc,
I cant really see what you tried but ofcause you cant put two outputs to the same channel!
First of all try to assign another channel to the second task you created. So the output is redirected to another pin.
For further help please post your code.
greetings,
Kevin
02-18-2014 09:09 AM
Hey Kevin,
Actually I was not putting 2 outputs into the same channel but creating 2 tasks with one channel per each.
My Mainform code is in attachment. Thank you.!
Chao
02-18-2014 09:11 AM
Sorry the attachment is here
02-19-2014 02:23 AM
Hi Jc,
At a first look I cant see any problem. But I cant test your program because I dont have a device with AOs present. Please make sure you dont use any outpot channel, smaple timing or other resource more than once.
Sorry I cant help you any further.
02-19-2014 02:33 AM
OK fine no problem. Anyway thanks for the suggestion!
Regards!
02-19-2014 02:55 AM
02-19-2014 04:19 AM
Hi Licia,
Sorry but do you mean what I shall do is like this?
With one single physical channel combo box and 2 signal frequency test box like this?
But when running it shows that the number of channels I use doesn't match the channels the task contains.
I made this query 2 weeks ago and your colleague Massimiliano is responsible for this, but he's not capably to handle the C# thing.
So some suggestions? thanks.
Chao
02-19-2014 10:05 AM
Hi Chao,
you have to modify the example (which is using AnalogSingleChannelWriter class) in order to call AnalogMultiChannelWriter Class.
This way, you can generate data from multiple channels, setting their names in physical channels input.
I hope this helps!
Bye,
Licia
02-20-2014 02:45 AM
Hi Licia!
Thank you very much for the hint. I think that would help, but I got syntax error when I changed AnalogSingleChannelWriter into
AnalogMultiChannelWriter, as following:
From the source code of AnalogMultiChannelWriter there are brackets after AnalogWaveform<double>, however here it's not correct. Any idea?
Thanks and regards!
Chao