?? emeter.h
字號:
//--------------------------------------------------------------------------
//
// Software for MSP430 based e-meters.
//
// THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
// REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
// INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
// COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
// TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
// POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
// INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
// YOUR USE OF THE PROGRAM.
//
// IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
// THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
// OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
// EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
// REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
// OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
// USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
// AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
// YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
// (U.S.$500).
//
// Unless otherwise stated, the Program written and copyrighted
// by Texas Instruments is distributed as "freeware". You may,
// only under TI's copyright in the Program, use and modify the
// Program without any charge or restriction. You may
// distribute to third parties, provided that you transfer a
// copy of this license to the third party and the third party
// agrees to these terms by its first use of the Program. You
// must reproduce the copyright notice and any other legend of
// ownership on each copy or partial copy, of the Program.
//
// You acknowledge and agree that the Program contains
// copyrighted material, trade secrets and other TI proprietary
// information and is protected by copyright laws,
// international copyright treaties, and trade secret laws, as
// well as other intellectual property laws. To protect TI's
// rights in the Program, you agree not to decompile, reverse
// engineer, disassemble or otherwise translate any object code
// versions of the Program to a human-readable form. You agree
// that in no event will you alter, remove or destroy any
// copyright notice included in the Program. TI reserves all
// rights not specifically granted under this license. Except
// as specifically provided herein, nothing in this agreement
// shall be construed as conferring by implication, estoppel,
// or otherwise, upon you, any license or other right under any
// TI patents, copyrights or trade secrets.
//
// You may not use the Program in non-TI devices.
//
// File: emeter-3ph-a.h
// Star's 3-phase meter with custom LCD
//
// Steve Underwood <steve-underwood@ti.com>
// Texas Instruments Hong Kong Ltd.
//
// $Id: emeter-3ph-star.h,v 1.1.1.1 2004/04/06 03:28:17 A0754793 Exp $
//
//--------------------------------------------------------------------------
/* This is a demonstration version of the configuration data file for the
MSP430 e-meter reference software. For most users, this file will need
to be edited to match the hardware being used. */
/* N.B.
This e-meter software uses a sampling rate of 3276.8/s. For a
mains supply at exactly 50Hz, each sample is 5.49degrees of
phase from the last. */
/*! This switch, in combination with the calibrator switch, enables calibration
with the meter cooperating with an external reference, through a UART port. */
#define SERIAL_CALIBRATION_SUPPORT
#define SERIAL_CALIBRATION_PASSWORD_1 0x1234
#define SERIAL_CALIBRATION_PASSWORD_2 0x5678
#define SERIAL_CALIBRATION_PASSWORD_3 0x9ABC
#define SERIAL_CALIBRATION_PASSWORD_4 0xDEF0
/*! This switch enables the sending of the current readings, through a UART port,
for use in cooperative calibration with other meters. */
#define SERIAL_CALIBRATION_REF_SUPPORT
/*! This switch selects single phase mode. If SINGLE_PHASE is not set the
software will be built for 3-phase operation. */
#undef SINGLE_PHASE
/*! This switch enables mains frequency measurement. This may be used as a
meter feature. It may be a requirement, if non-linear CT sensors are used. */
#undef MAINS_FREQUENCY_SUPPORT
/*! The nominal mains frequency is used to prime the mains frequency measurement,
and make its initial value settle quickly. It is not currently used after
reset. */
#define MAINS_NOMINAL_FREQUENCY 50
/*! This sets the number of pulses per kilo-watt hour the meter will produce at
its total energy pulse LED. It does not affect the energy accumulation process. */
#define TOTAL_ENERGY_PULSES_PER_KW_HOUR 1600
/*! This sets the number of pulses per kilo-watt hour the meter will produce at
each phase's energy pulse LED. It does not affect the energy accumulation
process. */
#define PHASE_ENERGY_PULSES_PER_KW_HOUR 1600
/*! This switch inhibits the accumulation of per phase negative power */
#undef INHIBIT_NEGATIVE_PHASE_POWER_ACCUMULATION
/*! This switch inhibits the accumulation of total negative power */
#undef INHIBIT_NEGATIVE_TOTAL_POWER_ACCUMULATION
/*! This is called after the meter has been initialised, and before interrupts are
enabled for the first time. This is just before the meter enters power
down mode waiting for the first power good indication. It may be used to implement
customised initialisation of the meter's special features. */
#define custom_initialisation() /**/
/*! This is called just before the meter enters the power fail state. Since the power is
failing when this is called, the custom routine should not take an extremely long time to
execute. The maximum safe time, before energy is drawn from the battery, will depend on the
hardware design, and how quickly the reservoir capacitor may deplete. There should be
plenty of time to do things like saving essential usage information to EEPROM. */
#define custom_power_fail_handler() /**/
/*! This is called when the meter wakes from the power fail state. It is called after the
main meter functions have all been restarted. */
#define custom_power_restore_handler() /**/
/*! This is called to start some customer specific energy pulse operation. For example,
turning on some special indicator device. */
#define custom_energy_pulse_start() /**/
/*! This is called to end some customer specific energy pulse operation. For example,
turning off some special indicator device. */
#define custom_energy_pulse_end() /**/
/*! The duration of the LED on time for an energy pulse. This is measured in
ADC samples (i.e. increments 1/3276.8s). The maximum allowed is 255, giving a
pulse of about 78ms. 163 gives a 50ms pulse. */
#define ENERGY_PULSE_DURATION 163
/*! Tiny power levels should not record at all, as they may just be rounding errors,
noise, or the consumption of the meter itself. This value is the cutoff level,
in 0.01W increments. */
#define RESIDUAL_POWER_CUTOFF 250
/*! This switch enables monitoring of the neutral lead for anti-fraud purposes. */
#undef NEUTRAL_MONITOR_SUPPORT
/*! This is a shift value for comparing currents or powers when looking for
imbalance between live and neutral. 3 give 12.5%. 4 give 6.25%. These are the
two commonest values to use. The relaxed version is used at low power levels,
where the values are less accurate, and a tight imbalance check might give false
results. */
#define PERMITTED_IMBALANCE_FRACTION 4
/*! This is a relaxed version of the permitted imbalance fraction, for use at low
powers/currents, where the power (and hence imbalance) measurement may be less
precise. The tighter imbalance measurement may give false results under high
EMI conditions. */
#define RELAXED_IMBALANCE_FRACTION 2
/*! This definition specifies the port bit change required to turn on the
normal operation indicator LED, when one is used. If this is defined,
clr_normal_indicator() should also be defined. The normal operation LED will be
lit when the mains voltage is normal. In limp mode, or power down mode,
it is switched off. */
#define set_normal_indicator() /**/
/*! This definition specifies the port bit change required to turn off the
normal operation indicator LED, when one is used. If this is defined,
set_normal_indicator() should also be defined. */
#define clr_normal_indicator() /**/
/*! This definition specifies the port bit change required to turn on the
earthed condition indicator LED, when one is used. If this is defined,
clr_earthed_indicator() should also be defined. The earthed LED will be lit when
there is a substantial imbalance in power (normal operating mode) or
current (limp mode) between the live and neutral leads. If the neutral
has the higher reading, this will also be used instead of the live reading. */
#define set_earthed_indicator() /**/
/*! This definition specifies the port bit change required to turn off the
earthed condition indicator LED, when one is used. If this is defined,
set_earthed_indicator() should also be defined. */
#define clr_earthed_indicator() /**/
#if defined(__MSP430__)
/*! This is called to turn on a total energy pulse indicator (e.g. LED or LCD segment) */
#define set_total_energy_pulse_indicator() (P3OUT &= ~BIT6)
/*! This is called to turn off a total energy pulse indicator (e.g. LED or LCD segment) */
#define clr_total_energy_pulse_indicator() (P3OUT |= BIT6)
/*! This is called to turn on a total reactive energy pulse indicator (e.g. LED or LCD segment) */
#define set_total_reactive_energy_pulse_indicator() (P3OUT &= ~BIT7)
/*! This is called to turn off a total reactive energy pulse indicator (e.g. LED or LCD segment) */
#define clr_total_reactive_energy_pulse_indicator() (P3OUT |= BIT7)
#endif
/*! This is the number of successive measurement blocks which must agree the
unbalanced status has changed before we accept it. */
#define PHASE_UNBALANCED_PERSISTENCE_CHECK 5
/*! This enables monitoring of the balance between the current in the live and neutral
leads, for tamper detection. */
#define POWER_BALANCE_DETECTION_SUPPORT
/*! This is the minimum current level (limp mode) and minimum power level (normal
mode) at which we will make checks for the earthed condition. Very small
readings lack the accuracy and resolution needed to make meaningfulF comparisons
between live and neutral. */
#define PHASE_UNBALANCED_THRESHOLD_CURRENT 500
#define PHASE_UNBALANCED_THRESHOLD_POWER 2000
/*! This selects the operation from current only, when only one lead is
functioning, and the meter is powered by a parasitic CT supply attached to
the leads. This is for anti-fraud purposes. Energy is accumulated at the
highest possible rate, assuming unity power factor, and the nominal voltage */
#undef LIMP_MODE_SUPPORT
/*! If limp mode is supported, these set the voltage thresholds for switching
bewteen normal mode and limp mode. */
//#define LIMP_MODE_VOLTAGE_THRESHOLD 50
//#define NORMAL_MODE_VOLTAGE_THRESHOLD 80
/*! If limp mode is supported, this sets the threshold current, in mA, below which we
no not operate. */
//#define LIMP_MODE_MINIMUM_CURRENT 800
/*! This selects the nominal voltage used for power calculations in limp mode */
#define MAINS_NOMINAL_VOLTAGE 230
/*! This selects support for measuring the RMS voltage. */
#undef VRMS_SUPPORT
/*! This selects support for measuring the RMS current. */
#undef IRMS_SUPPORT
/*! This selects support for reactive power measurement. */
#undef REACTIVE_POWER_SUPPORT
/*! This selects support for reactive power measurement through quadrature processing.
This is only effective when REACTIVE_POWER_SUPPORT is enabled. */
#undef REACTIVE_POWER_BY_QUADRATURE_SUPPORT
/*! The selects support for apparent or VA power measurement. */
#undef VA_POWER_SUPPORT
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -