phi is just the current pointer in the lookup table, and f is the increment that we add to the pointer. These are fractional values though so we need to store the pointers in fixed point and just use the integer part.
This looks good but we need to annotate what is an integer and what is a fixed point. We also need to determine the range for the error signal and what the precision should be. Should these be configurable?
We have a python model of an NCO, lets turn that into a basic PLL.
The big thing that we need here is a phase detector. We could either use 2 mixers in quadrature, or we could just xor the msb, which is the more digital way I guess.
Ah so here we need to determine the difference between positive difference and negative difference.
In the beginning the pll signal is completely out of phase, then gets in phase, then gets out of phase again.
We can see what quadrant we are in and whether being greater than or less than means before or after. also for our table we should use cosine, cause that makes it easier for this math.
Even with a much lower symbol rate we still see a big error with even a small phase error, so we need to sync the clocks somehow. Lets try building a costas loop.