LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ho do I encode driver constants in LabVIEW?

Hi,

 

I created a wrapper for calling a dll from LabVIEW. My driver uses a lot of constants like:

#define Baud_Rate_192001001

#define Baud_Rate_96001002  etc.

How do I include this information in my driver so when I call a VI I do not have to use "hardcoded" numbers?

Thanks

CT

 

0 Kudos
Message 1 of 8
(2,971 Views)

One approach I've seen in many NI-distributed VIs is a ring type definition.  Rings are used because the values in them do not need to be sequential; the downside is that unlike an enumeration, a the items in a list aren't part of the data type, so they don't update when new items are added to the type definition.  If the DLL header is stable and unlikely to change then this may be acceptable.

 

If you need flexibility to change the #define values, then you could create an enumerated type definition and a dedicated VI that uses that enum as an index into an array of output values.  It's very slightly more work but much easier to change if the header changes.

0 Kudos
Message 2 of 8
(2,963 Views)

But what if my constants are not 0,1,2 ...Is there a way to assign a number to a constant? It seems like there's no way to edit the "Digital Display" value.

thanks

0 Kudos
Message 3 of 8
(2,929 Views)

Sorry, I think I figured it out. It needs to be a Text Ring and and enum type.

0 Kudos
Message 4 of 8
(2,925 Views)

@Cimteker wrote:

Sorry, I think I figured it out. It needs to be a Text Ring and and enum type.


Why a text ring? Why not use Nathan's solution?

0 Kudos
Message 5 of 8
(2,919 Views)

Text ring is the only structure where I can define (BAUD_RATE_500k, 0x10) pair. Enum type would only allow me consecutive numbers. I think this is what Nathan was suggesting.

0 Kudos
Message 6 of 8
(2,906 Views)
0 Kudos
Message 7 of 8
(2,902 Views)
What about a numeric ring? I think it is more intuitive, unless I'm not understanding correctly
0 Kudos
Message 8 of 8
(2,887 Views)