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

📄 emeter.h

📁 msp430F437三相电表DEMO(编译器 IAR 3.42A)
💻 H
📖 第 1 页 / 共 3 页
字号:
    clr_normal_indicator() should also be defined. The normal operation LED will be
    lit when the mains voltage is normal. In limp mode, or power down mode,
    it is switched off. */
#define set_normal_indicator()                      /**/

/*! This definition specifies the port bit change required to turn off the
    normal operation indicator LED, when one is used.  If this is defined,
    set_normal_indicator() should also be defined. */
#define clr_normal_indicator()                      /**/

/*! This definition specifies the port bit change required to turn on the
    earthed condition indicator LED, when one is used. If this is defined,
    clr_earthed_indicator() should also be defined. The earthed LED will be lit when
    there is a substantial imbalance in power (normal operating mode) or
    current (limp mode) between the live and neutral leads. If the neutral
    has the higher reading, this will also be used instead of the live reading. */
#define set_earthed_indicator()                     /**/

/*! This definition specifies the port bit change required to turn off the
    earthed condition indicator LED, when one is used. If this is defined,
    set_earthed_indicator() should also be defined. */
#define clr_earthed_indicator()                     /**/

/*! This is the number of successive measurement blocks which must agree the
    unbalanced status has changed before we accept it. */
#define PHASE_UNBALANCED_PERSISTENCE_CHECK          5

/*! These is the minimum current level (limp mode) and minimum power level (normal
    mode) at which we will make checks for the earthed condition. Very small
    readings lack the accuracy and resolution needed to make meaningfulF comparisons
    between live and neutral. */
#define PHASE_UNBALANCED_THRESHOLD_CURRENT          500
#define PHASE_UNBALANCED_THRESHOLD_POWER            2000

/*! This selects the detection of the reversed power condition. */
#define PHASE_REVERSED_DETECTION_SUPPORT

/*! This selects that the reversed power condition is to be treated as tampering. */
#define PHASE_REVERSED_IS_TAMPERING

/*! This definition specifies the port bit change required to turn on the
    reverse condition indicator LED, when one is used. If this is defined,
    clr_reverse_current_indicator() should also be defined. The reversed LED will be lit
    in normal operating mode, if the raw power reading is negative in the live
    lead (without neutral lead monitoring) or in either of the leads (with
    neutral lead monitoring). The power value used is simply minus the actual
    reading. This only functions in the normal operating mode. In limp mode we
    have no simple way to tell forward current flow from reverse. In limp mode
    the LED is switched off. Note that if the meter is used in applications
    means we are actively feeding power to the public grid this functionality
    is inappropriate. In those cases the negative power would generally be used
    to accumulate a separate "generated energy" reading, to complement the usual
    "consumed energy" reading. */
#define set_reverse_current_indicator()             /**/

/*! This definition specifies the port bit change required to turn on the
    reverse condition indicator LED, when one is used. If this is defined,
    set_reverse_current_indicator() should also be defined. */
#define clr_reverse_current_indicator()             /**/

/*! This is the number of successive measurement blocks which must agree the
    reversed current status has changed before we accept it. */
#define PHASE_REVERSED_PERSISTENCE_CHECK            5

/*! This is the minimum power level at which we will make checks for the reverse
    condition. Very small readings are not a reliable indicator, due to noise. */
#define PHASE_REVERSED_THRESHOLD_POWER              2000

#endif

/*! Some customers expect a meter to count pulses from the time the mains power
    is restored, looosing any fractional count of an LED pulse. This looses the
    power company a fraction of a pulse of revenue, and means the meter is not
    doing the best it can. In the end, we just do what the customer wants. */
#define LOSE_FRACTIONAL_PULSE_AT_POWER_ON

/*! Target specific definitions for the analogue I/O pins */
#define VOLTAGE_INPUT_1                             INCH_3
#define VOLTAGE_INPUT_2                             INCH_4
#define VOLTAGE_INPUT_3                             INCH_5
#define LIVE_HIGH_CURRENT_INPUT_1                   INCH_0
#define LIVE_HIGH_CURRENT_INPUT_2                   INCH_1
#define LIVE_HIGH_CURRENT_INPUT_3                   INCH_2
#define LIVE_LOW_CURRENT_INPUT_1                    INCH_6
#define LIVE_LOW_CURRENT_INPUT_2                    INCH_8
#define LIVE_LOW_CURRENT_INPUT_3                    INCH_9
#define NEUTRAL_CURRENT_INPUT                       INCH_7
#define AGND_INPUT                                  INCH_7

#define DEFAULT_TEMPERATURE_OFFSET                  (1615*8)
#define DEFAULT_TEMPERATURE_SCALING                 (704*2)

#define DEFAULT_ROOM_TEMPERATURE                    250

#define DEFAULT_V_RMS_SCALE_FACTOR                  18034
//#define DEFAULT_V_RMS_LIMP_SCALE_FACTOR             21280
#define DEFAULT_I_RMS_SCALE_FACTOR                  3659
//#define DEFAULT_I_RMS_LIMP_SCALE_FACTOR             4360
#define DEFAULT_P_SCALE_FACTOR_A_LOW                1039 //1617  //978
#define DEFAULT_P_SCALE_FACTOR_A_HIGH               15663 //24330 //10710
#define DEFAULT_P_SCALE_FACTOR_B_LOW                1075 //1617  //978
#define DEFAULT_P_SCALE_FACTOR_B_HIGH               16074 //24330 //10710
#define DEFAULT_P_SCALE_FACTOR_C_LOW                1083 //1617  //978
#define DEFAULT_P_SCALE_FACTOR_C_HIGH               16271 //24330 //10710

#define DEFAULT_NEUTRAL_I_RMS_SCALE_FACTOR          4905
//#define DEFAULT_NEUTRAL_I_RMS_LIMP_SCALE_FACTOR     4360
#define DEFAULT_NEUTRAL_P_SCALE_FACTOR              6210

#define DEFAULT_FREQUENCY_PHASE_FACTOR              500
#define DEFAULT_FREQUENCY_GAIN_FACTOR               0

#define DEFAULT_BASE_PHASE_A_CORRECTION_LOW         -2
#define DEFAULT_BASE_PHASE_A_CORRECTION_HIGH        5
#define DEFAULT_BASE_PHASE_B_CORRECTION_LOW         -2
#define DEFAULT_BASE_PHASE_B_CORRECTION_HIGH        5
#define DEFAULT_BASE_PHASE_C_CORRECTION_LOW         -2
#define DEFAULT_BASE_PHASE_C_CORRECTION_HIGH        5
#define DEFAULT_NEUTRAL_BASE_PHASE_CORRECTION       73

#define DEFAULT_PHASE_CORRECTION1                   0
#define DEFAULT_GAIN_CORRECTION1                    0
#define DEFAULT_PHASE_CORRECTION2                   0
#define DEFAULT_GAIN_CORRECTION2                    0

#define custom_set_consumption(x,y)                 /**/
#define custom_magnetic_sensor_test()               /**/

/*! This is called every ADC interrupt, after the main DSP work has finished.
    It can be used for things like custom keypad operations. It is important
    this is a very short routine, as it is called from the main ADC interrupt. */
#define custom_adc_interrupt()                      /**/

/*! This is called at intervals, to allow integration of RF protocols for AMR. */
#define custom_rf_sniffer()                         /**/

/*! This is called at intervals, to allow integration of RF protocols for AMR. */
#define custom_rf_exchange()                        /**/

#define custom_rtc()                        /* not used */
#define custom_rtc_set()                    /* not used */
#define custom_rtc_retrieve(x)              /* not used */
#define custom_energy_pulse()               /* not used */
#define custom_keypad_handler()             /* not used */
#define custom_mainloop_handler()           /* not used */
#define custom_power_fail_handler()         /* not used */
#define custom_power_restore_handler()      /* not used */

#include "lierda_lcd.h"

/* LCD display parameters */

#define TWO_LINE_LCD

#define LCD_CELLS               8
#define LCD_POS_BASE            1
#define LCD_POS_STEP            1
//typedef uint8_t lcd_cell_t;

#define ICON_PHASE_A            ((5<<5) | 0)
#define ICON_PHASE_B            ((6<<5) | 0)
#define ICON_PHASE_C            ((4<<5) | 0)

#define ICON_A                  ((7<<5) | 8)
#define ICON_V                  ((7<<5) | 17)
#define ICON_kW                 ((7<<5) | 12)
#define ICON_H                  ((7<<5) | 10)

#define ICON_DECIMAL_2          ((7<<5) | 4)
#define ICON_DECIMAL_4          ((7<<5) | 2)

//#define ICON_BATTERY            ((7<<5) | 5)

#define ICON_TIME_COLON_1       ((7<<5) | 13)
#define ICON_TIME_COLON_2       ((7<<5) | 11)

#define ICON_DATE_COLON_1       ((7<<5) | 4)
#define ICON_DATE_COLON_2       ((7<<5) | 2)

#define FIRST_ROW_START             10
#define FIRST_ROW_CHARS             8
#define SECOND_ROW_START            1
#define SECOND_ROW_CHARS            8

#define FIRST_POSITION              1
#define YEAR_POSITION               1
#define MONTH_POSITION              3
#define DAY_POSITION                5
#define HOUR_POSITION               10
#define MINUTE_POSITION             12
#define SECONDS_POSITION            14
#define NUMBER_WIDTH                6

#define FIRST_POWER_POSITION            10
#define FIRST_VOLTAGE_POSITION          10
#define FIRST_POWER_FACTOR_POSITION     10
#define FIRST_VA_POWER_POSITION         10
#define FIRST_TEMPERATURE_POSITION      10

#define FIRST_REACTIVE_POWER_POSITION   1
#define FIRST_CURRENT_POSITION          1
#define FIRST_FREQUENCY_POSITION        1
#define FIRST_ENERGY_POSITION           1

#define DISPLAY_TYPE_POSITION       10

#define FREQUENCY_RESOLUTION    2
#define ICON_DECIMAL_FREQUENCY  ICON_DECIMAL_2
#define VOLTAGE_RESOLUTION      2
#define ICON_DECIMAL_VOLTAGE    ICON_DECIMAL_2
#define CURRENT_DISPLAY_DIVISOR 10
#define CURRENT_RESOLUTION      2
#define ICON_DECIMAL_CURRENT    ICON_DECIMAL_2
#define POWER_RESOLUTION        2
#define ICON_DECIMAL_POWER      ICON_DECIMAL_2
#define ENERGY_RESOLUTION       2
#define ICON_DECIMAL_ENERGY     ICON_DECIMAL_2

#define TEXT_MESSAGE_LENGTH     6

#define USE_WATCHDOG            1

#define P1DIR_INIT              (BIT7 | BIT6 | BIT4 | BIT3 | BIT0)
#define P1SEL_INIT              0
#define P1OUT_INIT              0

#define P2DIR_INIT              (BIT7 | BIT6 | BIT4 | BIT3 | BIT1 | BIT0)
#define P2SEL_INIT              (BIT5 | BIT4)
#define P2OUT_INIT              0

#define P3DIR_INIT              (BIT7 | BIT6 | BIT2 | BIT1 | BIT0)
#define P3SEL_INIT              0
#define P3OUT_INIT              (BIT2 | BIT1 | BIT0)

#define P4DIR_INIT              0
#define P4SEL_INIT              0 //(BIT1 | BIT0)   /* USART1 */
#define P4OUT_INIT              0

#define P5DIR_INIT              0
#define P5SEL_INIT              (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)    /* LCD divider chain and COM segments */
#define P5OUT_INIT              BIT7

#define P6DIR_INIT              0
#define P6SEL_INIT              (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
#define P6OUT_INIT              0

/* Full 160 segment display */
#define LCD_INIT                (LCDSG0_7 | LCD4MUX | LCDON)

#define GAIN_STAGES             2
#define NEUTRAL_GAIN_STAGES     1

⌨️ 快捷键说明

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