Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- max = 0;
- t = millis();
- while (1)
- {
- instantCurrent = readAnalog();
- if (instantCurrent > max)
- max = instantCurrent;
- if (millis() - t > 1/50) //period is over.
- { // prepare for the next maximum in the next period
- Irms = max/sqrt(2);
- AveragePower = 220 * Irms / 50; // --> THAT'S WHAT I WANT
- t = millis();
- max = 0;
- }
- }
Add Comment
Please, Sign In to add comment