![]() |
AVR1631 - Energy Meter Reference Design with ATxmega32A4
Rev 1.0
|
Meter Calibration routine. More...
#include <math.h>Go to the source code of this file.
Macros | |
| #define | VOLT_GAIN 1 |
| #define | FREQUENCY_MAX 5000 |
| #define | FREQUENCY_MIN 25000 |
| #define | LP_ORDER 6 |
| #define | ONE_PULSE_ENERGY_THRESHOLD (float)0.0003125 |
| #define | PULSE_ON_TIME 13 |
Functions | |
| void | calculate (void) |
| void | calculate_freq (void) |
| void | get_frequency (void) |
| int16_t | lp_filter (int16_t *) |
| void | meter_flush (void) |
Variables | |
| uint16_t | Vrms [5] |
| uint16_t | Irms [5] |
| uint16_t | Nrms |
| int16_t | offset [7] |
| uint16_t | adc_samples |
| int32_t | active_energy_signed |
| int32_t | neutral_power |
| uint16_t | active_power [5] |
| uint16_t | apparent_power |
| int16_t | power_factor |
| int32_t | volt_temp |
| int32_t | ct_temp |
| int32_t | shunt_temp |
| uint8_t | calibration_flag |
| uint8_t | calibration_count |
| uint8_t | gain_stage |
| variables used in metering calculations | |
| uint16_t | frequency |
| int64_t | watts_sum |
| int64_t | watts_sum_calib |
| uint8_t | freq_cnt |
| uint8_t | offset_cnt |
| uint16_t | max_demand |
| float | pulse_energy_2_5ms |
Meter Calibration routine.
$Revision: 1.0
$Date: 2012-07-01 10:10:10 +0530
Copyright (c) 2008, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file meter_calculations.h.
| void calculate | ( | void | ) |
brief This function is called on every 1sec and perform the calculation of metering paramters
| Irms | contains the root mean square value of current on phase line |
| Vrms | contains the root mean square value of voltage |
| Nrms | contains the root mean square value of current on neutral line |
| apparent_power | holds the apparent energy (VA) |
| active_power | holds the active energy (Watts) |
| power_factor | hols the power factor(PF) |
Definition at line 233 of file meter_calculations.c.
| void calculate_freq | ( | void | ) |
brief This function calculate line frequency from the value
| frequency | hold the line frequency. |
| freq_avg | hold the average timer value. |
Definition at line 396 of file meter_calculations.c.
| void get_frequency | ( | void | ) |
function check for the sign change in voltage signal for frequency calucaulation.
| sign_flag | updated when there is a sign change sign_flag = 0, during the negative half cycle sign_flag = 1, during the positive half cycle |
| freq_val | hold the timer value of one sine wave |
| freq_sum | hold the accumulated timer counter for frequency calculation |
| freq_cnt | hold the number of sine waves taken for frequency measument |
Definition at line 420 of file meter_calculations.c.
| int16_t lp_filter | ( | int16_t * | inp_array | ) |
brief This function performs the low pass filtering of the input array
| lp_coeff | contains the coefficients for the low pass filtering |
| lp_output | return the filtered value |
Definition at line 208 of file meter_calculations.c.
| void meter_flush | ( | void | ) |
brief This function clear all the varilable used in for energy calculation
Definition at line 447 of file meter_calculations.c.