LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating constant arrays

I want to precompute an array of values. How can I do this? I can make the array and put the data in an indicator, but how do I move that data into a constant? It seems to work easily with integer types, but I am not having so much success with fixed point types.

Message Edited by pd2 on 07-07-2008 05:00 PM
0 Kudos
Message 1 of 10
(3,921 Views)
I'm not sure what you're doing, and generating a constant array seems like an oxymoron to me, but to create a constant out of an indicator all you need to so is to drag the indicator onto the block diagram and drop it, as in a drag and drop operation. You can also right-click on the indicator terminal on the block diagram and select Create -> Constant.
0 Kudos
Message 2 of 10
(3,914 Views)
It should be sufficient to right-click the indicator (containing the data) and do a "change to constant" or "create constant".
 
What kind of difficulties do you have?
0 Kudos
Message 3 of 10
(3,913 Views)
What you guys are saying works fine when the data type is an integer. It does not work when the data type is fixed point. When I try to do it with fixed point data, it changes to all zeros.

As for why I am generating a constant array, it is because sometimes it can take a long time to compute something, but you need the values quickly at runtime. So I am computing a lot of values ahead of time and then pulling the correct value from the array at runtime so that it will be fast.
0 Kudos
Message 4 of 10
(3,895 Views)


pd2 wrote:
What you guys are saying works fine when the data type is an integer. It does not work when the data type is fixed point. When I try to do it with fixed point data, it changes to all zeros.

As for why I am generating a constant array, it is because sometimes it can take a long time to compute something, but you need the values quickly at runtime. So I am computing a lot of values ahead of time and then pulling the correct value from the array at runtime so that it will be fast.

What is your LabVIEW version? Everything works fine here with 8.5.1 and fixed point.
 
If all calculations depend only on diagram constants, the calculation will be done at compile time if possible and folded into a constant.
 
How big is the constant array? How long does it take to compute?


Message Edited by altenbach on 07-07-2008 04:12 PM
0 Kudos
Message 5 of 10
(3,892 Views)
I am using LabVIEW 8.5.

The array holds 257 samples of a cosine wave from 0 to pi/2. I am precomputing the array in the normal environment, but I will attempt to place the constant array on an FPGA. I realize there can be issues with arrays and FPGAs, but I want to try it as I think computing a sine or cosine with the Fixed-Point math module for the FPGA takes 17 cycles. Also, I can guarantee that these samples are all I will need. I do not need to interpolate.
0 Kudos
Message 6 of 10
(3,886 Views)
I found a detail I missed. All the values in the array were between 0 and 1. I decided to try to increment the values before I stored them in the indicator so they were all between 1 and 2. Then when I switched it to a constant, they all became 1. It looks like it rounds down when I change to a constant.
0 Kudos
Message 7 of 10
(3,881 Views)
Ok, now I feel dumb. It was working all along. The box that held the number just didn't get large enough for me to see the decimal point or anything after it. The whole number is there when I expanded the number view.
0 Kudos
Message 8 of 10
(3,879 Views)
What is the "word lenght" and "integer word lenght" setting?
0 Kudos
Message 9 of 10
(3,878 Views)
Signed 16 bit word length with 1 bit integer word length. This gives me a range from -1 to 1.
0 Kudos
Message 10 of 10
(3,876 Views)