?? emeter.h
字號:
/*! This switch enables support for power factor measurement. This feature
includes a lead/lag assessment. A frequency independant method, based
on the ratio of scalar dot products, is used. */
#undef POWER_FACTOR_SUPPORT
/*! This switch selects support for measuring the total active energy consumption. */
#define TOTAL_ENERGY_SUPPORT
/*! This switch selects support for measuring the active energy consumption on a phase
by phase basis. This is only significant for poly-phase meters. */
#define PER_PHASE_ENERGY_SUPPORT
#define set_phase_1_energy_pulse_indicator() (P3OUT &= ~BIT0)
#define set_phase_2_energy_pulse_indicator() (P3OUT &= ~BIT1)
#define set_phase_3_energy_pulse_indicator() (P3OUT &= ~BIT2)
#define clr_phase_1_energy_pulse_indicator() (P3OUT |= BIT0)
#define clr_phase_2_energy_pulse_indicator() (P3OUT |= BIT1)
#define clr_phase_3_energy_pulse_indicator() (P3OUT |= BIT2)
/*! This switch selects support for measuring the total reactive energy. */
#define TOTAL_REACTIVE_ENERGY_SUPPORT
/*! This switch selects support for measuring the reactive energy on a phase by phase
basis. This is only significant for poly-phase meters. */
#undef PER_PHASE_REACTIVE_ENERGY_SUPPORT
/*! This enables the generation of total energy pulses to an accuracy of 1/32768s, instead
of 10/32768s, when building meters using the ADC12 ADC converter. This features uses channel
2 of timer A, and the pulse LED/opto-coupler/etc. must be attached to the TA2 pin of the MCU.
Because extra hardware resources are used, and most meters do not require this level of pulse
position accuracy, this feature is made an option. */
#undef FINE_ENERGY_PULSE_TIMING_SUPPORT
/*! This switch enables use of the MSP430's internal temperature diode to
measure the meter's temperature. */
#define TEMPERATURE_SUPPORT
/*! This switch selects support for the monitoring of a hall-effect magnetic sensor. This can be
used to detect very high magnetic fields which might be used for tampering (i.e. fields strong
enough to paralyse CTs, and other magnetic components in the meter's design). */
#undef MAGNETIC_INTERFERENCE_SUPPORT
/*! This sets the number of consecutive seconds magnetic interference must be present
or not present before the magnetic tampering state will switch. */
//#define MAGNETIC_INTERFERENCE_PERSISTENCE_CHECK 5
/*! The hall effect sensors used to detect magnetic tampering output pulses, whose on/off ratio
reflects the scale of the magnetic field. This sets the ratio at which magnetic tampering is
declared. */
//#define MAGNETIC_INTERFERENCE_SAMPLE_RATIO 10
/*! When magnetic tampering is detected, the output of CTs is completely unreliable. The meter can only
assume there is a very high load at unity power factor, and charge accordingly. This sets the current
to be used in this calculation. It is specified in milliamps. */
#define MAGNETIC_INTERFERENCE_CURRENT 60000
/*! This switch selects support for a short range RF link. */
#undef RF_LINK_SUPPORT
/*! This selects real time clock support. This is implemented in software on
the MSP430. */
#define RTC_SUPPORT
/*! Related definitions to get special action routines to be called at various
intervals. User supplied callback functions must be provided. Note these
callback routines are called from within the per second timer interrupt
service routine. Don't do anything too complex within them. If a long
activity is required, set a flag within a simple routine, and do the main
work in the main non-interrupt loop. */
#undef PER_SECOND_ACTIVITY_SUPPORT
#undef PER_MINUTE_ACTIVITY_SUPPORT
#undef PER_HOUR_ACTIVITY_SUPPORT
#undef PER_DAY_ACTIVITY_SUPPORT
#undef PER_MONTH_ACTIVITY_SUPPORT
#undef PER_YEAR_ACTIVITY_SUPPORT
/*! Corrected RTC support enables temperature and basic error compensation for
the MSP430's 32kHz crystal oscillator, so it makes for a higher quality RTC
source, even using low accuracy (eg 20ppm) crystals. */
#define CORRECTED_RTC_SUPPORT
/*! This select support for a custom real time clock. The customer's routine
will be called every second. */
#undef CUSTOM_RTC_SUPPORT
#if defined(__MSP430__)
#define custom_rtc() /**/
#define custom_rtc_set() /**/
#define custom_rtc_retrieve(x) /**/
#endif
/*! This switch enables measurement of the third and fifth harmonic contents
of the current waveform. */
#undef HARMONICS_SUPPORT
/*! This switch select the use of current dependant phase correction, to allow
the use of non-linear CTs. */
#define PHASE_CORRECTION_SUPPORT
/*! This switch enables dynmaic phase correction for non-linear CTs, or other sensors
for which the phase changes with the current. */
#undef DYNAMIC_PHASE_CORRECTION_SUPPORT
/* This select support for a custom real time clock. The customer's routine
will be called every second. */
#undef CUSTOM_RTC_SUPPORT
/* This switch enables power down to battery backup status on loss of line
power. */
#undef POWER_DOWN_SUPPORT
/* These switches select a method of detecting when power is restored, if
power down mode is supported. */
/* This method assumes the voltage waveform is being turned into simple
digital pulses into an I/O pin. If this feature is used, POWER_UP_VOLTAGE_PULSE
must define the way a voltage pulse is sensed. */
#undef POWER_UP_BY_VOLTAGE_PULSES
//#define power_up_voltage_pulse() (P1IN & BIT0)
/* This method assumes the pre-regulator power supply voltage is being
monitored by Comparator A. This method is suitable for meters which
support a live/neutral only mode, for tamper resistance. */
#define POWER_UP_BY_SUPPLY_SENSING
/* This switch enables custom routines to be called as the meter enters and
exits the power fail state. These might be used to save and restore things,
using non-volatile memory. */
#undef CUSTOM_POWER_DOWN_SUPPORT
/* Many data logging requirements can be met by using only the MSP430's
info memory. If an external serial EEPROM is needed for more
complex requirements, this switch will enable an interface to
I2C type serial EEPROMs. Basic routines to driver these EEPROMs are
included in the toolkit. Routines to actually store and retrieve
information are left to the meter designer. */
#undef EXTERNAL_EEPROM_SUPPORT
/* This switch enables support of an IR receiver and/or transmitter for
programming and/or reading the meter. */
#define IEC1107_SUPPORT
/*! This definition specifies the port bit change required to enable the IR
receiver, when one is used. */
#define enable_ir_receiver() /**/
/*! This definition specifies the port bit change required to disable the IR
receiver, for power saving, when one is used. */
#define disable_ir_receiver() /**/
/*! This defines the speed of UART 0 */
#define USART0_BAUD_RATE 9600
/*! This defines the speed of UART 1 */
//#define USART1_BAUD_RATE 9600
/*! This switch enables a rolling display of all the meter's measured
parameters, for demonstration purposes. The parameters are displayed
on a local attached LCD, which may be driven by an MSP430's internal
LCD controller, or be part of a standard external module.
Real meters will generally need to replace this with their own custom
display routines. */
#define BASIC_LCD_SUPPORT
/*! This switch enables the calling of a custom LCD display routine. This allows
easy integration of custom code for specific meter designs. */
#undef CUSTOM_LCD_SUPPORT
/*! This is called to perform initialisation of a custom display */
#define custom_lcd_init() /**/
/*! This is called to perform custom display processing when the meter goes to
sleep. This is typically turning off the display, to conserve energy. */
#define custom_lcd_sleep_handler() (LCDsleep(), display_power_fail_message())
/*! This is called to perform custom display processing when the meter wakes up from
the sleeping condition. */
#define custom_lcd_wakeup_handler() LCDawaken()
/*! This switch enables multi-rate tariff features */
#undef MULTI_RATE_SUPPORT
/*! This is called from within the main processing loop. This allows easy integration
of custom code for specific meter designs. This routine is called often in normal
operating mode. In limp mode it is called once each time the background activity
informs the foreground activity there is a block of data to be processed. It will
also be called when a key is pressed, or for each repeat if a key is in repeat
mode. */
#define custom_mainloop_handler() /**/
/*! This is called in the main processing once every 2 seconds. */
#if defined(__MSP430__)
#define custom_2second_handler() /**/
#endif
/*! This switch enables support for some basic keypad handling, to work
with the basic demonstration LCD display routines. It demonstrates an
approach to keypad handling within an e-meter. */
#define BASIC_KEYPAD_SUPPORT
/*! This switch enables the calling of a custom keypad handler routine. This
allows easy integration of custom code for specific meter designs. */
#undef CUSTOM_KEYPAD_SUPPORT
/*! These are used with the above switches to determine the port bits assigned
to the keys. Only define the buttons which are actually used. */
#define sense_key_1_up() (!(P1IN & BIT6))
#undef sense_key_2_up
#undef sense_key_3_up
#undef sense_key_4_up
/*! These are used to select the features required of the keys. They are bits in
the key_states variable. Only define the features being used. Usually for
each key the "DOWN" option and either the "LONG_DOWN" or "REPEAT_DOWN" option
should be specified. Do not select both the "LONG_DOWN" and "REPEAT_DOWN" for the
same key. */
#define KEY_1_DOWN 0x01
#undef KEY_1_LONG_DOWN //0x02
#define KEY_1_REPEAT_DOWN 0x02
#undef KEY_2_DOWN //0x04
#undef KEY_2_LONG_DOWN //0x08
#undef KEY_2_REPEAT_DOWN //0x08
#undef KEY_3_DOWN //0x10
#undef KEY_3_LONG_DOWN //0x20
#undef KEY_3_REPEAT_DOWN //0x20
#undef KEY_4_DOWN //0x40
#undef KEY_4_LONG_DOWN //0x80
#undef KEY_4_REPEAT_DOWN //0x80
/*! Normally the meter software only calculates the properly scaled values
for voltage, current, etc. as these values are needed. This define
enables additional global parameters, which are regularly updated with
all the metrics gathered by the meter. This is generally less efficient,
as it means calculating things more often than necessary. However, some
may find this easier to use, so it is offered as a choice for the meter
designer. */
#define PRECALCULATED_PARAMETER_SUPPORT
/*! A PWM generator can be used to add dithering to the signals, to expand the
effective resolution of the ADC. */
#undef PWM_DITHERING_SUPPORT
#undef DAC12_DITHERING_SUPPORT
/*! This switch select the use of current dependant phase correction, to allow
the use of non-linear CTs. */
#define DYNAMIC_FIR_SUPPORT
/*! This switch selects where a backup battery's condition is monitored. */
#undef BATTERY_MONITOR_SUPPORT
/*! Target specific definitions for controlling the indicator LEDs */
#if defined(__MSP430__)
/*! This definition specifies the port bit change required to turn on the
normal operation indicator LED, when one is used. If this is defined,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -