Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How Do You Porperly Use DAQmx Flatten Channel String.vi?

I still don't understand what problem you are attempting to solve. Why do you do all of that typecasting? Leaving everything as in your very first post works just fine. The coercion dots are not a problem. The function seems to work exactly the same whether there is a string array or physical channel array. Please post details on problems you see with a physical channel array.

0 Kudos
Message 11 of 16
(1,448 Views)

Implicit typecasting is bad programming.  It's surprising this is the only supported way of doing this task.

0 Kudos
Message 12 of 16
(1,445 Views)

Why do you think it is bad programming? Read this.

0 Kudos
Message 13 of 16
(1,443 Views)

WRT the thread, the advise that you change your diagram or rewrite sub-VIs isn't possible when dealing with built-in library VIs.  I suppose I could write my own "DAQmx Flatten Channel String With Correct Data Types.vi" but that's a lot of work doubling for minimal gain.  NI shouldn't be throwing implicit typecasts around.  In real programming, this is greatly looked down upon and tends to get your code dismissed in review.

 

Altenbach may be right about the performance hit, but probably isn't- conversion of datatypes is either done bitwise (you can do this for adding 16bit and 32bit integers, say) for no penalty or on a compiler or runtime-level conversion.  Back to the thread, the conversion from int to double isn't "safe" (you can't represent integers exactly in floating point) and it isn't done without a buffer (0X28+0101 may be the binary for '5' in a 32bit integer, but that is not how '5' is represented in 64bit floating point).  If there is a savings in performance, it's because LabVIEW is doing something automatically that's more efficient than a polymorphic typecast function, not because implicit typecasting is faster than explicitely typecasting.

 

Even if there is a performance hit, it's impact will be pretty minimal.  You only call an instrument start function once per run, it's the part about reading/writing to instruments in the control loop you try to squeeze performance out of.

0 Kudos
Message 14 of 16
(1,440 Views)

The actual unflattening is done by a DLL. The input to the DLL is a string. I suspect the DLL is just being reused in LabVIEW and that a string for channel names is what is supported in all of the languages that DAQmx support. By using an array of physical channel names, you gain a little bit of convenience by having the ability to browse for channels. Using the typecast does not gain anything as far as I can see except adding complexity to a problem that does not exist.

0 Kudos
Message 15 of 16
(1,438 Views)

You're right, insasmuch as it isn't a show stopper- you can still feed a channel array in and get the program to function like it's supposed to.  I also realize that LabVIEW isn't really programming, but it apes the C conventions pretty closely.  It should also follow good programmign practices, one of which is don't rely on implicit typecasting, or even explicit, for that matter.

0 Kudos
Message 16 of 16
(1,424 Views)