亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? emeter.c

?? MSP430電能測量程序,用的是電力線載波通訊.即PLC
?? C
?? 第 1 頁 / 共 2 頁
字號:
//#define WFS

/** \file 
  * ESP430CE1 Application Program Example
  *
  * This file shows exemplarily the usage of the ESP430CE1 module for
  * a single-phase emeter with two current sensors (one shunt and one
  * current transformer).
  *
  * \author Volker Rzehak
  * \date   04/08/2003
  *
  * \Modified Stefan Schauer
  * \date   04/29/2003
    Changes:
     - added Temp. calibration Parameters
     - fixed bouncing of Idle Key
  */
//====================================================================

#include "device.h"
#include "emeter.h"
#include "parameter.h"
#include "display.h"
#include "calibration.h"
#include "emeter-toolkit.h"


#if __VER__ < 200
sfrb    SD16CONF0          = 0xB7;
sfrb    SD16CONF1          = 0xBF;
#else
#define SD16CONF0_                (0xB7)  
DEFC(   SD16CONF0               , SD16CONF0_)
#define SD16CONF1_                (0xBF)  
DEFC(   SD16CONF1               , SD16CONF1_)
#endif

// const and var definition
#define TIMEOUT	0xFFFF		// Huge timeout
//#define TIMEOUT	0x0FFF			// Shorter timeout
unsigned char ZXLDFGedge = 0;

/// Saves firmware version during initialization.
unsigned int firmware_version; 
/// Cumulated active energy.
float total_energy;
/// Last temperature measurement result.
unsigned int temperature;

// buffer to save RET values
//unsigned int savedRET[(RET31_ - RET0_)/2];

//union tu_ulong_word intlevel = {pSET_INTRPTLEVL_LO, pSET_INTRPTLEVL_HI};
struct ts_parameters s_parameters;

#ifdef __IAR_SYSTEMS_ICC__
#if __VER__ < 200
#pragma memory=constseg(INFOA)
#else
#pragma constseg=INFOA
#endif
#endif

#ifdef __CROSSWORKS__
 #pragma constseg("INFOA")
#endif

const struct ts_parameters s_parameters_flash = 
           {
              defVRatio,
              defIRatio,
              defEnergieRatio,
              defSET_PHASECORR1,
              defSET_PHASECORR2,
              defSET_V1OFFSET,
              defSET_I1OFFSET,
              defSET_I2OFFSET,
              defSET_STARTCURR_INT,
              defSET_STARTCURR_FRAC,
              {defSET_INTRPTLEVL_LO,
               defSET_INTRPTLEVL_HI},
              def_togglelevel,
              defTempGain,
              defTempOffset
           };

const long SerialNumber_flash = 0xDEAFC0C0;	// System serial number stored in FLASH

#ifdef __IAR_SYSTEMS_ICC__
#if __VER__ < 200
#pragma memory=default
#else
#pragma constseg=default
#endif
#endif

#ifdef __CROSSWORKS__
#pragma dataseg(default)
#endif
	
unsigned int CalCyclCnt = 0;     // Register for Cycle calculation of Calibration
unsigned int wfs1;
unsigned int wfs2;
unsigned int wfs3;
union tu_long_word energy;
union ts_long_word tempenergy;

signed long sumenergy= 0;
signed long maxenergy= 0;

void display_error(void) 
{;}


//====================================================================
/**
  * Analog front-end initialization routine.
  *
  * Configures the sigma-delta ADC module as analog front-end for
  * a tamper-resistant meter using a current transformer and a
  * shunt as current sensors (see configuration of channel 0 and 1).
  */
void init_analog_front_end(void)
{
/**
  * First it makes sure that the Embedded Signal Processing is 
  * disabled, otherwise it wouldn't be possible to modify the 
  * SD16 registers.
  */
  ESPCTL &= ~ESPEN;

/**
  * Then the general configurations of the analog front-end are done
  * that apply to all channels: clock selection (SMCLK) and divider
  * settings (depending on SMCLK frequency) and reference voltage
  * selections.
  */
  
//  SD16CTL= SD16SSEL_1  // Clock selection: SMCLK
  SD16CTL = 0x800 + SD16SSEL_1  // Clock selection: SMCLK + (Amp: )
#if (MCLK_FREQ == 2)
         | SD16DIV_1   // divide by 2 => ADC clock: 1.094MHz
#endif         
#if (MCLK_FREQ == 4)
         | SD16DIV_2   // divide by 4 => ADC clock: 1.094MHz
#endif         
#if (MCLK_FREQ == 8)
         | SD16DIV_3   // divide by 8 => ADC clock: 1.094MHz
#endif         
         | SD16REFON;  // Use internal reference


  SD16CCTL0 = INCH_0;  // I1
  SD16CCTL1 = INCH_0;  // I2
  SD16CCTL2 = INCH_0;  // V

  SD16CONF1 |= 0x40;   // Delay of ADC clock = 40ns
  

// -------------------------------------------------------------------
/** 
  * - Selection of ADC gain:
  *   - VIN,MAX(GAIN = 1) = 0.5V  > VCT(Peak)
  *   - VIN,MAX(GAIN = 2) = 0.25V < VCT(Peak)
  *   - VIN,MAX(GAIN = 16) = 0.031V  > VShunt(Peak)
  *   - VIN,MAX(GAIN = 32) = 0.015V  < VShunt(Peak)
  */
  // -----------------------------------------------------------
  // Configure analog front-end channel 2 - Current 1
   SD16INCTL0= I1_Gain; // Set gain for channel 0 (I1)
//  SD16INCTL0= GAIN_1; // Set gain for channel 0 (I1) to 1
//  SD16INCTL0= GAIN_2; // Set gain for channel 0 (I1) to 2
//  SD16INCTL0= GAIN_32; // Set gain for channel 0 (I1) to 32
  SD16CCTL0 |= OSR_0;  // Set oversampling ratio to 256 (default)

  // -----------------------------------------------------------
  // Configure analog front-end channel 1 - Current 2
  SD16INCTL1= I2_Gain; // Set gain for channel 1 (I2)
//  SD16INCTL1= GAIN_1; // Set gain for channel 1 (I2) to 1
//  SD16INCTL1= GAIN_2; // Set gain for channel 1 (I2) to 2
//  SD16INCTL1= GAIN_16; // Set gain for channel 1 (I2) to 16
  SD16CCTL1 |= OSR_0;  // Set oversampling ratio to 256 (default)

  // -----------------------------------------------------------
  // Configure analog front-end channel 2 - Voltage
 //!!!TEMP!!!	SetAFEGain2(calVoltage);
	SD16INCTL2= GAIN_1; //!!!TEMP!!! Set gain for channel 2 (V) to 1

	SD16CCTL2 |= OSR_0;  // Set oversampling ratio to 256 (default)
  
/**
  * \note 
  * Please note, that the oversampling ratio should be identical 
  * for all channels. Default is 256.
  */       

} // End of init_analog_front_end()


//====================================================================
void SetAFEGain2(int lineVoltage)
{
// Configure analog front-end channel 2 - Voltage
  if (lineVoltage <= 125)
  	{ SD16INCTL2= GAIN_2; }// Set gain for channel 2 (V) to 2
  else
    { SD16INCTL2= GAIN_1; }// Set gain for channel 2 (V) to 1
}



//====================================================================
/**
  * Sets one parameter of the ESP430CE1 module.
  *
  * The parameter \a param is loaded with \a data.
  *
  * \param param Parameter to be set.
  * \param data Data to be loaded into parameter.
  */
void set_parameter(unsigned int param, unsigned int data)
{
  volatile unsigned int timeout= TIMEOUT;  
  //  /\  Prevent variable from being "optimized".
  MBOUT1= data;
  MBOUT0= param;
  
  do
  { 
    while (((MBCTL & IN0IFG) == 0) && ((--timeout) > 0)) ;
    if (timeout == 0) { display_error(); return; }
  } while ((MBIN0 != mPARAMSET) || (MBIN1 != param));
}

//====================================================================
/**
  * Initializes ESP430CE1.
  *
  */
void init_esp_parameter(unsigned char flashvars)
{
  volatile unsigned int timeout;
  //  /\  Prevend variable from being "optimized".

  // copy predefined init values to RAM
  if (flashvars)
  {
	s_parameters = s_parameters_flash;
	_NOP();
  }
  
/**
  * Makes sure that the Embedded Signal Processing 
  * is enabled, 
  */
  ESPCTL |= ESPEN;
  MBCTL = 0;
    
/**
  * that it is not in measurement or calibration mode,
  */
  if ((RET0 & 0x8000) != 0) 
  { 
    // Set Embedded Signal Processing into "Idle" mode
    MBOUT1= modeIDLE; // ESP_IDLE;
    MBOUT0= mSET_MODE;
    timeout= TIMEOUT;
    while (((RET0 & 0x8000) != 0) && (--timeout > 0)) ;
  }

/**
  * and that it is ready to receive messages by requesting the
  * firmware version.
  */
  MBOUT0= mSWVERSION;
  timeout= TIMEOUT;
  do
  { 
    while (((MBCTL & IN0IFG) == 0) && (--timeout > 0)) ;
    if (timeout == 0) { display_error(); return; }
  } while (MBIN0 != mSWRDY);
  firmware_version= MBIN1; // Save firmware version.
  
/**
  * Then the parameters are initialized.
  *
  * \par Control 0: make settings for :
  * - Use current channel I2 - tamper-detection
  * - Count absolute active energy 
  *   (negative energy is considered as tampering)
  * - Switch DC removal alorithm on for I1
  * - Switch DC removal alorithm on for I2
  */
  set_parameter(mSET_CTRL0, defSET_CTRL0);

/**
  * \Set Number of Measurement: 
  *    e.g.  4096 * 50Hz. => int after 1sec
  */
  set_parameter(mSET_INTRPTLEVL_LO, s_parameters.pSET_INTRPTLEVL.w[0]);
  set_parameter(mSET_INTRPTLEVL_HI, s_parameters.pSET_INTRPTLEVL.w[1]);


/**
  * \par Nominal Mains Frequency: 
  *    e.g.  50Hz.
  */
  set_parameter(mSET_NOMFREQ, calFreq);
  
/**
  * \par Phase Error Correction:
  * Sets phase error for current 1/2 at nominal mains frequency for 
  * current transformer according to its specification
  * The phase error of the shunt is zero.
  */
  set_parameter(mSET_PHASECORR1, (int)s_parameters.pSET_PHASECORR1);
  set_parameter(mSET_PHASECORR2, (int)s_parameters.pSET_PHASECORR2);
  
/** \par Adjustment parameters for the two currents:
  * Current Transformer:
  * \par
  * There are two possibilties to adjust the two current
  * values:
  * -# Only one current value is scaled with a factor > 1
  *    to fit the others current's value. The factor
  *    for the later is set to 1.\n
  *    In this example current I1 would be scaled by 0.32/0.30 = 1.06667.
  *    (The RMS values at the maximum current are used to calculate the
  *     factor.)
  *    The current transformer's value is scaled to fit with 
  *    shunt's value, because the shunt's values are bigger, 
  *    so the current transformer's values are multiplied with 
  *    a factor > 1 - otherwise the shunt's values would be 
  *    multiplied with a factor < 1 and this would result
  *    in degraded accuracy.
  * -# Both currents are scaled with a factor > 1 to use the maximum FSR
  *    (Full Scale Range) at the maximum current Imax.\n

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美写真视频网站| 69堂亚洲精品首页| 国产剧情一区在线| 日韩精品欧美精品| 亚洲图片欧美综合| 亚洲精品视频在线| www久久久久| 日韩视频在线你懂得| 欧美日韩情趣电影| 中文字幕精品在线不卡| 日韩欧美一区二区在线视频| 欧美日韩另类国产亚洲欧美一级| 91麻豆免费看片| 色综合天天综合| 一本色道久久加勒比精品 | 国产一区欧美日韩| 美日韩一区二区| 久久成人精品无人区| 久久精品国产澳门| 国模冰冰炮一区二区| 国产经典欧美精品| 成熟亚洲日本毛茸茸凸凹| 国产精品一二三在| 国产精品自产自拍| 成人免费视频一区| 99久久99久久精品国产片果冻 | 五月激情综合婷婷| 日韩二区三区四区| 色老汉av一区二区三区| 欧美亚洲一区二区在线| 欧美中文字幕一区| 欧美日韩精品福利| 欧美一区二区三区视频免费| 欧美一区二区三区性视频| 日韩一区二区电影| 久久男人中文字幕资源站| 国产精品免费aⅴ片在线观看| 欧美国产日韩精品免费观看| 亚洲日本在线天堂| 一个色在线综合| 亚洲电影在线免费观看| 麻豆精品视频在线观看免费| 国产美女娇喘av呻吟久久 | 国产盗摄女厕一区二区三区| 成人激情图片网| 欧美性受极品xxxx喷水| 91精品福利在线一区二区三区 | 99精品久久久久久| 欧美理论在线播放| 日韩二区三区在线观看| 亚洲综合999| 加勒比av一区二区| 不卡一区在线观看| 欧美精品色综合| 精品日韩成人av| 国产精品久久久久久久浪潮网站| 夜色激情一区二区| 久久99精品国产91久久来源 | aaa欧美日韩| 欧美伦理电影网| 国产亚洲一区字幕| 亚洲欧洲日产国码二区| 日韩av一区二| 9人人澡人人爽人人精品| 在线这里只有精品| 久久一区二区视频| 亚洲午夜影视影院在线观看| 久久99精品久久久久久久久久久久| 床上的激情91.| 91精品婷婷国产综合久久性色 | 欧美肥大bbwbbw高潮| 久久精品亚洲一区二区三区浴池| 亚洲精品免费看| 日韩在线一区二区三区| 丁香亚洲综合激情啪啪综合| 欧美日本在线看| 亚洲视频在线一区| 麻豆精品国产传媒mv男同| 色综合色综合色综合色综合色综合| 91精品久久久久久久99蜜桃| 国产精品国产馆在线真实露脸 | 欧美一区二区精品在线| 亚洲裸体xxx| av动漫一区二区| 国产精品狼人久久影院观看方式| 狠狠久久亚洲欧美| 欧美成人精品二区三区99精品| 舔着乳尖日韩一区| 亚洲视频一区二区在线观看| 国产在线精品不卡| 久久综合九色欧美综合狠狠| 七七婷婷婷婷精品国产| 欧美一区二区三区四区久久| 日韩制服丝袜av| 日韩一区二区三区电影在线观看| 日本午夜一本久久久综合| 欧美乱妇23p| 免费成人结看片| 精品国精品国产尤物美女| 六月丁香综合在线视频| 精品国产伦一区二区三区免费 | 91高清视频在线| 一区二区三区蜜桃| 欧美少妇xxx| 日日噜噜夜夜狠狠视频欧美人| 欧美日本视频在线| 日本中文一区二区三区| 日韩欧美中文字幕公布| 精品一区二区在线视频| 精品国产一区二区三区av性色| 精品在线你懂的| 久久久精品影视| 99久久精品免费| 亚洲最大成人综合| 欧美电影在哪看比较好| 色94色欧美sute亚洲线路一ni| 亚洲电影第三页| 91精品国产色综合久久| 韩日精品视频一区| 国产人成亚洲第一网站在线播放 | 成人丝袜18视频在线观看| 国产精品久久久久精k8| 色婷婷亚洲一区二区三区| 一区二区三区毛片| 日韩一区二区三区视频在线观看| 国产综合成人久久大片91| 中文在线一区二区| 在线观看亚洲成人| 天堂在线一区二区| 久久一区二区三区四区| 97久久精品人人做人人爽| 亚洲国产视频在线| 欧美xxxxxxxxx| 国产suv精品一区二区三区| 亚洲欧洲av一区二区三区久久| 欧美性受xxxx黑人xyx性爽| 麻豆91在线看| 亚洲视频每日更新| 亚洲综合在线免费观看| 51精品秘密在线观看| 国产精品正在播放| 有码一区二区三区| 精品999久久久| 91久久国产综合久久| 青青草91视频| 中文字幕一区二区在线播放| 欧美久久一二区| 丁香婷婷深情五月亚洲| 亚洲一卡二卡三卡四卡无卡久久| 日韩欧美二区三区| 色偷偷88欧美精品久久久| 美国十次综合导航| 一区二区三区四区激情| 久久中文字幕电影| 欧美日韩精品系列| 岛国一区二区在线观看| 蜜臀久久99精品久久久久久9| 国产精品久久久久久久岛一牛影视 | 久久99国内精品| 亚洲黄色在线视频| 国产亚洲综合在线| 欧美一级日韩免费不卡| 色av成人天堂桃色av| 欧美日韩久久久| 成人久久久精品乱码一区二区三区 | 国产精品毛片无遮挡高清| 91精品啪在线观看国产60岁| 91在线精品一区二区| 国内精品伊人久久久久av一坑| 亚洲成人黄色影院| 亚洲视频一二区| 亚洲国产精品激情在线观看| 日韩午夜在线观看| 在线精品国精品国产尤物884a| 国产91精品露脸国语对白| 麻豆91免费看| 天天免费综合色| 一区二区三区不卡在线观看| 国产欧美一区在线| 亚洲精品一区二区精华| 欧美精品黑人性xxxx| 91久久精品国产91性色tv| 国产精品自拍三区| 激情文学综合网| 免费人成黄页网站在线一区二区| 亚洲最新在线观看| 亚洲精品伦理在线| 亚洲欧美日韩在线| 中文字幕av一区二区三区免费看| 精品国产精品网麻豆系列| 欧美日韩电影一区| 欧美偷拍一区二区| 欧美怡红院视频| 在线视频一区二区三区| 色婷婷一区二区三区四区| 91首页免费视频| 色综合久久66| 97se亚洲国产综合自在线观| av网站一区二区三区| 成人精品免费网站|