Hi Ken,

Thank you very much for your response!

**Ken Kundert wrote on Sep 29**^{th}, 2020, 6:49am:This may be a simple debugging issue. I recommend that you print/plot your variables, especially R, and see if you are getting the values you expect.

You hit the bull's-eye

! Debugging the model, I realized that it was not entering in the

*timer* routine.

Looking more carefully, I noted that, despite their declaration, the compiler was interpreting

*period* and consequently

*speriod* as integer variables, assigning 0 for both of them.

This issue was fixed adding

*.0* to the numbers used to those variables calculations.

**Ken Kundert wrote on Sep 29**^{th}, 2020, 6:49am:I see two other confounding issues. First, the resistance appears to change every 128 cycles. If your FFT spans these changes then you will be measuring some kind of average resistance rather than the instantaneous resistance., which is what you calculated by hand.

That was a very usefull observation. I took care of it, thank you.

**Ken Kundert wrote on Sep 29**^{th}, 2020, 6:49am:Also, are you sure *speriod* should be 1280 cycles and *speriodd* be 128 cycles. Perhaps those two values should be swapped? It seems like the way it is SUM will be 0 90% of the time.

In fact,

*speriod* is (1/1280) cycles and

*speriodd* is (1/128) cycles. I believe there was a misreading here. Anyway, I changed it a little bit, adding an

*if* statement inside the timer routine to do the operation of

*speriodd* given a specific

*N*. Now it seems to work perfectly.

Again, thank you very much for your help!

Kind regards,

Vitor