07-23-2012 04:19 AM
Hi everybody,
I am new to Labwindows. I am using NI-USB-6221 device. I want to have 8 different Signal on 8 different DO at the same time but my device only writes one Signal at a time. I read something about multithreading. Do I have to use this solution or is there any other easier way to solve it?
Greeting
lee
07-23-2012 04:44 AM
If you configure the output channel to hold several lines or an entire port you can write simultanously to all off the lines with a single instruction.
Look for WriteDigPort example that comes with DAQmx and writes data to an entire port of a daq card (you'll find it in samples\daqmx\digital\generate values\write dig port folder)..
07-23-2012 06:19 AM
Hi,
I still have a question :-(. For Example I want to have sin, cos, sinc, rect, pwm,... signal and each should have its own line und sended silmutaneously. Is the example not for one signal on 8 different lines?
sorry for my stupid question.
07-23-2012 06:42 AM
Hello Lee, the example drives all lines in a port independent one to each other. Depending on the value you are passing to the board, it will drive appropriate lines on or off (one bit per line).
Which is your goal? Seems you want to drive a stepper motor or so. Depending on the problem to address there may be specific boards more suitable than others to solve it.
07-23-2012 09:51 AM
My device is sending to two signals silmultaneously but those signals aren't right. I was using DAQmxWriteDigitalLines.
And now I am using DAQmxWriteDigitalU32 and my output is just one signal again.
For Example: my data would be data=[1,0,1,0,1,0,1,0,1,0] and
data2=[1,1,1,0,1,1,1]
int CVICALLBACK as (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int lauf;
switch (event)
{
case EVENT_COMMIT:
DAQmxCreateTask ("out", &task);
DAQmxCreateDOChan (task, "Dev1/port0", "", DAQmx_Val_ChanForAllLines);
DAQmxStartTask (task);
while(loop)
{
ProcessSystemEvents();
if(loop==1)
{
DAQmxWriteDigitalU32 (task, 5, 1, 10.0, DAQmx_Val_GroupByChannel, data, &written, 0);
DAQmxWriteDigitalU32 (task, 7, 1, 10.0, DAQmx_Val_GroupByChannel, data2, &written, 0);
ProcessSystemEvents();
}
}
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
07-23-2012 09:54 AM
And how do I increase the frequence. I tried using:
DAQmxSetWriteAttribute (task, DAQmx_Write_RegenMode, DAQmx_Val_AllowRegen);
DAQmxCfgSampClkTiming (task, "/Dev1/PFI15", 1000000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 36);
But it didn't work. Rate=how many samples I want to generate in seconds. Sample per channel= How many sample per channel should be generated. Sample per channel*=how many sample per channel should be generated from the data. Is my understanding correct?
greeting
07-23-2012 02:38 PM
It seems to me that this explanation from Dan clarifies a lot of concepts.
07-26-2012 10:52 AM
Hi Lee,
You say you want to implement sin, cos, sinc, rect, pwm, etc waveforms on 8 different DO channels.
It is not possible to generate analog waveforms on DO (digital output) channels. DO channels are either logic-0 or logic-1, no intermediate voltages are possible.
Your hardware has 2 analog outputs. So you can generate 2 waveforms simultaneously. See the analog output samples of DAQmx.