LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Threshold and interpolate array in LabVIEW FPGA

Hi,

It's a classical one, but I don't find an answer that fit my problem :

I want to threshold an array with a 4-20 mA analog input then interpolate an other array with the result of the threshold.

The result of the interpolation is then sent to an 4-20 mA analog output.

Very simple ! Just like that :

InterpolateArray.gif

But I want to do that in LabVIEW FPGA on a cRIO 9074....and these functions don't exist in LabVIEW FPGA.

I failed to use LUT, so I need some help...

The 4-20 mA modules give/need a single-precision floating point format.

Thanks,

 

0 Kudos
Message 1 of 6
(3,542 Views)

Can you be more specific about how you failed to use a lookup table? What is the precision (how many bits) of the input and the output? If it's not too large, you might consider using a memory block as a lookup table. Cast the fixed-point value to an integer representation and use it as the memory address (assuming positive numbers only; if it can also be negative then it's a bit more work).

 

If a lookup table, possibly in RAM, isn't an option, then you can code the interpolation yourself, but that's more work.

0 Kudos
Message 2 of 6
(3,520 Views)

Hi,

 

Thank your for reply,

The precision of I/O I need is 0,1 mA in single precision format.

I want to threshold then interpolate because the relation beetween the input and the output is quite chaotic, not resolvable.

I don't understand "Cast the fixed-point value to an integer representation"

Do you mean multiply the single precision input by 10 to have an integer ?

Is the memory address has to start from 0 ?

Is the step beetween each address has to be 1 ?

A LUT allows to interpolate but how to threshold ?

"If a lookup table, possibly in RAM, isn't an option" --> well, how to know if it is or not an option ?

 

Imagine that :

X is 6.4 mA

X array is 4.0 ; 4.1 ; 4.2   ......... 19.9 ; 20 mA

Y array is 7.5 ; 4.8 ; 14.8 ; 4.3 ; 4.9 ; 20.0 ; 11.8..... any chaotic value

Y is the 4-20 mA analog output.

Can you post an example solving my problem, with the best solution : LUT and/or memory block ?

 

Thanks,

0 Kudos
Message 3 of 6
(3,508 Views)

Which analog input and output units are you using? How precise (how many bits) are the inputs and outputs? Let's say you have a 16-bit input and output. That means there are 65536 total possible inputs, and the same number of outputs. There's a direct mapping of inputs to outputs. So, your lookup table needs to contain 65536 *2 elements, each of which is 2 bytes (16 bits), for a total of 262144 bytes or 256kb. The FPGA in the 9074 has 720kb of RAM, so more than enough space to store this lookup table. If either the input or output is lower precision, for example 12 bits, then it requires even less space.

 

You wrote "I failed to use LUT" - in what way did you fail? Have you looked at the help for the Look-Up Table 1D Express VI? How about this white paper?

 

By "cast the fixed-point value to an integer representation" I meant that if you are using fixed-point (not floating-point) on the FPGA, there is a fixed-point to integer cast function which simply tells LabVIEW to treat the same sequence of bits as an integer instead of fixed point. You may be able to set the analog input and output to use fixed-point (or raw integers) instead of floating point, which will be more efficient on the FPGA. If your only choice for the input and output is single-precision, use the numeric conversion functions to convert to fixed-point. The effect of making this cast is a bit like multiplying by 10 in that it shifts the decimal place to the right, but it's a free operation (requires no FPGA logic) unlike a multiply. To understand this further, read about fixed-point math.

0 Kudos
Message 4 of 6
(3,495 Views)

I don't understand "Which analog input and output units are you using?"

The inputs and outputs of my 4-20 mA cRIO modules are delivered by I/O property node in single-precision floating point, not in fixed point, not in integer.

The modules are :

9265 16 bit

9203 16 bit

 

"There is a fixed-point to integer cast function which simply tells LabVIEW to treat the same sequence of bits as an integer instead of fixed point."

Do you mean the "to U32" function in the conversion palette or anything else ?

If a cast my SGL to a FXP, then my FXP to a U32, just by using the conversion palette, is it ok ?

 

"may be able to set the analog input and output to use fixed-point (or raw integers) instead of floating point, which will be more efficient on the FPGA"

OK, but how can I set the analog input and output to use fixed-point (or raw integers) instead of floating point ?

 

What about the threshold ?

What about the addresses ?

 

Can you post an example solving my problem, with the best solution : LUT and/or memory block ?

 

Thanks

0 Kudos
Message 5 of 6
(3,486 Views)

I have already told you the solution: use the lookup table Express VI (which is implemented as a memory block). Why does this not work for you?

 

The lookup table express VI includes interpolation. There is no need for thresholding. In fact, in your original example, there is also no need for thresholding. You can combine the two arrays into an array of 2-element clusters, which makes it effectively a lookup table, and wire that to the interpolate function alone.

 

If you have enough RAM available on the FPGA, you can also avoid interpolation by creating a lookup table large enough to hold every possible input value (and corresponding output). Since you are dealing with a 16-bit input, there are only 65536 possible values. I realized I provided the wrong numbers in my earlier post (I was off by a factor of 2). The address is the input and the table contains the corresponding outputs, so your lookup table will consume only 65536 * 2 = 131072 bytes or 128kb of RAM (each output value is 16 bits or 2 bytes).

 

I don't have the LabVIEW 2013 FPGA module available right now, and I can't find any documentation suggesting that the inputs and outputs are single-precision floating point values. Everything I see says that they are fixed-point values. Are you sure that the inputs and outputs are floating point? Can you provide a screenshot? In any case, regardless of the numeric format, you are limited by the 16-bit precision of the inputs and outputs, so you'll never have more than those 65536 possible values. If you do have to do the conversion, you can use the To Fixed Point and Fixed Point to Integer Cast functions (and the equivalents in the reverse direction). That will give you an integer with the same bit pattern as the fixed-point equivalent which you can use as an integer input to the lookup table.

0 Kudos
Message 6 of 6
(3,470 Views)