What is meant by 16-bit real integer and a 16-bit imaginary integer?

Hello guys,
I found this code for the calculation of the amplitude over time with CIR data:
double amp = std::max(abs(real), abs(imag)) + std::min(abs(real), abs(imag)) / 4;

How is this calculation is achieved? And what are the 16-bit real integer and a 16-bit imaginary integer metioned in the User Manual?

Best Regards,
Miro

Hi Miro,

The formula looks wierd to me. For amplitude or magnitude I would expect something with sqrt().
Or it can be actually a rough sqrt() approximation. Where did you find it?
Anyway the CIR data can be read using 0x25 register file, see 7.2.38 Register file: 0x25 – Accumulator CIR memory of the User Manual.
It contains 1016 points of the CIR buffer (aka accumulator), interleaved real and imaginary parts, 16bit signed int each.
Probably for this formula you don’t need the whole data, only the first path.

That calculation (Max + 1/4 Min) is intended as a quick and dirty method of calculating the magnitude of the signal without resorting to floating point maths. If you have the CPU power then sqrt(maxmax + minmin) will give you a far better solution.

1 Like

This reminds me the famous inverse square root.
BTW I saw double word in the topicstarter’s post, that’s why I was curious. Usually this amplitude is used to indicate some levels or check wrt some threshold - in that case the asctual square root is not needed, the sum of squares is enough.