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.

Hi Andy, Hi Alec
thanks for your answers.
I have some problems to understand the variables real integer and imaginary integer. Is real integer just the positive amplitude and imaginary the negative? But then, how can positive and negative parts exist at the same time?

for (int i = 0; i < 992; i++)
{
    dwt_readaccdata(cir, 5, (fp_int - 2) * 4 + 4 * i);
    int16 real = 0;
    int16 imag = 0;
    int32 amp = 0;
    real = (int16)cir[2] << 8 | (int16)cir[1]; /*printf("%i,",real);*/
    imag = (int16)cir[4] << 8 | (int16)cir[3]; /*printf("%u\n",imag);*/

    amp = std::max(abs(real), abs(imag)) + std::min(abs(real), abs(imag)) / 4;
}

This is the complete code.

No. They are both part of the signal.
The real and imaginary parts tell you the phase of the value.

Feel free to google a description of the real and imaginary parts of an RF signal, an FFT and just about anything else to do with signal processing. But if this is a new concept to you then expect to get a little confused at first, it’s not something that is intuitive, at least not to me.

But on the plus side most of the time you don’t need to understand it. Just take the magnitude of the vector (sqrt(realreal + imagimag)) and don’t worry too much about what’s going on behind the curtain. Or as alec pointed out, depending on the application you may be able to skip the sqrt part and save some CPU time.

Thank you very much.
Indeed, I found it in literature about complex signals. Judging from the name, I thought it was something device-specific like the dummy octet. :stuck_out_tongue: