0
\$\begingroup\$

So I'm working with the following differences equation:

$$y_n=\alpha y_{n-1}+(1-\alpha)x_n$$

I know this works with 16-fixed point arithmetic, and given some samples I'm trying to figure out how the operation is working. The data given to me is: ´

$$-13559=23528\times(-23528)+(1-23528)\times 12539$$

So my attempt was to do the multiplications, then shift one bit to the left (to eliminate the repeated sign bit) and then shift 16 bits to the right so that result is kept in Q15.

I obtain: $$-13559=-16893-9002$$

Now the result is divided by 2 to put the result in Q14 (I know this is not needed here but since this needs to be general for any pair of numbers we need to guarantee there is no overflow). So now I get: $$-13559=-12947$$

Which is way off. Any idea about what I might be doing wrong? I can provide more pairs of samples if needed.

Thank you!

EDIT: I was pointed out that my samples might be wrong but I don't think they are I provide here the respective values:

$$\alpha=23528$$

Sequence of values

yn=-32767

xn=0 -> yn=-23528

xn=12539 -> yn=-13359

xn=23170 -> yn=-3060

xn=30273 -> yn=6338

xn=32767 -> yn=13789

EDIT2: Ok so now I seem to be achieving more consistent things. However I still can't achieve the exact values of the samples given. Below are my results:

Sequence of values

yn=-32767

xn=0 -> yn=-23528 -> ynOBTAINED=-23528

xn=12539 -> yn=-13359 -> ynOBTAINED=-13359

xn=23170 -> yn=-3060 -> ynOBTAINED=-3059

xn=30273 -> yn=6338 -> ynOBTAINED=6339

xn=32767 -> yn=13789 -> ynOBTAINED=13790

So it is quite similar but there seems to be an offset. I unfortunately noticed later samples have a deviation of 3 or more so there is something wrong with the way I am computing this.

I've tried two different approaches but with the same results

output_filt=((((output_filt*alpha)<<1)>>16)+(((input_filt*(32767-alpha))<<1)>>16));

OR      
output_filt=((output_filt*alpha + input_filt*(32767-alpha))<<1)>>16;

Can someone please help me?

\$\endgroup\$
12
  • 1
    \$\begingroup\$ Looks like your sample is wrong. The first samples equation doesn't hold. \$\endgroup\$ Commented May 24, 2021 at 22:35
  • \$\begingroup\$ @MituRaj I don't think they are. I've provided more samples \$\endgroup\$ Commented May 24, 2021 at 23:11
  • 2
    \$\begingroup\$ The use of \$\alpha\$ and \$\left(1-\alpha\right)\$ implies to me that \$0\le \alpha \le 1\$. Yet I see you showing \$\left(1-23528\right)\$. I'm just guessing at this moment, but do you agree that the value 23528 (dividing by 65536 because you mentioned 16 bit values) implies \$\alpha\approx 0.359\$? Or am I missing the situation and you are supposed to solve for \$\alpha\approx 0.7236\$? Oh, and why is \$Y_{_{n-1}}\$ so conveniently a negative value with the same decimal digits as your \$\alpha\$ value? I'm not saying it's wrong. Just noting the coincidence. \$\endgroup\$ Commented May 24, 2021 at 23:36
  • 2
    \$\begingroup\$ @GrangerObliviate So the value is about 23528/32768=0.718, then? If so, then that first equation doesn't really calculate out right. Something still seems amiss. But what do I know? Perhaps you'll clarify your question? \$\endgroup\$ Commented May 25, 2021 at 0:00
  • 2
    \$\begingroup\$ "I'm still obtaining values slightly off but is only 1 or 2 units" - rounding errors? \$\endgroup\$ Commented May 25, 2021 at 2:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.