I was trying to make a frequency mixer (only difference frequency) for two square waves (PWM1, PWM2, both 0.5-4KHz range) using ONLY Arduino due.
I'm new to signal processing, and the only way I can think of making a differential frequency is purely mathematical,and only for sin waves:
The cos term is a problem because it involves 90 degree phase shift, so I cannot just use logical operators to express the function.
However during Googling I saw a statement that D flip flop can be used to produce only the difference term in frequency mixing.
That is, if I understand it correctly, attaching an interrupt to the rising edge of PWM1, in the ISP read the PWM2 value and write it to the output pin.
It make sense as the closer the frequencies of PWM1 and PWM2 is, the smaller the frequency of the output wave. However it seems too good to be true and I cannot figure out how this is mathematically equivalent to the difference part of the product of the two signals.
Will I get better accuracy if I use a real D flip flop ?
For 'frequency mixer' I mean the product of two signals. $$2cosAcosB=cos(A+B)+cos(A-B)$$ For 'the difference part of frequency mixer' I mean only the term with differential frequency (A-B).