Hi there,

I want to use the simple Kalman filter from Analog Devices' image tool box. The application is to track a moving part with constant speed. The Kalman model has a state vector dimension of 2 (location + speed) and the measurement is 1-dimensional (only location).

I went into the Kalman code and had a look at the Kalman example, too. It appears to me that this Kalman implementation uses some fixed point format X.Y where the shift of the decimal must be specified when applying the Kalman filter. It also uses some adi_Float16toMaxXY and adi_MatXYtoFloat16 conversions from utililies_ref.c. Looking at float16.h and utilities_ref.c I understood that I need to convert normal measurement input from (normal) float to float16 format and then convert this Float16-Matrix to a MatXY format for the Kalman Filter.

Same applies to initilisation of the matrices A, H, Q,... Now I found the following ackward thing. Trying to convert a number

1.973

from float to float16 failed. When using the test fits_to_fl16(1.973) it returned false (failed) and if I still used it it went into the DEBUG message "precision lost" (see float16.h code). So I started to try what numbers are accepted:

fits_to_fl16(1.97) -> false

fits_to_fl16(1.9) -> false

fits_to_fl16(2.0) -> true

fits_to_fl16(0.2) -> false

This looks to me pretty unusable and I found here in the forum:

Please note that the IEEE support for single precision floats has been significantly improved in VisualDSP++ 5.0 Update 9 and it might be that you could consider using standard float types instead. Also the reason that float16.h and _float16 aren't documented is that they are non-standard and not really intended for general use.

So either I use the float16 format wrongly or I should use a different approach to "import" my measurments into the Kalman Filter's update and to initialize the matrices.

I appreciate any help on this issue.

TheWiper

Hi,

Here is the response provided through private support:

All inputs to Kalman is in X.Y format and not in float16. This format is converted internally to float16 and back since matrix inverse accepts data in float16 due to the need for dynamic ranges.

X.Y format is a fixed point format where Y amount of bits is given for decimal portion of the number. X will always be 32-Y as total number of bits in an integer is 32. If one need 16 bits of precision for the decimals then format used is 16.16 or if one requires only 8 bits of precision then format used will be 24.8 format. The allocation of bits of decimals part depends on the application and the number ranges one require.

Allocating more bits to decimal part will reduce the range of numbers possible. The shift parameter for the Kalman is actually the value of Y in X.Y.

If one has value in float format, then it need not be converted into float16 and then to X.Y format since this may reduce the precision. One can easily convert float to X.Y in the following ways:

If the format is 24.8 and need to convert 1.7f to 24.8 format, then multiply 1.7 with 2^8(i.e. 256) which will give 435.2 and take only the Integer part or round it off (better precision but more MIPS). In this case it is 435 which is the representation of 1.7 in 24.8 format.

Hence, the conversion is

Representation of a float number in X.Y format = (int)(float_number * 2^Y)

Hope this clarifies the input format representation for the Kalman filter.

Regards,

Craig.