AVR1631 - Energy Meter Reference Design with ATxmega32A4  Rev 1.0
 All Data Structures Files Functions Variables Typedefs Macros
meter.h File Reference

Meter Calibration routine. More...

#include <ioavr.h>
#include <math.h>
#include "clksys_driver.h"
#include "adc_driver.h"
#include "rtc_driver.h"
#include "meter_calculations.h"
#include "meter_calibration.h"
#include "meter_initialisation.h"
#include "meter_lcd_module.h"
#include "meter_rtc.h"
#include "avr_compiler.h"

Go to the source code of this file.

Data Structures

struct  coefficient

Macros

#define RTC_CYCLES_1S   1024
#define TAMPER_CURRENT_REVERSAL   PIN0_bm
#define TAMPER_EARTH_FAULT   PIN1_bm
#define TAMPER_NEUTRAL_CUT   PIN3_bm
#define F_CPU   32000000UL
#define F_TIMER   500000UL
#define F_SAMPLING   124
#define POWERED_UP   0
#define POWER_OFF_DETECTED   1
#define POWER_OFF   2
#define POWER_ON_DETECTED   2
#define eeprom   eeprom_t
#define meter   meter_t

Functions

void tamper_check (void)
int16_t adc_iadc_debug (void)
int16_t adc_vadc_debug (void)

Variables

uint8_t rtc_flag
uint8_t cover_open_flag
__eeprom struct coefficient eeprom_t
struct coefficient meter_t
int16_t debug_count
int16_t debug_count1

Detailed Description

Meter Calibration routine.

Application note:
AVR1631: Energy Meter Reference Design with ATxmega32A4
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author
Atmel Corporation: http://www.atmel.com
Support email: avr@a.nosp@m.tmel.nosp@m..com

$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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  1. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

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.h.

Function Documentation

void tamper_check ( void  )

This function checks for different types of tampering such as earth fault current reversal, neutral cut, magnetic tampering

check for earth fault tamper (Load earthing)
compare the phase current is within 12% of the neutral current

if tampering persist for 15 secs update the led status

check the status for Current Reversal tampering

if tampering detected toggle the TAMPER_CURRENT_REVERSAL LED

check the status for Neutral CUT tampering and configure the status led

check the status of Magnetic tamper flag and update the LED

Definition at line 58 of file meter_task.c.