LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric values longer than 32bit?

Greetings,

I'm an EE student currently working as a LV instrument driver developer
for a well-known T&M equipment manufacturer here in Munich.

My problem is the following: Is it possible to handle numeric values
longer than 32bit in LV? Specifically, one of my instrument driver VIs
needs to supply an initialization value to the Wideband CDMA "long code"
configuration menu of a versatile vector signal generator. This value
can range from 0x0 to 0x1FF,FFFF,FFFF (which accounts for 41 bits, if
I'm not mistaken). The instrument expects this value in hexadecimal
form.

A quick and dirty solution could be either to split up the control range
in 32+9 bits, i.e. place two controls on the front panel, or to use a
string control an
d have the user specify the hex value as a string. Both
solutions are not very desirable though, especially since instrument
driver VIs are meant to be used as sub-VIs in customer-specific programs
and for that reason aren't usually accessed from their front panels.

So, are there any other, more elegant solutions than the ones mentioned
above?

Thanks a lot in advance!
--
(c) Tobias Hermann
0 Kudos
Message 1 of 10
(7,165 Views)
I'm really not sure how to do this (a C program maybe?). But the quick and
dirty solution should work without the need for another front panel, and
without the user ever having to deal with hex.

Of course, you'll have a string on the front panel. But you just convert it
using "From Deciamal" and the right to "To Hex"

With a 41-bit number, chances are the user would type in the number,
correct? In that way, a string control is no different that a numeric.

Now, if you want up/down arrows, that's still possible with some extra
programming (make the arrows booleans and then convert string to number, add
1, convert back to string).

Well, not an elegant solution, but it should work.


Rick
--

rick@csciences.com

Chesapeake Sciences Corp.
1127B Benfield Blvd Mill
ersville, MD 21108

Tel: (410) 923-1300 x3430 Fax: (410) 923-2669
0 Kudos
Message 2 of 10
(7,165 Views)
Greetings from Munich again!

Rick Nelson schrieb:
>
> I'm really not sure how to do this (a C program maybe?). But the quick and
> dirty solution should work without the need for another front panel, and
> without the user ever having to deal with hex.

Well, 0x1FFFFFFFFFF would be quite an impressive number written as a
decimal, wouldn't it? 🙂
BTW, the instrument's configuration menu confronts the user wanting to
change this value with the whole 41 bit _binary_ and lets him toggle
each bit between 0 and 1... so I wouldn't worry too much about hex
numbers...

> With a 41-bit number, chances are the user would type in the number,
> correct? In that way, a string control is no different that a
> numeric.

It's up to the user of the instrument driver how he wants to specify
that value. Usually, I suppose, either a constant is wired to the driver
VI's corresponding input terminal, or the programmer just pops up on
that terminal and selects "Create Control" if he wants to place a
control on his application VI's front panel.
In both cases, yes, the number would be typed in at some point, and
that's why I considered a string control as an alternative. But I feel
that the user might want to feed a value to that terminal he somehow
*calculated* before in his application program, though this is rather
unlikely.
FWIW, the default setting for that initialization value is just 0x1, and
I suspect that in at least 95% of all cases the instrument will work as
desired without ever changing that number.

> Now, if you want up/down arrows, that's still possible with some extra
> programming (make the arrows booleans and then convert string to number, add
> 1, convert back to string).

This shouldn't even be necessary - I'm sure no-one would want to click
all the way through 41 bits! 🙂 It's just that I didn't want to split
up a control which is *one* menu item on the instrument into *two* LV
controls - and possibly avoid string controls for non-string items for
the sake of consistency.

FYI, the instrument in question is described here:
http://www.rsd.de/www/dev_center.nsf/html/1117113frame

Thanks for the input so far!
--
(c) Tobias Hermann
0 Kudos
Message 3 of 10
(7,165 Views)
> This shouldn't even be necessary - I'm sure no-one would want to click
> all the way through 41 bits! 🙂 It's just that I didn't want to split
> up a control which is *one* menu item on the instrument into *two* LV
> controls - and possibly avoid string controls for non-string items for
> the sake of consistency.
>

Another option is to make a cluster of two or three integers. One
I16 and one I32 may be a good choice, or perhaps three I16s. This
can be the input to the subVI where the numbers are turned into Hex
and zero padded to the right number of digits. This sort of clustering
will keep things to one cluster, especially when making a constant.

Greg McKaskle
0 Kudos
Message 4 of 10
(7,165 Views)
Tobias Hermann wrote:
>
> Greetings,
>
> I'm an EE student currently working as a LV instrument driver developer
> for a well-known T&M equipment manufacturer here in Munich.
>
> My problem is the following: Is it possible to handle numeric values
> longer than 32bit in LV? Specifically, one of my instrument driver VIs
> needs to supply an initialization value to the Wideband CDMA "long code"
> configuration menu of a versatile vector signal generator. This value
> can range from 0x0 to 0x1FF,FFFF,FFFF (which accounts for 41 bits, if
> I'm not mistaken). The instrument expects this value in hexadecimal
> form.
Hi,
may I make first something clear : THERE AINT SUCH A THING : hex number!!

Hexadecimal is a notation of a (integer) number using base 16. You
could, and
this is very common, represent the SAME number by decimal notation.

In any current computer's memory everything you type in (as a STRING) is
represented in binary format (base 2).

So,
-either your controller wants the information as a hexadecimal string
(ASCII text) : no problem, use a string control.
-or it needs it really as a 41 bit NUMBER (which you can NOTE in
binary,octal,decimal or any other string) : that is difficult as there
are rarely integer types (in any programming language I know) of more
than 32 bits. definition.

I really think, you are supposed to send a hex string. Which, as I said
is easy.
Am I right?
--
P. Meyer
Universite de Paris Sud
Physique des Solides, bt. 510
e-mail : meyer@lps.u-psud.fr
T : (33) (0)1 69 15 60 62
Fx: (33) (0)1 69 15 60 68
0 Kudos
Message 5 of 10
(7,165 Views)
Hi there!

meyer schrieb:
> Hi,
> may I make first something clear : THERE AINT SUCH A THING : hex number!!
>
> Hexadecimal is a notation of a (integer) number using base 16. You
> could, and this is very common, represent the SAME number by decimal notation.

Of course you're right - that's why I was talking about numeric _values_
and hex/decimal/binary _form_ in my original message. Different way of
saying the same thing. But perhaps, my formulation became somewhat
unprecise at a later point...

> In any current computer's memory everything you type in (as a STRING) is
> represented in binary format (base 2).

Yes, I agree.

> So,
> -either your controller wants the information as a hexadecimal string
> (ASCII text) : no problem, use a string control.

>

> I really think, you are supposed to send a hex string. Which, as I said
> is easy.
> Am I right?

Being GPIB-controlled, the instrument indeed expects a hex ASCII string.
In fact, a VISA instrument driver does basically nothing else than build
up appropriate control strings from the user's inputs, using functions
like Format Into String (and lots of Case Structures, usually) and
writing them to a specified VISA session. But my original question
concerned the _input_ side of the VI. I wanted to avoid using a string
control for a numeric value, so that the user can wire a source of
numeric data to the corresponding VI input without having to convert it
to a string first. That's exactly the task of the VISA instrument
driver: make the instrument (connected via GPIB or RS-232) look like a
simple "data sink/source" in LV without the user having to worry about
SCPI control string syntax or instrument-specific things, like the
correct order of the commands to be issued etc.

Hopefully, I co
uld clear things up a bit...

Thanks again!
--
(c) Tobias Hermann
0 Kudos
Message 6 of 10
(7,165 Views)
Dear Tobias Hermann

Sorry I did not get you right the first time around.
Generally, when numericians (I mean people doing calculations concerning
nubers, big ones normally, need more or even unlimited numerical range
on integers, they often use strings. So this was what I was offering as
a practical solution.
Anyway, a numerical control, when you look at the underlying workings,
is nothing but a specialized "string input" followed by a string-number
conversion using the current base. This is for direct interaction.
On how they managed at NI the WIRING of numerical input, I can only
speculate. Probably they include another conversion when you declare a
connector for the sub VI.
As there is no numerical type bigger than 32 bits in LV, I see no simple
solution.

--
P. Meyer
Universite de Paris Sud
Physique des Solides, bt. 510
e-mail : meyer@lps.u-psud.fr
T : (33) (0)1 69 15 60 62
Fx: (33) (0)1 69 15 60 68
0 Kudos
Message 8 of 10
(7,165 Views)
Since you will ultimately send a string then you have many options.
The way I ready this is a question about the presenation of the controls
that will add up to a hex value. The question is what do the values depict.
If they can be split into some functional groups then I would have controls
that
make sense for each group.
Ie If one of the hex values sets up 1 of 16 functions then I might have a
ring control that lists each function. If each bit is an on/off for some
setting
I might consider and array or cluster of booleans. I always try to think of
what
the data means and use an appropriate control.
Kevin

Tobias Hermann wrote:

>
> A quick and dirty solution could be either to split up the control range
> in 32+9 bits, i.e. So, are there any other, more elegant s
olutions than
> the ones mentioned
> above?
>
0 Kudos
Message 7 of 10
(7,165 Views)
In <378C9C5F.646A0E63@eikon.tum.de> Tobias Hermann writes:
>My problem is the following: Is it possible to handle numeric values
>longer than 32bit in LV? Specifically, one of my instrument driver VIs
>needs to supply an initialization value to the Wideband CDMA "long code"
>configuration menu of a versatile vector signal generator. This value
>can range from 0x0 to 0x1FF,FFFF,FFFF (which accounts for 41 bits, if
>I'm not mistaken). The instrument expects this value in hexadecimal
>form.

FORMING THE 41-bit STORAGE

You can create any arbitray numerical data length by using a binary
array. This is the best and most direct solution to your needs.
Just remember, LabView allocates binary arrays in multiples of bytes,
so a 41-bit array will be rounded up to a length of 6 bytes or
48-bits; however, LabView knows to return only the first 41-bits to
you upon request.

GENERATING AN ARRAY OF 41-bit VALUES

The next issue is that you need an array of 41-bit numbers. You simply
define this as a 2-dimensional array of binary values. When
initializing this array, be certain you order the dimension indices
such that the fastest moving index has a size value of 41. The slowest
moving index will then be for the actual numerical size of your array.
If you transpose the index definition, nothing will work right! Be
careful!

When your array (above) is defined, it should be shown in LabView as a
brown wire, which deplicts it as a binary 2-dimensional array. If it
is instead shown in a magenta color, then you instead defined and array
(cluster) of 41-bit binary numbers. That will work okay too (and will
even be easier the used), but it will take more storage and will take
LabView longer to handle. However, if you're more confortable will the
latter choice, I can understand that. It does have the feature of being
able to address each 41-bits number directly. With the 2-dim approach
I initially outlined, you'll need to slice out each 41-bit number from
the 2-dim array each time you access (read/write) it.

FORMATTING BINARY INTO HEX

Formatting your storged numbers is an entirely _separate_ issue and
your 41-bits numbers only need to worry about formatting when you
send them to an output device. For a LabView control panel, simply
open a binary array control, then select the appropriate options so
they are displayed in base-2, octal, or hex. LabView supports all
three display formats with any binary indicator.

If you need to format your numbers to a hex string (for an output
device), try the "To Hexadecimal" or "Format & Append" function.
Again, if you're using the 2-dim binary array apprach, you'll need to
slice out each 41-bit number indivdually. If you're using the cluster
(array) if 1-dim 41-bit array approach, you can skip that step.
Frankly, I'm not sure how well LabView's formatting functions work with
1-dim binary arrays, but in principal they should. If they don't work
directly, no big deal. Just cast the 41-bit arrays into U8 numbers
(bytes) and have the formatting function format those numbers into hex
strings; simply one more step.

One question: Why on earth do you want to format the data going
into your instrument in the first place? Almost all instruments will
take binary input _directly_ without formatting it into ASCII (octal,
hex, etc) first. This is much faster because the ASCII of all this
hex stuff requires many more bytes to transfer to your instrument.
Moreover, the instrument then needs to convert the ASCII (hex) back
into binary before it can use any of it. You should investigate
skipping the formatting step altogether. The exception might be
if you're using an RS-232 connection to your instrument where raw
binary isn't allowed. Newer interfaces like GPIB, 1394, etc will
allow binary transfer directly.

COMMENTS ON STRINGS

Don't use strings in LabView. By default, each string get a minimal
memory allocation of 2K. If you define a 100 element (array) string,
that's 200K of memory just to hold those strings. Not a big deal, but
when the memory manager starts doing garbage collection (which is
required with string manipulations), things will really slow down.

String are important, but data should always be stored in a binary
form within any computer, not in ASCII formatted form (hex included).
--
/\ Mark M Mehl, alias Superticker (Supertickler to some)
<><> Internet: mehl@IAstate.edu
\/ Preferred UUCP: uunet!iastate.edu!mehl
Disclaimer: You got to be kidding; who would want to claim anything I said?
0 Kudos
Message 9 of 10
(7,165 Views)
....
>
> COMMENTS ON STRINGS
>
> Don't use strings in LabView. By default, each string get a minimal
> memory allocation of 2K. If you define a 100 element (array) string,
> that's 200K of memory just to hold those strings. Not a big deal, but
> when the memory manager starts doing garbage collection (which is
> required with string manipulations), things will really slow down.
>
> String are important, but data should always be stored in a binary
> form within any computer, not in ASCII formatted form (hex included).

I'm not sure where this information comes from, but strings do not have
a minimum memory allocation of 2Kbytes. To my calculations, the smallest
string fits into 40 bytes -- four bytes in the dataspace where the handle
is written, four byt
es for the master pointer, some predata pointer over-
head ~ 16 bytes, a four bytes string size field, and some internal frag-
mentation. Thus, strings from zero to twelve characters all fit within
the 40 bytes. Over forty characters and they go into a different
allocation pool with different rules for internal fragmentation.

Note that the allocation of small blocks from the system happens in
bigger
chunks and a suballocator doles the memory out as needed. In particular,
any string greater than or equal to 16K will come straight from the system,
but smaller than 16K and they are suballocated from the occasional 64K
system allocation.

One more note, all of these constants for the overhead size and the size
where the various allocators kick in are subject to tweaking as they are
sort of tuning parameters. They are the numbers that have been used since
LV4 up to and including LV5.1.

Greg McKaskle
0 Kudos
Message 10 of 10
(7,165 Views)