Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Is the following method for downsampling 40 MHz to 5 MHz allright in vhdl

Status
Not open for further replies.

syedshan

Advanced Member level 1
Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Visit site
Activity points
5,134
downsampling 40 MHz to 5 MHz in vhdl

hello every one,

I have a high speed adc which I am giving the clock of 40 MHz. Now my requirement is such I need only the signals equivalent to 5 Mhz clock-related signal hence I am doing so by following method.

Is this alright. I read about down-sampling that for high frequency components we might have aliasing issues, (but I am thinking that taking only every 8th data wont hurt the signals much...!!?? note sure though


Code:
process(clkHIGHM, rst)
begin
	if(rst = '1') then
		cntr <= 0;
		fwr_en <= '0';
		wr_cnt <= 0;
		wr_stop <= '0';
	elsif(rising_edge(clkHIGHM)) then
		if(f_full = '0' and wr_stop = '0') then
			if(cntr < div_factor-1) then   //div_factor = 8
				cntr <= cntr + 1;
				fwr_en <= '0';
			else
				cntr <= 0;
				fwr_en <= '1';
				wr_cnt <= wr_cnt + 1;
			end if;	
		elsif(f_full = '1') then
			wr_stop <= '1';
			fwr_en <= '0';			
		end if;
	end if;

PS. Note that the clock frequency even for the down-sampled sample is 40 MHz but since the data is stored in FIFO first, hence I am enabling wr_en at respective intervals.
 

Have you simulated this code?
You need to ensure you're sampling above the niquist frequency (2x source frequency). As long as the signal you're trying to sample is less than 2.5Mhz, it should work, but obviously the higher the sampling frequency the higher the accuracy in data reproduction.
 

As mentioned, a simple downsampling mirrors spectral components above the Nyquist frequency of 2.5 MHz into the base band. But the 40 MHz sampled data may already contain aliasing products if the ADC hasn't a suitable anti-alias filter in front of it. For a reasonable answer, you need to know the input signal spectrum and the applied filtering.

Even if there's are no signal components beyond 2.5 MHz, you have at least ADC quantization noise. Downsampling without decimation filter misses the chance to improve the signal-to-noise ratio. In so far the simplest downsampling method is also the worst in terms of signal processing. Averaging the samples would already improve SNR and give a certain attenuation of out-of-band components.
 

hmm

Actually I went onto run it into hardware (after simulation of course) and result is shown in image below, with comparision

Actually later I found that I should observe the Nyqist (of course the higher the better result).

I tested over hardware my design with sinosoidal wave of 1 MHz and the result is good, although I can see some difference at the peaks (please see the diagram. so I will try to down sample with some lower sampling factor)

About using LP filter, yes this is the next thing I would have done if simple down sampling would have produced un-deterministic results. But since the signal I am trying to sample is maximum 1 MHz ultrasonc wave, I guess I do not need LP fitler

Thanks for help though

Capture.JPG
 
Last edited:

I tested over hardware my design with sinosoidal wave of 1 MHz and the result is good, although I can see some difference at the peaks (please see the diagram. so I will try to down sample with some lower sampling factor)

Obviously no aliasing problems are expectable with about 1 MHz input frequencies. But you probably didn't specify the problem exactly.

The said "difference at the peaks" reveals a problem in understanding of time discrete signal processing. A sequence of sampled data points doesn't look like the original sine wave. The Nyquist criterion claims only that the original signal can unequivocally reconstructed from the samples. The plotted waveform is, by the way, a special reconstruction where the data points are connected by straight lines. In terms of digital processing, the data is defined only at the sampling points.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top