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

📄 meter.c

📁 TDK 6521 SOC 芯片 DEMO程序
💻 C
📖 第 1 页 / 共 4 页
字号:
          select = M_WH;
       case M_WH:
       #if EXPORT
       case M_WHE:
       #endif
          wh_lcd   (LcdSrc[((select - M_WH) * 4) + phase]);
          break;
       #endif

       #if VAR_ELEMENT
       #if IMPORT
       case M_VARH:
       #endif
       #if EXPORT
       case M_VARHE:
       #endif
          varh_lcd (LcdSrc[((select - M_WH) * 4) + phase]);
          break;
       #endif

       #if VA_ELEMENT
       #if IMPORT
       case M_VAH:
       #endif
          vah_lcd  (LcdSrc[((select - M_WH) * 4) + phase]);
          break;
       #endif

       #if RMS_VALUES
       case M_IRMS:
      // display Irms
      if (phase != 2) phase = 1;
          rms_i_lcd (phase);
          break;

       case M_VRMS:
      // display Irms
      if (phase != 2) phase = 1;
          rms_v_lcd (phase);
          break;
       #endif // RMS values

       #if  BATTERY_TEST
       case M_BATTEST:  // Show last measured battery voltage.
          battest_lcd ();
          select_phase += 1; // count appearances
          if (phase > 20) // don't use up the battery
          {
            select_phase = 0;
            #if SCROLL_METER
            select_total = alcdNext[0];
            #else
            select_total = M_WH;
            #endif
          }
          break;                
       #endif

       #if DEMAND   
       #if WATT_ELEMENT
       case M_WATT:
          w_lcd   (*LcdSrcP[((select - M_WATT) * NUM_SUMS) + phase]);
          break;
       #endif

       #if VAR_ELEMENT
       case M_VAR:
          var_lcd (*LcdSrcP[((select - M_WATT) * NUM_SUMS) + phase]);          
          break;
       #endif

       #if VA_ELEMENT
       case M_VA:
          va_lcd  (*LcdSrcP[((select - M_WATT) * NUM_SUMS) + phase]);          
          break;
       #endif
       #endif // DEMAND.
    }

    #if  MODE_DISPLAY
    if (show_mode)
        LCD_Mode (select);
    #endif
}

/***************************************************************************
 * History:
 * $Log: meter.c,v $
 * Revision 1.78  2006/10/13 00:51:10  tvander
 * Removed compile options for 6530, 6515;
 * renamed 6511 and 6513 to trace11 and trace13;
 * Binary verified unchanged from previous version.
 *
 * Revision 1.77  2006/10/11 20:46:47  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.76  2006/03/10 00:05:57  tvander
 * Equation 1's creep logic is fixed.
 *
 * Revision 1.75  2006/10/06 01:41:21  tvander
 * The frequency -determination routine is invoked if the RTC is locked to the line.
 * The DEG_SCALE equation now takes a single number from ce651x.h or ce652x.h
 *
 * Revision 1.74  2006/09/29 08:57:04  tvander
 * Simplified default display set-up.
 * Simplified creep (creep doesn't need to clear variables, RMS-calculate already
 * does that!)
 * Fixed m0 so it defaults to m3 (power)
 *
 * Revision 1.73  2006/09/18 19:30:28  tvander
 * LCD display routine defaults to display watt hours.
 *
 * Revision 1.72  2006/09/15 16:49:21  tvander
 * Fixed heart beat.
 *
 * Revision 1.71  2006/09/14 00:38:57  tvander
 * vasum defined in the correct case
 *
 * Revision 1.70  2006/09/13 21:38:54  gmikef
 * *** empty log message ***
 *
 * Revision 1.69  2006/09/13 01:38:18  gmikef
 * *** empty log message ***
 *
 * Revision 1.68  2006/09/12 02:44:55  gmikef
 * *** empty log message ***
 *
 * Revision 1.67  2006/09/10 00:28:09  Michael T. Fischer
 * First version to support DGM0915 LCD.
 *
 * Revision 1.66  2006/09/09 02:29:33  gmikef
 * *** empty log message ***
 *
 * Revision 1.65  2006/09/09 01:43:27  gmikef
 * Split out scrolling function.
 *
 * Revision 1.64  2006/09/09 01:14:14  gmikef
 * *** empty log message ***
 *
 * Revision 1.63  2006/09/08 07:36:46  Michael T. Fischer
 * *** empty log message ***
 *
 * Revision 1.62  2006/08/19 01:36:50  tvander
 * Fixed 6520's creep for equation 1
 *
 * Revision 1.61  2006/08/18 23:24:49  tvander
 * Fixed creep logic so it compiles in all equations (working is another issue...)
 *
 * Revision 1.60  2006/08/18 00:35:24  tvander
 * Added small current calculations for all the missing equations.
 *
 * Revision 1.59  2006/07/22 01:11:46  tvander
 * Changed a constant array to live in code space, saving room in the set-up
 * code.
 *
 * Revision 1.58  2006/07/17 18:03:44  tvander
 * Added call to read real time clock.
 * Added comments about flag update routine.
 *
 * Revision 1.57  2006/07/13 22:33:20  tvander
 * Fixed anomalies with counting.
 *
 * Revision 1.56  2006/07/13 18:43:40  tvander
 * If watchdog is reset continually in main loop, and doesn't depend on periodic interrupts, then the code to fix up the CE isn't needed either.
 *
 * Revision 1.55  2006/07/08 01:53:11  tvander
 * Code that reinitializes the CE conflicts with the CLI command CE0
 *
 * Revision 1.54  2006/07/07 22:18:44  tvander
 * Saves brownout cache data.
 *
 * Revision 1.53  2006/07/07 01:04:58  tvander
 * Added code to restart the CE
 *
 * Revision 1.52  2006/06/24 05:29:09  tvander
 * Clean build
 *
 * Revision 1.51  2006/06/15 20:05:12  tvander
 * Limits the range written to gain_adj, a 16-bit value, by the meter's temperature
 * compensation.
 *
 * Revision 1.50  2006/06/15 16:54:50  tvander
 * Removed reset of meter_had_power from meter.c, and moved to ce.c
 * Moved readying of eeprom into eeprom driver, from meter.c
 *
 * Revision 1.49  2006/06/14 02:46:00  tvander
 * Faster LCD display.
 * Includes commented-out test code to verify that the main loop completes
 * within an accumulation interval, (used to test 1/8 speed MPU operation).
 *
 * Revision 1.48  2006/06/12 20:28:35  tvander
 * Fixed so that an invalid number ot an M command causes an error message, and
 * does not change the display.
 *
 * Revision 1.47  2006/06/09 22:40:54  tvander
 * Redesigned creep to operate on voltages as well as current, and to account
 * correctly for the equations.
 *
 * Revision 1.46  2006/06/09 00:22:46  tvander
 * Removed conditional compilation flags from the adc gain compensation routine.
 * Fixed a spurious pulse problem caused by CREEP.
 *
 * Revision 1.45  2006/06/08 20:58:49  tvander
 * Emergency code, that keeps meter running when interrupts are disabled, should reenable interrupts.
 *
 * Revision 1.44  2006/06/06 05:15:20  tvander
 * clean build
 *
 * Revision 1.43  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.42  2006/05/20 00:29:55  tvander
 * Responds better to impossible M commands.
 *
 * Revision 1.41  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.40  2006/04/28 23:36:04  tvander
 * Commented the code that recovers from a missed interrupt.
 * Also placed the RTC first, so that its compensation is
 * more accurate (minor effect, but why not improve it?)
 *
 * Revision 1.39  2006/04/27 00:06:57  tvander
 * Added tamper resistance, mostly to wh.c; Added a calibration signal to rtc.c
 *
 * Revision 1.38  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.37  2006/04/12 00:27:49  tvander
 * Debugged compilation with equations 3 and 4, on 6513
 *
 * Revision 1.36  2006/03/31 23:40:09  tvander
 * IMAX2 modification
 *
 * Revision 1.35  2006/03/17 00:41:40  tvander
 * First cut at IMAX2
 *
 * Revision 1.34  2006/03/08 20:24:05  tvander
 * Changed so that rtc compensation is not called if no RTC function is present.
 *
 * Revision 1.33  2006/03/08 00:08:02  tvander
 * Multiplexed interrupts are in io65xx.c
 * Added stubbed interrupt to io65xx.c
 * Clean build
 *
 * Revision 1.32  2006/03/06 03:39:27  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.31  2006/02/11 02:09:25  tvander
 * Clean build:
 * Fixed up 6513.uv2
 * Deleted landis & gyr build because it's proprietary.
 *
 * Revision 1.30  2006/02/10 03:13:20  tvander
 * Fixed VAh calculations and display, date display
 *
 * Revision 1.29  2006/02/10 00:49:45  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.28  2006/02/08 03:43:26  tvander
 * Made "import" the default power measurement mode, rather than net-metering
 *
 * Revision 1.27  2006/01/25 01:05:13  tvander
 * Floating point temperature calibration
 *
 * Revision 1.26  2006/01/11 00:51:36  gmikef
 * *** empty log message ***
 *
 * Revision 1.25  2006/01/10 04:07:15  gmikef
 * Added PDATA support for CE Outputs.
 *
 * Revision 1.24  2006/01/04 04:47:52  gmikef
 * Switched RMS and VA calculations to use floating point. (and Calibration).
 *
 * Revision 1.23  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.21  2005/12/21 01:35:28  tvander
 * 6513
 *
 * Revision 1.20  2005/11/10 22:51:33  tvander
 * 6520 has battery mode commands.
 * Brownout always has decimal point 7.
 * LCD Mode always has decimal points 7 and 6.
 * Sag detection is disabled.
 *
 * Revision 1.19  2005/11/09 02:21:16  tvander
 * Added code to display watt hours from brownout mode.
 * Added code to clear EEPROM (lapie command "EEE")
 *
 * Revision 1.18  2005/10/18 02:17:11  tvander
 * Access CLI in brownout by pressing reset.
 * Debugged serial 1 usage from CLI.
 * Implemented scrolling display as M17
 *
 * Revision 1.17  2005/10/12 23:00:06  tvander
 * Includes demonstratable mission mode, brownout, LCD and sleep modes
 *
 * Revision 1.16  2005/10/08 04:41:24  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.15  2005/10/06 20:49:54  tvander
 * Made the parsing a little more accurate.
 *
 * Revision 1.14  2005/09/28 20:54:02  tvander
 * V/I phase displays for all phases,
 * main edge count displays for both types,
 * rewrote setup from defaults to group related functions.
 *
 * Revision 1.13  2005/09/28 00:53:34  tvander
 * Fixed freq and temperature displays
 *
 * Revision 1.12  2005/09/27 01:27:04  tvander
 * V/I phase works
 *
 * Revision 1.11  2005/09/22 23:45:17  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.10  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.9  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.8  2005/09/11 00:34:05  tvander
 * Clean compiles
 *
 * Revision 1.7  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.6  2005/09/03 02:15:13  tvander
 * Added exports...
 *
 * Revision 1.5  2005/09/02 19:02:49  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/09/01 02:06:23  gmikef
 * Cleaned up the builds.
 *
 * Revision 1.3  2005/08/31 22:41:08  tvander
 * Incorporated kwh calculations, because the table's row-order has to be coordinated with the logic in meter_lcd()
 *
 * Revision 1.2  2005/08/30 18:18:00  gmikef
 * *** empty log message ***
 *
 * Revision 1.1  2005/08/28 02:34:31  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.         *
 ***************************************************************************/

⌨️ 快捷键说明

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