Continue to Site

# Finding time period of an unknown signal

Status
Not open for further replies.

#### BojackHorseman

##### Newbie level 6
I want to find the time period of an unknown signal in microseconds. I already have a code that helps me find the frequency of an unknown signal. Is there a way to modify that code to find the time period of that signal in microseconds ?
Code:
timescale 1ns / 1ps

module freq_counter( input clk_100mhz,
input reset,
input low_freq_clk,
output reg [13:0] out1
);

reg low_freq_clk_x, low_freq_clk_xx, low_freq_clk_xxx;
reg [25:0] lo_counter;
reg [26:0] hi_counter;
always @(posedge clk_100mhz or posedge reset) begin
if (reset) begin
lo_counter <= 26'd0;
hi_counter <= 27'd0;
out1 <= 14'd0;
end

else begin

low_freq_clk_xxx <= low_freq_clk_xx;
low_freq_clk_xx <= low_freq_clk_x;
low_freq_clk_x <= low_freq_clk;

if (low_freq_clk_xxx & ~low_freq_clk_xx) lo_counter <= lo_counter + 1'b1;

// Output total frequency when one second is up
if (hi_counter == 27'd100000000) begin
out1 <= lo_counter;
lo_counter <= 1'b0;
hi_counter <= 1'b0;
end else
hi_counter <= hi_counter + 1'b1; // Elapse time
end
end
endmodule`

Hi,

Basically if you have the frequency, then just do

t(p_us) = 1,000,000/f

****

But an unknown signal ... it can be anything...

****

At least you should specify
* the frequency range,
* the resolution,
* the update rate.

Klaus

Hi,

Basically if you have the frequency, then just do

t(p_us) = 1,000,000/f

****

But an unknown signal ... it can be anything...

****

At least you should specify
* the frequency range,
* the resolution,
* the update rate.

Klaus
The frequency range is from 1000Hz to 9999 Hz. As for resolution I want the output in microseconds and update every 1 second.

Hi,

and what about the "unknown" signal? How "unknown" is it?
In best case it is a clean square wave logic signal. Then the signal is not a at all unknow, just it´s frequency.
Or ist it any analog signal, or any modulated signal?

Klaus

@BojackHorseman
One cannot design a digital system where NOTHING is known about the system input/s.
The more information you give us, the more help will you get!

Status
Not open for further replies.