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

📄 vphase.c

📁 TDK 6521 SOC 芯片 DEMO程序
💻 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 Phase Calculation.
// 
//  AUTHOR:  MTF
//
//  HISTORY: See end of file
//**************************************************************************
// File: VPHASE.C 
//
#include "options.h"
#include "lcd.h"
#include "meter.h"
#include "vphase.h"

#if VOLTAGE_PHASES
enum { PH_OFFSET = 24 };                // 2.4 x 10.

static void Display_VPhase (int32_t d);

//===========================================================================//
void voltage_phase_lcd (uint8_t select_phase)
{
    int32_t d;
    switch (select_phase)
    {
       case 0:
       case 1:
          d = VPhase_AB;
          break;

       case 2:
       case 3:
          d = VPhase_AC;
          break;
       default: 
          d = 0; 
          break;
    }
    Display_VPhase (d);
}          

static void Display_VPhase (int32_t d)
{
    LCD_Number (d, 6, 0);               // Display upto four digits.
}

//---------------------------------------------------------------------------//
#if EQUATION == _1ELEMENT_2WIRE || EQUATION == _1ELEMENT_3WIRE
void Calc_Voltage_Phase (void)
{
}
#elif EQUATION == _2ELEMENT_3WIRE_DELTA || EQUATION == _2ELEMENT_4WIRE_WYE
void Calc_Voltage_Phase (void)
{
    if ((Status & SAGA) || (* (int16i_t *) &v0sqsum < VThrshld) ||
        (Status & SAGB) || (* (int16i_t *) &v1sqsum < VThrshld))         
    { // The voltages are not valid, so the phases between conductors cannot be calculated.
       VPhase_AB = 0;
    }
    else
    {
       int16_32_t sum_presum;

       sum_presum.l = memget_ce (&sumpre);   
       VPhase_AB = ((3600 *  PH_AtoB) / sum_presum.i[ LO ] + PH_OFFSET + 5) / 10; 
    }
}
#elif EQUATION == _2ELEMENT_4WIRE_DELTA
void Calc_Voltage_Phase (void)
{
    int16_32_t sum_presum;

    if ((Status & SAGA) || (* (int16i_t *) &v0sqsum < VThrshld) ||
        (Status & SAGC) || (* (int16i_t *) &v2sqsum < VThrshld))        
    { // The voltages are not valid, so the phases between conductors cannot be calculated.
       VPhase_AC = 0;
    }
    else
    {
       sum_presum.l = memget_ce (&sumpre);   
       VPhase_AC = ((3600 *  PH_AtoC) / sum_presum.i[ LO ] + PH_OFFSET + PH_OFFSET + 5) / 10;
    }
}
#elif EQUATION == _3ELEMENT_4WIRE_WYE
void Calc_Voltage_Phase (void)
{
    int16_32_t sum_presum;

    if ((Status & SAGA) || (* (int16i_t *) &v0sqsum < VThrshld) ||
        (Status & SAGB) || (* (int16i_t *) &v1sqsum < VThrshld) ||      
        (Status & SAGC) || (* (int16i_t *) &v2sqsum < VThrshld))        
    { // The voltages are not valid, so the phases between conductors cannot be calculated.
       VPhase_AB = 0;
       VPhase_AC = 0;
    }
    else
    {
       sum_presum.l = memget_ce (&sumpre);   
       VPhase_AB = ((3600 *  PH_AtoB) / sum_presum.i[ LO ] + PH_OFFSET + 5) / 10; 
       VPhase_AC = ((3600 *  PH_AtoC) / sum_presum.i[ LO ] + PH_OFFSET + PH_OFFSET + 5) / 10;
    }
}
#endif
#endif // VOLTAGE_PHASES.
/***************************************************************************
 * History:
 * $Log: vphase.c,v $
 * Revision 1.13  2006/09/29 08:58:44  tvander
 * Fixed display routine.
 *
 * Revision 1.12  2006/09/09 01:15:04  gmikef
 * *** empty log message ***
 *
 * Revision 1.11  2006/06/14 02:46:38  tvander
 * Faster LCD display.
 *
 * Revision 1.10  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.9  2006/03/06 03:41:35  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.7  2005/12/21 01:35:28  tvander
 * 6513
 *
 * Revision 1.6  2005/09/22 23:45:21  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.5  2005/08/30 18:21:14  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/08/10 02:04:19  gmikef
 * *** empty log message ***
 *
 * Revision 1.3  2005/04/30 02:15:55  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/04/27 21:38:11  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.         *
 ***************************************************************************/
/* vphase.c */

⌨️ 快捷键说明

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