Forum Discussion
Altera_Forum
Honored Contributor
14 years ago --- Quote Start --- so, this cosine wave will be sent out of FPGA to modulate the external source current, right? this ensures that the incoming current is locked with the cosine wave from NCO. --- Quote End --- Yes. --- Quote Start --- hmm...I am not sure if I get this part. so if the sampling rate of ADC is 40MSPS. to multiply the input with the cosine& sine, the clk from PLL should be 40Mhz too so the sampling rate of cosine/sine wave from NCO is 40MHz, is that correct? --- Quote End --- You might be able to understand this a little easier if you think about this in terms of samples. Here's some MATLAB code that generates the attached PDF
% Sampling frequency
fs = 40e6;
% Test tone frequency
f0 = 154e3;
% Total sampling time
T = 4/f0; % 4 periods for this example
% Number of samples
Nt = ceil(fs*T);
% Sample index
n = ;
% Time index
t = n/fs;
% NCO output
nco_i = cos(2*pi*f0*t);
nco_q = sin(2*pi*f0*t);
% Plot I and Q as digital looking waveforms
% (you need to zoom into the figure to see the steps)
figure(1)
hold off
stairs(n, nco_i)
hold on
stairs(n, nco_q, 'r')
axis()
What this plot shows you is the NCO output sampled in time; the samples are spaced 40MHz apart, but the signal they generate is at 154kHz. Is that clearer? What this example does not show you is that in reality the cosine and sine would also be quantized, eg., rather than defining nco_i = cos(2*pi*f0*t), you would define a signal that can only take on say 8-bit values, i.e., nco_i = round(cos(2*pi*f0*t)*2^7); --- Quote Start --- and after LPF, the DC components are cos(phase) and sine(phase), if I wanna get the amplitude, mathematically it is cos^2+sine^2...and should I implement the equation in verilog to get the amplitude? --- Quote End --- Given the outputs of the filters output_i and output_q, the magnitude of the signal is sqrt(output_i^2 + output_q^2). You could calculate these values in Verilog, but I suspect the data update rate you require is probably pretty slow, eg. 1Hz or slower, so you can instead have your logic write the sensor values to RAM (for all the current sensor I and Q output values), and then calculate the sensor position in software. Cheers, Dave