?? meter.h
字號:
#define VARhi_C Totals.Sums.T_VARhi_C.a
#define VAh Totals.Sums.T_VAh.a
#define VAh_A Totals.Sums.T_VAh_A.a
#define VAh_B Totals.Sums.T_VAh_B.a
#define VAh_C Totals.Sums.T_VAh_C.a
// Exports
#define Whe Totals.Sums.T_Whe.a
#define Whe_A Totals.Sums.T_Whe_A.a
#define Whe_B Totals.Sums.T_Whe_B.a
#define Whe_C Totals.Sums.T_Whe_C.a
#define VARhe Totals.Sums.T_VARhe.a
#define VARhe_A Totals.Sums.T_VARhe_A.a
#define VARhe_B Totals.Sums.T_VARhe_B.a
#define VARhe_C Totals.Sums.T_VARhe_C.a
// These are used for phased calibration and net metering
#define Whn Totals.Sums.T_Whn.a
#define Whn_A Totals.Sums.T_Whn_A.a
#define Whn_B Totals.Sums.T_Whn_B.a
#define Whn_C Totals.Sums.T_Whn_C.a
#define VARh Totals.Sums.T_VARh.a
#define VARh_A Totals.Sums.T_VARh_A.a
#define VARh_B Totals.Sums.T_VARh_B.a
#define VARh_C Totals.Sums.T_VARh_C.a
// This ought to be cleared when )1=2
#define MainEdgeCount Totals.Sums.T_MainEdgeCount
#define main_edge_cnt_nom Totals.T_main_edge_cnt_nom
// for counting pulses
#define pulse_count_w Totals.Sums.T_pulse_count_w.a
#define pulse_count_r Totals.Sums.T_pulse_count_r.a
#define pulse_count_3 Totals.Sums.T_pulse_count_3.a
#define pulse_count_4 Totals.Sums.T_pulse_count_4.a
// Nonvolatile fields needed for timekeeping
#define OperatingSeconds Totals.Acc.T_OperatingSeconds
#define Rtc_Time_Date Totals.Acc.T_Rtc_Time_Date
#define RTC_COPY Totals.Acc.T_Rtc_Time_Date
#define trim_value Totals.Acc.T_trim_value
#define trim_count Totals.Acc.T_trim_count
#define second_count Totals.Acc.T_second_count
#define Rtc_Sec Totals.Acc.T_Rtc_Time_Date.Sec
#define Rtc_Min Totals.Acc.T_Rtc_Time_Date.Min
#define Rtc_Hour Totals.Acc.T_Rtc_Time_Date.Hour
#define Rtc_Day Totals.Acc.T_Rtc_Time_Date.Day
#define Rtc_Date Totals.Acc.T_Rtc_Time_Date.Date
#define Rtc_Month Totals.Acc.T_Rtc_Time_Date.Month
#define Rtc_Year Totals.Acc.T_Rtc_Time_Date.Year
#define brownout_cache Totals.Acc.T_brownout_cache
#define brownout_cache_mode Totals.Acc.T_brownout_cache_mode
#define brownout_cache_valid Totals.Acc.T_brownout_cache_valid
#define brownout_cache_offset ((uint8x_t*)&brownout_cache - (uint8x_t*)&Wh)
#define brownout_cache_len 6 // cache, valid, and mode
#define CalibrationCount Totals.Acc.T_CalibrationCount
// route calculations into the revenue registers
#if ABS_VALUE
// Use absolute value sum as revenue registers (more tamper resistant)
#define Wha Totals.Acc.T_Whr.a
#define Wha_A Totals.Acc.T_Whr_A.a
#define Wha_B Totals.Acc.T_Whr_B.a
#define Wha_C Totals.Acc.T_Whr_C.a
//#elif ???
// Use your choice as revenue registers here...
#elif VA_ELEMENT // selectable from options.h
// Use volt-amps as revenue registers (probably the best technical choice)
#undef VAh
#undef VAh_A
#undef VAh_B
#undef VAh_C
#define VAh Totals.Acc.T_Whr.a
#define VAh_A Totals.Acc.T_Whr_A.a
#define VAh_B Totals.Acc.T_Whr_B.a
#define VAh_C Totals.Acc.T_Whr_C.a
#else // if neither abs-value or va_element
// Use watt-hour imports as revenue registers (a common choice)
#undef Whi
#undef Whi_A
#undef Whi_B
#undef Whi_C
#define Whi Totals.Acc.T_Whr.a
#define Whi_A Totals.Acc.T_Whr_A.a
#define Whi_B Totals.Acc.T_Whr_B.a
#define Whi_C Totals.Acc.T_Whr_C.a
#endif
// generic names for the default revenue registers
#define Wh Totals.Acc.T_Whr.a
#define Wh_A Totals.Acc.T_Whr_A.a
#define Wh_B Totals.Acc.T_Whr_B.a
#define Wh_C Totals.Acc.T_Whr_C.a
// Used to select the LCD display in meter totals, also the M command in CLI
#define M_NONE 0
#define M_TEMP 1 // enable TEMPERATURE
#define M_FREQ 2 // enable FREQUENCY
#define M_WH 3 // enable WH_ELEMENT (however it's calculated...)
#define M_WHE 4 // enable WH_ELEMENT, and EXPORT
#define M_VARH 5 // enable VARH_ELEMENT
#define M_VARHE 6 // enable VARH_ELEMENT, and EXPORT
#define M_VAH 7 // enable VAH_ELEMENT
#define M_HOURS 8 // enable OPERATING_TIME
#define M_TIME 9 // enable REAL_TIME_DATE
#define M_DATE 10 // "
// M_PF and M_VI_ANGLE have the same number because
// usually one wants power factor or V/I angle, but not both)
#define M_PF 11 // enable POWER_FACTOR
#define M_VI_ANGLE 11 // enable PHASE_ANGLES
#if POWER_FACTOR && PHASE_ANGLES
#error Power factor and V/I phase angles are both enabled and
#error use the same mode number
#endif
#define M_VPHASE 12 // enable VOLTAGE_PHASES
#define M_EDGE_CNT 13 // counts of edges enable MAIN_EDGE_COUNT
#define M_PULSE 14 // counts of pulses enable PULSE_CNT
#define M_IRMS 15 // measure current enable RMS_VALUES
#define M_VRMS 16 // measure voltage. "
#define M_BATTEST 17 // enable BATTERY_TEST
#define M_WATT 18 // enable WATTs.
#define M_VAR 19 // enable VARs.
#define M_VA 20 // enable VAs.
#define M_NULL 255
#if PHASE_C_PRESENT
#define MAX_RMS 3
#define MAX_PHASE 4
#elif PHASE_B_PRESENT
#define MAX_RMS 2
#define MAX_PHASE 3
#elif PHASE_A_PRESENT
#define MAX_RMS 1
#define MAX_PHASE 1
#endif
#define MAX_OUTPUT 9
#define MAX_TOTAL 18
#define MAX_SCROLL (MAX_TOTAL)
#define MAX_PULSE 4
#define MAX_INTERVAL 1800 // 30 minutes
#define MAX_EDGE_TYPE 2
//============================================================================//
#if CLI
void cmd_meter (void);
#endif
void temperature_lcd (void);
void meter_initialize (void);
void meter_run (void);
void meter_lcd (void); // Meter redisplay last selection.
#if AUTOSLEEP
void meter_brownout_lcd (void);
#endif
void meter_totals (uint8_t select, uint8_t phase);
void scroll_meter (void);
#if FLAG
void Update_register (void); // copy flag data to registers
#endif
//----------------------------------------------------------------------------//
extern const uint8_t code alcdNext[];
extern bool beat;
extern bool ce_totals_ready; // Enables update only if changed.
// volt-amps, scaled like w0sum
extern int32_t pdata vasum, va0sum, va1sum, va2sum;
#if FLAG
extern bool register_available;
extern bool register_locked;
extern bool register_write;
extern struct Totals_t xdata Registers;
extern struct Totals_t xdata Totals;
#else // No flag protocol.
extern struct Totals_t xdata Totals;
#endif
// indicates that power supply was powered
extern volatile bool meter_had_power;
/***************************************************************************
* History:
* $Log: meter.h,v $
* Revision 1.47 2006/03/10 00:06:26 tvander
* Remove unused pulse-counting variables.
*
* Revision 1.46 2006/10/06 01:42:28 tvander
* The calibration count is moved into the nonvolatile accumulators.
* A dummy was left so that the addresses in between are unchanged.
*
* Revision 1.45 2006/10/03 00:35:38 tvander
* Moved main_edge_cnt_nom earlier in the data structures, before deltaT, the start of the 32-bit indexing. In that way, it does not offset the indexing by one byte, a clear error.
*
* Revision 1.44 2006/09/27 01:35:56 tvander
* Removed CFG_BATTERY from the software configuration
*
* Revision 1.43 2006/09/14 00:39:25 tvander
* defines vasum
*
* Revision 1.42 2006/09/12 02:45:02 gmikef
* *** empty log message ***
*
* Revision 1.41 2006/09/09 02:29:40 gmikef
* *** empty log message ***
*
* Revision 1.40 2006/09/09 01:43:36 gmikef
* Split out scrolling function.
*
* Revision 1.37 2006/07/27 00:58:01 tvander
* Fixed code to lock RTC to line frequency. Added a single byte to the shared
* data structure.
*
* Revision 1.36 2006/07/25 00:30:02 tvander
* Main edge count needs to be signed.
*
* Revision 1.35 2006/07/07 22:18:44 tvander
* Saves brownout cache data.
*
* Revision 1.34 2006/07/07 01:05:45 tvander
* Added a battery-present configuration bit to r_Parms.T_Config
*
* Revision 1.33 2006/06/09 22:40:55 tvander
* Redesigned creep to operate on voltages as well as current, and to account
* correctly for the equations.
*
* Revision 1.32 2006/06/08 20:59:18 tvander
* Added sum variables for Wh and VARh net-metering
*
* Revision 1.31 2006/06/06 05:15:20 tvander
* clean build
*
* Revision 1.30 2006/05/25 03:31:45 tvander
* Renamed variables so nonvolatile variables can be switched to other definitions
* of watt-hours (e.g. from absolute value to volt-amps or imports)
* (meter.c, meter.h, pulse_src.c)
* FIxed power factors so they zero correctly.
* Fixed RMS to work with different accumulation interval.
*
* Revision 1.29 2006/05/18 23:18:52 tvander
* 16K and 32K
* First cut at new requirements.
* 32K 6521 is grossly tested.
* All others have a clean compile with C51 8.02
*
* Revision 1.28 2006/04/27 00:06:57 tvander
* Added tamper resistance, mostly to wh.c; Added a calibration signal to rtc.c
*
* Revision 1.27 2006/04/25 01:09:55 tvander
* Integrated improved RTC. Compensates for time off, has default constant
* compensation. Computes true hours of operation.
*
* Revision 1.26 2006/04/19 01:16:41 tvander
* Now defines where rtc.c puts its data.
*
* Revision 1.25 2006/04/12 00:27:49 tvander
* Debugged compilation with equations 3 and 4, on 6513
*
* Revision 1.24 2006/03/31 23:40:09 tvander
* IMAX2 modification
*
* Revision 1.23 2006/03/17 00:41:17 tvander
* Reformatted Parameters_t to fit in IMAX2 stuff
*
* Revision 1.22 2006/03/06 03:39:43 Michael T. Fischer
* More 6530 prep.
*
* Revision 1.21 2006/02/10 00:49:46 tvander
* Added )1=2, count of accumulation intervals, reduced RAM usage by
* making optional phase c, net metering, and pulse counts.
* rearranged RAM so these things change in some reasonable way when accessed
* by ).
*
* Revision 1.20 2006/02/08 03:43:27 tvander
* Made "import" the default power measurement mode, rather than net-metering
*
* Revision 1.19 2006/01/25 01:05:14 tvander
* Floating point temperature calibration
*
* Revision 1.18 2006/01/10 04:07:34 gmikef
* Added PDATA support for CE Outputs.
*
* Revision 1.17 2006/01/04 04:47:52 gmikef
* Switched RMS and VA calculations to use floating point. (and Calibration).
*
* Revision 1.16 2005/12/23 01:27:46 tvander
* Meter.c would not compile for 6513 because a table was wrong.
* A few style issues.
*
* Revision 1.14 2005/12/21 01:35:28 tvander
* 6513
*
* Revision 1.13 2005/11/09 02:21:17 tvander
* Added code to display watt hours from brownout mode.
* Added code to clear EEPROM (lapie command "EEE")
*
* Revision 1.12 2005/11/05 01:58:15 tvander
* Added bits to status register
*
* Revision 1.11 2005/10/08 04:41:25 tvander
* Fixed priority inversion.
* Rewrote watchdog to work in brownout, but of course it doesn't work.
* Watchdog can now be defeated by clearing watchdog option to 0.
* Reorganized watt hour modules (at last!).
* Disabled reading of STATUS in 6521_cli because the CE's status is always SAG.
* Tested with 6521_CLI; measurements seem to work.
* Fixed other builds.
*
* Revision 1.10 2005/10/06 20:49:54 tvander
* Made the parsing a little more accurate.
*
* Revision 1.9 2005/09/27 01:27:05 tvander
* V/I phase works
*
* Revision 1.8 2005/09/22 23:45:17 tvander
* Clean build all models and unit tests, updated copyright to be fore Teridian
*
* Revision 1.7 2005/09/13 19:26:55 tvander
* Release 6521 CLI version for early customers.
* RMS works.
* Accumulation interval to 1 second.
* Wrate slowed to 3.2 Kh/pulse for new accumulation interval.
* Pulse outputs inverted, so they start dark.
* LCD density increased from 1/3 bias to 1/2 bias, for demo PCB.
* VAh code is included, but untested.
*
* Revision 1.6 2005/09/12 07:47:30 tvander
* Power measurement is stable, with no creep.
* VARh measurement is stable, with no creep.
* Pulse sources work.
* Full access to MPU variables.
* Rolled date.
* Clock software works.
*
* Revision 1.5 2005/09/08 00:31:43 tvander
* Fixed: Lost data due to overwrite of Ithrshld, xfer busy never runs,
* unavailable second phase, cosmetic issues with status. Updated
* date.
*
* Revision 1.4 2005/09/01 02:06:45 gmikef
* Cleaned up the builds.
*
* Revision 1.3 2005/08/31 05:57:43 gmikef
* First version w/ LAPIE interface.
*
* Revision 1.2 2005/08/30 18:18:18 gmikef
* *** empty log message ***
*
* Revision 1.1 2005/08/28 02:34:59 gmikef
* *** empty log message ***
*
* 2003 NOVEMBER 21; First Version.
*
* Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved. *
* this program is fully protected by the United States copyright *
* laws and is the property of Teridian Semiconductor Corporation. *
***************************************************************************/
#endif /* meter.h */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -