How to accurately count the time period (hardware)?
If it is not a noisy signal you could use a technique called "zero crossing" to gate a counter. You may use an FPGA to create accumulators to add up times and down times.