Sensor square wave input

Requests, not necessarily related to fpga4fun...

Sensor square wave input

Postby neil_mallia » Mon Mar 29, 2010 2:40 pm


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

HUM1 := '0';

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
Posts: 4
Joined: Mon Mar 29, 2010 2:29 pm

Return to Help requests