Hi,

I have a humidity sensor which gives a square wave as an output. I want to read the frequency of the square wave. I am using VHDL.

What I did till now is a 1 second timer and then I am trying to read how many positive edges are there in that one second, but till now I am getting only rubbish!

To read the positive edges of the input I did the following:

if (HUMIDITY = '1' AND HUM1 = '0') THEN -- a positive edge

Fout := Fout + '1'; --increase counter

HUM1 := '1'; -- so that on the next clock cycle the statement becomes false

END IF;

IF HUMIDITY = '0' THEN

HUM1 := '0';

END IF;

Where HUMIDITY is the Input from the sensor, Fout is a counter and HUM1 is a variable.

Then after 1 second I am storing Fout in another variable and then reset it to start again.

Any help on how can I implement this please?

Thanks a lot