?? globe.h
字號:
/********************************************************************************
* 杭州利爾達(dá) *
* MSP430FE42X單相防竊電多功能電表平臺 *
* ----- ESP SD16實(shí)現(xiàn) *
* *
* *
* 說明:本軟件為杭州利爾達(dá)單相防竊電多功能電表DEMO軟件 *
* *
*********************************************************************************/
#ifndef _GLOBE_H_
#define _GLOBE_H_
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned int uint16;
typedef signed int int16;
typedef unsigned long uint32;
typedef signed long int32;
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned int uint16_t;
typedef signed int int16_t;
typedef unsigned long uint32_t;
typedef signed long int32_t;
// LCD顯示字符表
extern const unsigned char lcd_digit_table[];
struct emeter_var
{
// 系統(tǒng)狀態(tài)標(biāo)志位
uint16 ui_meter_status;
// 防竊電模式狀態(tài)
uint16 ui_anti_tamperring_status;
// 保存ESP軟件版本號
uint16 ui_firmware_version;
// 指示顯示頁面
uint8 uc_display_stage;
// 秒計數(shù)
uint16 ui_sec_count;
/* 電網(wǎng)頻率 */
uint16 ui_main_frequency;
/* 功率因子 */
uint16 ui_power_factor;
// 上次溫度測量值,攝氏度
int16 i_last_temperature;
// 上次溫度測量值,采樣值
int16 i_temperature;
// 溫度采樣偏置
int16 i_temperature_offset;
// 電流有效值
uint16 ui_current_IRMS;
/* 電壓有效值 */
uint16 ui_voltage_V1RMS;
// 累計有用功電能
float f_total_energy;
// 上次測量得到的各項(xiàng)電能
uint32 ul_total_power;
uint32 ul_act_power_counter;
uint32 ul_act_power1;
uint32 ul_act_power2;
uint32 ul_react_power;
uint32 ul_app_power;
float f_re_total_power;
/* 校表參數(shù)緩存 */
uint8 ucFlashOperated[2];
float f_Cz1; // 電路常數(shù)
float f_Cz2; // 電路常數(shù)
uint16 ui_GainCorr1;
uint16 ui_GainCorr2;
int32 l_PowerOffset1;
int32 l_PowerOffset2;
float f_PhaseCorr1;
float f_PhaseCorr2;
uint16 ui_SD16_CurrentCorr1;
uint16 ui_SD16_CurrentCorr2;
uint16 ui_SD16_VoltageCorr1;
uint16 ul_TempSampleOffset;
uint8 ucCalibrationMode;
uint8 ucCalibrationOption;
uint8 uc_pout_hc595;
uint8 uc_restart_esp_delay;
uint8 uc_lcd_remaining_times;
uint8 uc_switch_delay_counter;
uint8 display_stage;
};
extern struct emeter_var emeter;
union signed_long_word
{
int32 l;
uint16 w[2];
};
extern union signed_long_word ds;
extern uint32 ul_total_power_infact;
extern uint16 ui_step_counter;
struct current_sensor_parms_s
{
uint16 V_rms;
uint16 I_rms;
/* Channel's DC estimates, accumulated powers, and the logged
accumulated power from the last measurement cycle. */
int32_t I_dc_estimate;
int16_t P_accum[3];
int16_t P_accum_logged[3];
/*! \brief The accumulating dot product of I.I */
int16_t I_sq_accum[3];
/*! \brief The latest logged dot product of I.I */
int16_t I_sq_accum_logged[3];
/*! \brief The current number of accumulated samples. */
int16_t sample_count;
/*! \brief The latest logged number of accumulated samples. */
int16_t sample_count_logged;
/*! \brief The beta of the FIR/interpolator used for phase correction. */
int16_t fir_beta;
/*! \brief The step into the history data used for phase correction. */
int16_t fir_step;
int16_t fir_gain;
/*! \brief History of the current samples, for use when making large phase corrections */
int16_t I_history[2];
int8_t I_endstops;
};
struct phase_parms_s
{
uint16_t V_rms;
uint16_t I_rms;
/* Voltage channel DC estimates. We need separate estimates for normal
and limp mode, as in limp mode we use a different ADC reference. */
int32_t V_dc_estimate[2];
int16_t V_history[4];
/* Accumulated squares of the phase corrected voltage (V.V). These are used to
calculate the RMS voltage, and the power factor. We need separate accumulation
for each current sensor, as we accumulate the phase corrected voltage which matches
the current sensor's phase shift. The actual phase correction is not important for this.
However, if we use just one accumulated voltage we would need to use a scaling factor before
it can be applied. This might reduce precision, so we do things this way. */
int16_t V_sq_accum[3];
int16_t V_sq_accum_logged[3];
struct current_sensor_parms_s current;
struct current_sensor_parms_s neutral;
/* The number of samples of mains waveform cycles accumulated so far during the
current measurement cycle. The logged value from the last measurement cycle. */
int16_t sample_count;
int16_t sample_count_logged;
uint16_t status;
/* Values used in determining ADC overload, for each of the ADCs.
The ones for detecting overload of the high gain current ADCs
are always needed. The others are optional. */
int8_t V_endstops;
int8_t V_history_index;
};
extern struct phase_parms_s *phase;
/****************************************************************
* 定義顯示頁面,顯示順序?yàn)椋? *
* P1 電流通道I1平均有功功率 *
* P2 電流通道I2平均有功功率 *
* C 電流有效值IRMS *
* U 電壓有效值VRMS *
* F 電網(wǎng)頻率 *
* PF 功率因素 *
* rP 平均無功功率 *
* AP 平均視在功率 *
*****************************************************************/
enum
{
DISPLAY_STAGE_ACT_ENERGY_1 = 1, // P1
DISPLAY_STAGE_ACT_ENERGY_2, // P2
DISPLAY_STAGE_CURRENT, // C
DISPLAY_STAGE_VOLTAGE, // U
DISPLAY_STAGE_FREQUENCY, // F
DISPLAY_STAGE_POWERFACTOR, // PF
DISPLAY_STAGE_REACT_ENERGY, // rP
DISPLAY_STAGE_APP_ENERGY, // AP
DISPLAY_STAGE_TEMPERATURE, // t
DISPLAY_STAGE_TIME, // 時間
DISPLAY_STAGE_DATE, // 日期
DISPLAY_STAGE_TEST1,
DISPLAY_STAGE_TEST2,
DISPLAY_STAGE_TEST3,
DISPLAY_STAGE_TEST4,
DISPLAY_STAGE_TEST5,
DISPLAY_STAGE_TEST6,
DISPLAY_STAGE_TEST7,
DISPLAY_STAGE_TEST8,
DISPLAY_STAGE_TEST9,
DISPLAY_STAGE_LAST
};
// meter_status;
#define SKIP_A_SECOND BIT0 // 時鐘跳過一秒標(biāo)志
#define MAIN_VOLTAGE_DOWN BIT1 // 電網(wǎng)電壓無標(biāo)志,電表將關(guān)閉ESP
#define NEW_ENERGY_READY BIT2 // 標(biāo)志新的能量已經(jīng)準(zhǔn)備好
#define KEY_PRESS_DELAY BIT3 // 標(biāo)志按鍵延時狀態(tài)
#define REQUIRE_MODIFY_ESP_PARAM BIT4 // 標(biāo)志需要修改ESP參數(shù)寄存器,需要先讓ESP進(jìn)入IDLE狀態(tài)
#define IN_TEMPERATURE_MEASURE BIT5 // 標(biāo)志正在一次溫度測量狀態(tài)
#define V1_CZ_TRAILING BIT6
#define ENRDY_INT_OCCUR BIT7 /* ESP新的能量準(zhǔn)備好中斷發(fā)生標(biāo)志 */
#define REQUIRE_RTC_CORRENT BIT8 /* 要求溫度補(bǔ)償 */
#define REQUIRE_FLASH_OP BIT9
#define REQUIRE_LCD_UPDATE BITA
#define ENSPER_INT_OCCUR BITB
#define BT_1SEC_INT_OCCUR BITC
// ui_anti_tamperring_status
#define IN_SD16_MEASURE_MODE BIT0
#define IN_ESP_MEASURE_MODE BIT1
#define IN_ONLY_RTC_MODE BIT2
#define EXTERN_VOLTAGE_SENSOR BIT3
#define SD16_MEASURE_NEW_LOG BIT4
// 實(shí)時時鐘結(jié)構(gòu)
struct rtc_s
{
uint8 second;
uint8 minute;
uint8 hour;
uint8 day;
uint8 week;
uint8 month;
uint8 year;
uint8 sumcheck;
};
extern struct rtc_s rtc;
extern uint32 ul_actensper1;
extern uint32 ul_actensper2;
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -