From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Pattern Generation with USB-6341?

Solved!
Go to solution

Hi all,

We developed a quasi "device-independent" multifunction daq software. This sw is able to generate timed pattern-sequence with the actually used device. Until now we used PCI-6025 and USB-6221 devices but now we purchased a USB-6341 and when I try to use it a -200565 error message pops up: "Specified digital channel contains more bits than supported by the 8-bit version of DAQmxBase Port Write. Use the version of DAQmxBase Port Write that supports wider digital ports. Minimum Write Size in bits: 32"

I tried to change PORT0 to PORT1 and PORT2 but only PORT0 is legal for pattern-generation procedure and this one requires DAQmxWriteDigitalU32 function...
I don't understand why.

a/ 6341 contains 24 DIO lines
b/ only 8 DIO lines are hardware-timed

So there is 24 DIO lines (i.e. 24 bits not 32!) but only 8 lines are hardware-timed and I want to use only this 8 lines for pattern-generation!
Our whole software is based on 8-bit pattern-arrays (type of writeArray is "uInt8"). If we can't use this structure we must rewrite dozens of functions...

So how can we use DAQmxWriteDigitalU8 function with USB-6341 or what can we do?


Thanks,

 - George Cs. -

0 Kudos
Message 1 of 8
(6,889 Views)

Dear George,

I tried to reproduce the problem you had and it seems that the DAQmxWriteDigitalU8 function only supports writing on one port. The following code ran without any error for me.

Be sure that the Create Channel VI is configured properly and the lines terminal only contains lines of the same port.

I hope this helps you.

If the problem persists it could be helpful if you attached some small piece of the code with which you experiene the problem.

Best Regards,

 

0 Kudos
Message 2 of 8
(6,874 Views)

Dear Adam Cseh,

Thank you for your answer. I viewed your sample and, though I'm using daqmx API only, I don't see where is the trick..

Originally I tried the following:

* * *
DAQmxCreateTask('TaskPT', @TaskPT);
DAQmxCreateDOChan(TaskPT, 'USB-6341/port0', '', DAQmx_Val_ChanForAllLines);
DAQmxCfgSampClkTiming(TaskPT, '', 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 2); // 1 kHz, 2 loops
DAQmxRegisterDoneEvent(TaskPT, 0, LongWord(@PatternDone), nil); // PatterDone is the callback proc.
DAQmxSetWriteRegenMode(TaskPT, DAQmx_Val_AllowRegen);
DAQmxWriteDigitalU8(TaskPT, PatternLen, 0, 1, DAQmx_Val_GroupByScanNumber, @PatternBuf[0], @samp_written, nil);
DAQmxStartTask(TaskPT);
* * *

As I saw your sample I modified the DAQmxCreateDOChan function.

First I tried:

 DAQmxCreateDOChan(TaskPT, 'USB-6341/port0/line0:7', '', DAQmx_Val_ChanForAllLines);

and then:

 DAQmxCreateDOChan(TaskPT, 'USB-6341/line0:7', '', DAQmx_Val_ChanForAllLines);

and finally:

 DAQmxCreateDOChan(TaskPT, 'USB-6341/port0/line0', '', DAQmx_Val_ChanForAllLines);


but, at the call of DAQmxWriteDigitalU8 function, the well-known error message appears again and again..

"Specified digital channel contains more bits than supported by the 8-bit version of DAQmxBase Port Write."

More bits? I'm specifying "line0"! What "more bits"?

 

I still don't understand..

Any idea?


Thanks,

 - George Cs. -

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

Dear George,

I found a similar problem to yours:

http://forums.ni.com/t5/Multifunction-DAQ/NI-DAQmx-9-2-to-9-6-upgrade-VI-gives-200565-error-now/m-p/...

 

As you can see, the API was designed so that the full internal port width of the device (32 bits) has to be written and therefore the corresponding DAQmxWriteDigitalU32 function has to be used. If you pass an 8-bit number to it, it will be internally casted to 32 bits. Please ignore the attached code above, because it also mistakenly uses the DAQmxWriteDigitalU8 vi.

 

Best Regards,

 

 

 

0 Kudos
Message 4 of 8
(6,836 Views)

>If you pass an 8-bit number to it, it will be internally casted to 32 bits.

Unfortunately it happens not internally. This is the problem. We must convert the bytes (uInt8) to uInt32.. And I think this is not a good concept in the API.
Therefore we can not keep the software compatibility, moreover we must rewrite all pattern-generation functions and data structure 😕
And this is bad news. Very very bad news..


Greets

- George Cs. -

0 Kudos
Message 5 of 8
(6,833 Views)

Dear Adam Cseh,

 


One thing I still don't understand. If you read this please answer me..

 

There is 3 available port in USB-6341 namely: port0, port1, port2 - it's ok since the device has 24 DIO.
port0 is able to generate buffered output - it's ok since the specification says that 8 DIO lines are hardware-timed. This is on port0.
So if I want to use port0 it means I use the 8 hardware-timed DIO lines. (If I select port0 it means I want to use "line0:7".)
So I don't understand why must I send 32-bit data for a 8-bit port??
This is absolute illogical and incomprehensible for me.
What is the explanation for this?


Thanks,

- George Cs. -

0 Kudos
Message 6 of 8
(6,804 Views)
Solution
Accepted by topic author George_Cs

Dear George,

this is an interesting question, which might seem a little unintuitive at first. The main reason for the 32-bit write operation (although the USB-6341 only has 24 DIOs) is that the functions and the driver support other devices too. As you can see in the manual of the device (http://www.ni.com/pdf/manuals/370784d.pdf) the X series DAQs support digital IOs up to 32 bidirectional signals. 

In order to keep things consistent the 32-bit operation is required even if you only use a subset of the available ports.

I hope this helps to explain.

Best Regards

0 Kudos
Message 7 of 8
(6,797 Views)

Now I see. Thanks for the answer.

 

Best regards,

 

- George Cs. -

0 Kudos
Message 8 of 8
(6,789 Views)