LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Different Signal on different DO? using USB-6221

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

0 Kudos
Message 1 of 8
(3,544 Views)

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)..



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(3,543 Views)

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.

 

 

0 Kudos
Message 3 of 8
(3,537 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 8
(3,531 Views)

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;
}

0 Kudos
Message 5 of 8
(3,525 Views)

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

0 Kudos
Message 6 of 8
(3,524 Views)

It seems to me that this explanation from Dan clarifies a lot of concepts.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 8
(3,520 Views)

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.

S. Eren BALCI
IMESTEK
0 Kudos
Message 8 of 8
(3,486 Views)