Hi,
I want to calculate the energy by calculating the frequency
Frequency has nothing to do with energy. Each single pulse represents a certain amount of "energy".
If you want to calculate "total energy" you just need to count (integrate) the pulses and multiply the value with the "singke pulse energy".
**************
You need to measure
frequency only, if you want to calculate "active power".
If you want this, then the first thing you need to decide:
* what range of frequency do you expect?
Then decide "frequency measurement method" you want/need to use.
* time measurement between pulses (for low frequencies)
* or "counting pulses for a known period of time" (for high frequencies)
--> there are a lot of "frequency measurement" threads in this forum, with code and discussions.
Then multiply the frequency with the "single pulse energy" to get active power.
Klaus