📄 peak_alerts.c
字号:
/***************************************************************************
* This code and information is provided "as is" without warranty of any *
* kind, either expressed or implied, including but not limited to the *
* implied warranties of merchantability and/or fitness for a particular *
* purpose. *
* *
* Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved. *
***************************************************************************/
//**************************************************************************
// DESCRIPTION: 71M652x POWER METER - Voltage/Current Peak Alerts.
//
// AUTHOR: MTF
//
// HISTORY: See end of file
//**************************************************************************
// File: PEAK_ALERTS.C
//
#include "options.h"
#if PEAKS
#include "meter.h"
#include "peak_alerts.h"
#define PHASE_B_CALCULATED (PHASE_B_PRESENT || EQUATION == _1ELEMENT_3WIRE)
/*** External functions referenced by this module ***/
/*** External variables referenced by this module ***/
/*** Public functions declared within this module ***/
void Determine_Peaks (void);
/*** Public variables declared within this module ***/
/*** Private functions declared within this module ***/
/*** Private variables declared within this module ***/
//===========================================================================//
void Determine_Peaks (void)
{
Status &= ~( MAXT | MINT | MAXIA | MAXIB | MAXIC | MAXVA | MAXVB | MAXVC );
#if TEMPERATURE
// temperature
if (deltaT > TEMP_MAX) // temp max and min are relative to calibration temp.
Status |= MAXT;
if (deltaT < TEMP_MIN)
Status |= MINT;
#endif
// calculated from most significant 16 bits of CE vsqsum and isqsum
// Therefore, no square root operations are required
if (Irms_A > IPThrshld) // always present
Status |= MAXIA;
#if PHASE_B_CALCULATED
if (Irms_B > IPThrshld)
Status |= MAXIB;
#endif
#if PHASE_C_PRESENT
if (Irms_C > IPThrshld)
Status |= MAXIC;
#endif
// If the voltage is present, test it
if (Vrms_A > VPThrshld) // always present
Status |= MAXVA;
#if PHASE_B_CALCULATED
if (Vrms_B > VPThrshld)
Status |= MAXVB;
#endif
#if EQUATION == _2ELEMENT_4WIRE_DELTA || EQUATION == _3ELEMENT_4WIRE_WYE
if (Vrms_C > VPThrshld)
Status |= MAXVC;
#endif
}
#endif // PEAKS.
/***************************************************************************
* History:
* $Log: peak_alerts.c,v $
* Revision 1.16 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.15 2006/09/09 01:14:32 gmikef
* *** empty log message ***
*
* Revision 1.14 2006/06/08 21:00:03 tvander
* Corrected so it only measures voltages that exist.
*
* Revision 1.13 2006/06/03 00:08:09 tvander
* Fix spurious max. current error.
*
* Revision 1.12 2006/05/18 23:18:53 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/03/06 03:40:12 Michael T. Fischer
* More 6530 prep.
*
* Revision 1.9 2005/11/05 01:58:15 tvander
* Added bits to status register
*
* Revision 1.8 2005/10/08 04:41:26 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.7 2005/09/22 23:45:19 tvander
* Clean build all models and unit tests, updated copyright to be fore Teridian
*
* Revision 1.6 2005/08/30 18:19:12 gmikef
* *** empty log message ***
*
* Revision 1.5 2005/08/10 02:04:04 gmikef
* *** empty log message ***
*
* Revision 1.4 2005/07/01 00:42:36 tvander
* Redesigned the peak detect to use the voltage and current right from the CE, so no square root or RMS calculations are needed.
*
* Revision 1.3 2005/04/30 02:14:44 gmikef
* *** empty log message ***
*
* Revision 1.4 2005/04/27 21:38:09 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. *
***************************************************************************/
/* peak_alerts.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -