⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wh.c

📁 TDK 6521 SOC 芯片 DEMO程序
💻 C
📖 第 1 页 / 共 2 页
字号:
    #if PHASE_C_CALCULATED
    wh_sum_net (Whn_C, &wh2);             // Watt hours phase C. 
    #endif // element C
    #endif
    #if NET_METER && WATT_SUMS
    memcpy_xx (Wh, Whn_A, sizeof (Wh));      // Clear out overall total.
    #if PHASE_B_PRESENT
    add8_8 (Wh, Whn_B);                      // Sum up overall total.
    #endif // element B
    #if PHASE_C_CALCULATED
    add8_8 (Wh, Whn_C);                      // Sum up the overall total.
    #endif // element C
    #endif // WATT_SUMS

    // Calculate absolute value metering
    #if ABS_VALUE
    #if PHASE_A_PRESENT
    wh_sum_abs (Wha_A, &wh0);             // Watt hours phase A. 
    #endif // element A
    #if PHASE_B_CALCULATED
    wh_sum_abs (Wha_B, &wh1);             // Watt hours phase B. 
    #endif // element B
    #if PHASE_C_CALCULATED
    wh_sum_abs (Wha_C, &wh2);             // Watt hours phase C. 
    #endif // element C
    #if !WATT_SUMS
    if (i0sqsum > i1sqsum)
    {
        wh_sum_abs (Wha, &wh0);        // Watt hours phase A. 
    }
    else
    {
        wh_sum_abs (Wha, &wh1);        // Watt hours phase A. 
    }
    #else
    memcpy_xx (Wha, Wha_A, sizeof (Wha));      // Clear out overall total.
    #if PHASE_B_PRESENT
    add8_8 (Wha, Wha_B);                      // Sum up overall total.
    #endif // element B
    #if PHASE_C_CALCULATED
    add8_8 (Wha, Wha_C);                      // Sum up the overall total.
    #endif // element C
    #endif // WATT_SUMS
    #endif

    #if IMPORT
    #if PHASE_A_PRESENT
    wh_sum_import (Whi_A, &wh0);         // Watt hours phase A. 
    #endif // element A
    #if PHASE_B_CALCULATED
    wh_sum_import (Whi_B, &wh1);         // Watt hours phase B. 
    #endif // element B
    #if PHASE_C_CALCULATED
    wh_sum_import (Whi_C, &wh2);         // Watt hours phase C. 
    #endif // element C

    #if !WATT_SUMS 
    if (i0sqsum > i1sqsum)
    {
        wh_sum_import (Whi, &wh0);        // Watt hours phase A. 
    }
    else
    {
        wh_sum_import (Whi, &wh1);        // Watt hours phase A. 
    }
    #else
    memcpy_xx (Whi, Whi_A, sizeof (Whi_A)); // Clear out the total imports. 
    #if PHASE_B_PRESENT
    add8_8 (Whi, Whi_B);                    // Sum up the total imports.
    #endif // element B
    #if PHASE_C_CALCULATED
    add8_8 (Whi, Whi_C);                    // Sum up the total imports.
    #endif // element C
    #endif // WATT_SUMS
    #endif // IMPORT

    #if EXPORT
    #if PHASE_A_PRESENT
    wh_sum_export (Whe_A, &wh0);         // Watt hours phase A. 
    #endif // element A
    #if PHASE_B_CALCULATED
    wh_sum_export (Whe_B, &wh1);         // Watt hours phase B. 
    #endif // element B
    #if PHASE_C_CALCULATED
    wh_sum_export (Whe_C, &wh2);         // Watt hours phase C. 
    #endif // element C
    #if !WATT_SUMS 
    if (i0sqsum > i1sqsum)
    {
        wh_sum_export (Whe, &wh0);        // Watt hours phase A. 
    }
    else
    {
        wh_sum_export (Whe, &wh1);        // Watt hours phase A. 
    }
    #else
    memcpy_xx (Whe, Whe_A, sizeof (Whe_A)); // Clear out the total exports.
    #if PHASE_B_PRESENT
    add8_8 (Whe, Whe_B);                    // Sum up the total exports.
    #endif // element B
    #if PHASE_C_CALCULATED
    add8_8 (Whe, Whe_C); 
    #endif // element C
    #endif // WATT_SUMS
    #endif // EXPORT
}

#endif // equation

/***************************************************************************
 * History
 * $Log: wh.c,v $
 * Revision 1.29  2006/10/13 00:51:12  tvander
 * Removed compile options for 6530, 6515;
 * renamed 6511 and 6513 to trace11 and trace13;
 * Binary verified unchanged from previous version.
 *
 * Revision 1.28  2006/10/11 20:46:48  tvander
 * Fixed phase B accumulation and measurement for equation 1.
 * Phase B is not part of the equation, but is very useful for calibration.
 *
 * Revision 1.27  2006/10/03 00:33:59  tvander
 * Turned off WATT_SUMS and VAR_SUMS, so that maximum of elements is calculated instead of sums.  Assured that Wh exports and VARh imports and exports both have a "maximum of A and B" behavior when WATT_SUMS and VAR_SUMS are turned off.
 *
 * Revision 1.26  2006/09/29 09:00:05  tvander
 * Wh conversion constants rounded down to avoid upsetting regulatory personnel.
 * The idea is that the electricity customer should not be charged for electricity they did not use.
 *
 * Revision 1.25  2006/09/14 00:41:09  tvander
 * Spaces for tabs (pretty printing)
 *
 * Revision 1.24  2006/09/13 21:39:10  gmikef
 * *** empty log message ***
 *
 * Revision 1.23  2006/09/12 02:45:21  gmikef
 * *** empty log message ***
 *
 * Revision 1.22  2006/09/10 00:28:48  Michael T. Fischer
 * First version to support DGM0915 LCD.
 *
 * Revision 1.21  2006/09/09 02:29:47  gmikef
 * *** empty log message ***
 *
 * Revision 1.20  2006/09/09 01:15:06  gmikef
 * *** empty log message ***
 *
 * Revision 1.19  2006/09/08 07:38:05  Michael T. Fischer
 * *** empty log message ***
 *
 * Revision 1.18  2006/08/04 17:24:38  tvander
 * Modified comment to have correct value.
 *
 * Revision 1.17  2006/07/07 01:07:06  tvander
 * Made the brownout LCD format logic non-reentrant, and conditional on a new
 * compile flag, AUTOSLEEP
 *
 * Revision 1.16  2006/06/14 02:46:38  tvander
 * Faster LCD display.
 *
 * Revision 1.15  2006/06/06 05:15:21  tvander
 * clean build
 *
 * Revision 1.14  2006/05/30 17:19:33  tvander
 * Fixed Wha dependency; else-if was misplaced.
 *
 * Revision 1.13  2006/05/25 03:32:50  tvander
 * Renamed Wh variables so it's easier to switch different definitions of watts into the nonvolatile revenue registers.
 *
 * Revision 1.12  2006/05/18 23:18:54  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.11  2006/04/27 00:06:57  tvander
 * Added tamper resistance, mostly to wh.c; Added a calibration signal to rtc.c
 *
 * Revision 1.10  2006/04/25 01:09:56  tvander
 * Integrated improved RTC.  Compensates for time off, has default constant
 * compensation.  Computes true hours of operation.
 *
 * Revision 1.9  2006/04/12 00:27:50  tvander
 * Debugged compilation with equations 3 and 4, on 6513
 *
 * Revision 1.8  2006/03/06 03:41:51  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.7  2006/03/03 11:31:05  Michael T. Fischer
 * Prep for 6530 LCD, etc.
 *
 * Revision 1.6  2006/02/10 03:13:21  tvander
 * Fixed VAh calculations and display, date display
 *
 * Revision 1.5  2006/01/10 04:08:38  gmikef
 * Added PDATA support for CE Outputs.
 *
 * Revision 1.4  2006/01/04 04:47:55  gmikef
 * Switched RMS and VA calculations to use floating point. (and Calibration).
 *
 * Revision 1.2  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.1  2005/10/08 04:41:29  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.
 *
 *
 * Abstracted from accumulate.c
 *
 * Revision 1.9  2005/09/22 23:45:13  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.8  2005/09/11 00:34:04  tvander
 * Clean compiles
 *
 * Revision 1.7  2005/08/30 18:14:00  gmikef
 * *** empty log message ***
 *
 * Revision 1.6  2005/06/18 00:58:12  tvander
 * Refactored accumulate_energy, squashed a bunch of bugs.
 *
 * Revision 1.5  2005/06/17 22:54:44  tvander
 * Separated imports and exports.
 * Some imports and exports were not being updated.
 *
 * Revision 1.4  2005/06/14 00:14:42  tvander
 * Error in accumulation- it was checking a pointer for its sign.
 *
 * Revision 1.3  2005/04/30 02:12:59  gmikef
 * *** empty log message ***
 *
 * Revision 1.6  2005/04/29 00:01:58  gmikef
 * *** empty log message ***
 *
 * Revision 1.5  2005/04/27 21:38:06  gmikef
 * *** empty log message ***
 *
 * 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.         *
 ***************************************************************************/
/* wh.c */
#endif // WATT_ELEMENT.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -