LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed Point Rio Question

Solved!
Go to solution

Just a general question about some gaps in my knowledge. We used fixed point in the Rio which is fine. If I am doing some basic mathematics, say multiplication of two numbers formatted as 20,4 ie integer size 4 and 16 bits after the decimal point then I get a 40,8 number. Should I re-convert that back to 20,4 or can I leave it and just continue. Will labview make space for all the varying solutions or must I handle it manually? I can see if I am doing a lot of multiplies and adds then the numbers would get bigger and bigger.

 

Also I saw an article where the progammer did the shifting to the right and scaling himself but will the fxp block do this for me? eg I multiply two 8,4 numbers and get a 16,8 which I must shift to the right and re-scale. So what is best practice for multiplication,division and addition.

 

Thanks

0 Kudos
Message 1 of 3
(2,093 Views)
Solution
Accepted by topic author tomnz

I am not sure what you're asking here.  What do you mean by, "Will LabVIEW make space for all the varying solutions?"  By providing the result as a 40,8 value, LabVIEW is ensuring that there will be sufficient space for any result.  You can continue with that value, but eventually you'll need to scale it back.  Numbers with more bits require more FPGA resources, and there is a maximum number of bits that can be used to store a value.  It's up to you to know how you would like to handle that scaling.  Sometimes it's more important to preserve the most significant bits and lose resolution.  In other cases you may know in advance the normal range of the inputs, and can accept overflow for unusual inputs in order to maintain resolution for typical values.  There's no definite best practice.  See Caveats and and Recommendations for Using Fixed-Point Numbers.

0 Kudos
Message 2 of 3
(2,087 Views)

i agree with nathand post and understand where the questions from the original come from.  the bottom line with fxp numbers and RIO is that you have to think about all of the operations you are doing and determine the appropriate output type for your operations.  applying scaling coeffs to a 20.4 can probably remain a 20.4.  squaring a 20.4 can be anywhere from 20.8 to 40.8 depending on what you are doing with the results.  just as important is the choice to saturate or wrap.

thought is required at all steps.

the previous method of doing the same thing without explicit fxp support required even more thought.

Stu
0 Kudos
Message 3 of 3
(2,085 Views)