marceluda / rp_lock-in_pid_h

Lock-in and PID application for RedPitaya enviroment (only with harmonic modulation)
GNU General Public License v3.0
7 stars 8 forks source link

Modulation Amplitude unexpected behavior #7

Closed avsteele closed 2 years ago

avsteele commented 2 years ago

The modulation amplitude does not behave like I would expect. I expected that if I had for example Output 1 set to cos_ref or cos_1f, then a modulation amplitude integer value of -1...8100 would let me select the amplitude of the output wave over its full range. But instead I see the results below:

If I set Output 1 to cos_1f then for Mod Amplitude A Out 1 =-1...8100 Output 1 sine wave amplitude goes from ~0.5 V ... 0.75V

If I set Output 1 to cos_ref then for Mod Amp A Out 1 =-1...8100 the sine wave amplitude goes from 0.5...1.0 V

The only configuration which works like I expect is I use the Modulation Amplitude Out 2, where output 2 is set to Ctrl_A . Then a the modulation amplitude integer -1...8100 causes a sine wave of amplitude ~0V to ~0.5 V to get added to the ramp.

Is this the expected behavior?

Thanks a lot!

marceluda commented 2 years ago

Yes, that's the expected behaviour.

The problem is that it's not documented properly. My error.

The idea is this:

Here's the code: https://github.com/marceluda/rp_lock-in_pid_h/blob/master/lock_in%2Bpid_harmonic/fpga/rtl/lock.v#L421

Sorry for the poor description.

avsteele commented 2 years ago

Thank you Marcelo. Ok I understand partially.

Normally, I set Out 1 to cos_1f, or sin_1f. Then the demodulation works well and the phase setting's effect on the demodulated output works as expected. (I see from the code that _1f signals get phases added).

The cos_ref and sin_ref do not have a phase added to them, so the demodulation cannot be optimized.

Also, (for reasons I cannot quite understand), using cos_ref, sin_ref (or any other output with these added) do not demodulate correctly at 46 kHz, but seem to work OK at every other lower frequency.

Is there something I'm missing?

marceluda commented 2 years ago

That's right.

What I use to do is add cos_ref on out1 (with the control_A signal assigned) and then use F1 signa for demodulation. So I can tune it for maximum amplitude before the PID input.

avsteele commented 2 years ago

Ah I see now. I didn't realize the which was meant by signal F1o. But now I see it here: https://marceluda.github.io/rp_lock-in_pid/TheApp/instruments/instruments_02_scope/

Thanks!