This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Resolution problem 3 phase energy meter MSP430f47197 (NOT answered *** TI Employees attention plz!)



I am wondering if I can increase the resolution of kWhs on the following product. I changed the resolution factor and applied different changes on the Background as well as Foreground parts but still no success. Please guide!

http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=slaa409a&fileType=zip

 

http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=slaa409&fileType=pdf

  • Through the code I found the followings.

    #define VOLTAGE_RESOLUTION                          2

    or 

    #define ENERGY_RESOLUTION                           2

    And also:

    #define VOLTAGE_DIGITS                              4

    However, by changing them, nothing is changed! Maybe somewhere the display code does not hsow the values properly! I am still working on it! 

  • Also according to the following documentation. I tried to change the Scaling factor and sample count. No success! Maybe the register are truncated somewhere or resolution does not go higher!!! I am not sure which quantity should be changed in order to get a more resolution.

    http://www.ti.com/lit/an/slaa409a/slaa409a.pdf

  • Seems adjusting Vrms and Irms values are doable but when it comes to product of those and get a P is not easy to change the resolution!

  • To measure energy consumption, you need to integrate over time the product of voltage * current.

    To measure the voltage, the resolution and accuracy depends on the voltage divider resistors, the reference voltage and the resolution of the ADC used. What is the accuracy of the divider? What is the range and resolution of the ADC?

    To measure the current, the resolution and accuracy depends on the CT (or shunt resistors), the reference voltage and the resolution of the ADC used. What is the accuracy of the CT (or shunt)? What is the range and resolution of the ADC?

    To integrate over time, you have to use summation at fixed intervals as an approximation. What is that interval?

    Without improving the above three elements, you cannot get meaningful results even if you carry out the calculation to very large number of bits without truncation. Truncation is often used to save calculation time by ignoring meaningless bits. If you do not do that, you might prolong the summation interval and thus get worse results and only gain some meaningless garbage bits in the result. 

  • old_cow_yellow said:
    To measure energy consumption, you need to integrate over time the product of voltage * current.

    Yes, that is true! 

    old_cow_yellow said:
    To measure the voltage, the resolution and accuracy depends on the voltage divider resistors, the reference voltage and the resolution of the ADC used. What is the accuracy of the divider? What is the range and resolution of the ADC?

    I notice that they had used bite-wise shift, then I could able to get more decimal points. As for the ADC they have used 16-Bit Sigma-Delta and as Accuracy it says:

    #undef FINE_ENERGY_PULSE_TIMING_SUPPORT

    ! This enables the generation of total energy pulses to an accuracy of 1/32768s, instead
    of 10/32768s, when building meters using the ADC12 ADC converter.

    And pge 12 of

    http://www.ti.com/lit/an/slaa409a/slaa409a.pdf

    The SD16 converter is self triggering at a sampling frequency of 4096 samples/sec. 

    old_cow_yellow said:
    To measure the current, the resolution and accuracy depends on the CT (or shunt resistors), the reference voltage and the resolution of the ADC used. What is the accuracy of the CT (or shunt)? What is the range and resolution of the ADC?

    I don't us CT I used Shunt resistors and could able to add more decimal points to that.

    It is said:

    As discussed in the previous sections simultaneous voltage and current samples are obtained
    from six independent SD16 converters at a sampling rate of 4096 Hz.

    But I don't know the accuracy of shunt resistors!

    old_cow_yellow said:
    To integrate over time, you have to use summation at fixed intervals as an approximation. What is that interval?

    I am not sure about the interval that you are talking about but they have used the following method:

        
        #if defined(INHIBIT_NEGATIVE_TOTAL_POWER_ACCUMULATION)
            if (total_active_power > 0  &&  (total_active_power_counter += total_active_power) >= TOTAL_ENERGY_PULSE_THRESHOLD)
        #else
            if ((total_active_power_counter += total_active_power) >= TOTAL_ENERGY_PULSE_THRESHOLD)
        #endif
            {
                total_active_power_counter -= TOTAL_ENERGY_PULSE_THRESHOLD;
        #if TOTAL_ENERGY_PULSES_PER_KW_HOUR < 1000
                if (++extra_total_active_power_counter >= 16) // was 16
                {
                    extra_total_active_power_counter = 0;
        #endif
                    ++total_consumed_active_energy;
                    /* Ideally we want to log the energy each kWh unit, but doing
                       it with a mask here is good enough and faster. */
                    if ((total_consumed_active_energy & 0x3FF) == 0)
                        phase->status |= ENERGY_LOGABLE;
                    /* Pulse the LED. Long pulses may not be reliable, as at full
                       power we may be pulsing many times per second. People may
                       check the meter's calibration with an instrument that counts
                       the pulsing rate, so it is important the pulses are clear,
                       distinct, and exactly at the rate of one per
                       1/ENERGY_PULSES_PER_KW_HOUR kW/h. */
        #if defined(total_active_energy_pulse_start)
            #if defined(FINE_ENERGY_PULSE_TIMING_SUPPORT)
                    /* TODO: This will not work if extra_total_active_power_counter is in use */
                    /* Work out the fraction of an ADC interrupt, in 1/10ths of an ADC interrupt period,
                       at which the real transition occurs */
                    /* Break up the loop a bit, for efficiency */
                    xxx = total_active_power_counter << 1;
                    j = 10;
                    if (xxx >= total_active_power)
                    {
                        xxx -= total_active_power;
                        j = 5;
                    }
                    xxx += (xxx << 2);
                    do
                        j--;
                    while ((xxx -= total_active_power) > 0)
                        ;
                    /* j is now our fraction of an ADC interrupt. If we use this right now to control timer A
                       its effect would be indeterminate. We need timer A to be updated at the very start of an
                       ADC interrupt service, to ensure the fraction of an ADC interrupt is programmed into the
                       timer while its count is at a well defined value - zero. */
                    fine_pulse_operation = OUTMOD_5 | SCS;
                    TACCR2 = j;
            #else
                    total_active_energy_pulse_start();
            #endif
                    total_active_energy_pulse_remaining_time = ENERGY_PULSE_DURATION;
        #endif
        #if defined(MULTI_RATE_SUPPORT)
                    multirate_energy_pulse();
        #endif
        #if TOTAL_ENERGY_PULSES_PER_KW_HOUR < 1000
                }
        #endif
            }
        #if defined(total_active_energy_pulse_start)
            if (total_active_energy_pulse_remaining_time  &&  --total_active_energy_pulse_remaining_time == 0)
            {
            #if defined(FINE_ENERGY_PULSE_TIMING_SUPPORT)
                /* Turn off the indicator at the next CCR2 match. */
                fine_pulse_operation = OUTMOD_1 | SCS;
                /* Leave TACCR2 alone, and we should get the same offset as last time, resulting in even length pulses */
            #else
                total_active_energy_pulse_end();
            #endif
            }
        #endif

    old_cow_yellow said:
    If you do not do that, you might prolong the summation interval and thus get worse results and only gain some meaningless garbage bits in the result. 

    Agreed! try to do so! :((

  • I found the following as well!

    #if defined(TOTAL_ACTIVE_ENERGY_SUPPORT)
        /* We now play the last measurement interval's power level, evaluated
           in the foreground, through this measurement interval. In this way
           we can evenly pace the pulsing of the LED. The only error produced
           by this is the ambiguity in the number of samples per measurement.
           This should not exceed 1 or 2 in over 4000. */

  • Also:

    #if !defined(__MSP430__)
    /*! The minimum value which the ADC can produce. */
    #define ADC_MIN -32768
    /*! The maximum value which the ADC can produce. */
    #define ADC_MAX 32767
    #endif

  • OCY,

    I don't understand the "product" part ...when I have voltage to 5 decimal points and current to 5 as well, there should be a register which exclude those numbers and I have only 2 decimal point of energy!

    Even though, you mentioned that the resolution and shunt registers and that time interval is important, I believe that it is not that much out of reach to get at least 4 decimal point of energy! Then I can calibrate it and compare it with a standard meter in order to see if I get an accurate values! Right? But understanding the code which is written by someone else and with many C and h file is not an easy job!

  • Let's say in the Active Power section we have:

    #if defined(SINGLE_PHASE)
    int32_t active_power(void)                  // Active Power --------------
    #else
    int32_t active_power(struct phase_parms_s *phase, struct phase_nv_parms_s const *phase_nv)
    #endif
    {
        int32_t x;
        int16_t i;
    #if defined(NEUTRAL_MONITOR_SUPPORT)  ||  GAIN_STAGES > 1
        int32_t y;
    #endif
    #if defined(PHASE_REVERSED_DETECTION_SUPPORT)
        int reversed;
    #endif
    
        /* We can only do real power assessment in full operating mode. */
        /* If we have neutral monitoring for a single phase meter, we need to measure
           both power levels, and decide between them. Issues to be assessed here are
           whether one or both leads show reverse power, and whether the power levels
           are balanced. */
    #if defined(PHASE_REVERSED_DETECTION_SUPPORT)
        /* If we find a negative power level we may be genuinely feeding power to the grid,
           or we may be seeing a tamper condition. This is application dependant. */
        reversed = FALSE;
    #endif
    
        x = div_sh48(phase->metrology.current.dot_prod_logged.P_active[0], 31 - 2*ADC_BITS, phase->metrology.current.dot_prod_logged.sample_count); // 27 to 32
        i = phase_nv->current.P_scale_factor[0];

    I found the following for  dot_prod_logged.

     struct current_sensor_dot_prod_set_s dot_prod_logged;

    But have no idea how they calculate this product macro!!!

  • By “product”, I mean the result of multiplication.

    I am neither an engineer nor a programmer. I do not know (nor care to know) the specifics of the energy meter you are talking about.

    Assuming that it is a “230VAC, 100Amp Service” energy meter commonly used in residential household, it must be able to measure the 100 Amp full load.

    If a 16-bit ADC is used, this means the ADC reads 65536 counts when the current is 100 Amp. Thus the least count of the ADC is about 100 / 65535 = 0.0015 Amp.

    To me, the above means when the current is less than ~0.0015 Amp, the ADC reads 0. And when the ADC appears to tells you the current is “x” Amp, it actually means the current is somewhere between “x” Amp and “x + 0.0015” Amp.

    Multiply the current by the voltage to get power. When the power consumption is blow ~0.35 Watt, you will get 0.00000000000000000000 Watt no mater how precise you do the multiplication. And when the multiplication appears to tell you the power consumption is “y” Watt, it actually means the power consumption is somewhere between  “y” Watt and “y + 0.35” Watt.

    Over a month (30*24 Hr) time, when the energy meter appears to tell you “z” kWattHr, it really means somewhere between “z” kWattHr and “z + 0.25” kWattHr. The digits after the decimal point are meaningless.

  • old_cow_yellow said:
    I am neither an engineer nor a programmer.

    You amaze me! But you have a lot experience and knowledge! From LCD driver to SVS and .... I believe you have a passion for Electronics!

    old_cow_yellow said:
    Assuming that it is a “230VAC, 100Amp Service”

    Yes, even 230 rather than 110 v. 

    old_cow_yellow said:
    commonly used in residential household, it must be able to measure the 100 Amp full load.

    Yes, usually called single point meter!

    old_cow_yellow said:

    65536 counts

    Yes, 2^16!

    old_cow_yellow said:
    100 / 65535 = 0.0015 Amp.

    Oh you mean the resolution is only 4 decimal points right? Then, why I have let's say: 25.68645 and it is changing!?

    old_cow_yellow said:
    ~0.35 Watt,

     230* .0015 .... I see but I don't reach to that ...just in case!

    old_cow_yellow said:
    The digits after the decimal point are meaningless.

    Yes, but I just use it to compare with a standard meter with precision of micro Watt-hour!

  • CaEngineer said:
    ...

    100 / 65535 = 0.0015 Amp.

    Oh you mean the resolution is only 4 decimal points right? Then, why I have let's say: 25.68645 and it is changing!? ...

    [/quote]

    If the ADC reading is 65535 when the current is exactly 100 Amp, then the resolution is 0.0015259021896696421759365224689097............ Amp

    If that ADC reads 16833, calculation will result of what appears to be a current of 25.685511558709086747539482719158..... Amp

    But actually, the current is anywhere between 25.685511558709086747539482719158...... Amp and 25.687037460898756389715419241627..... Amp

    It is my opinion that only 25.68 is significant, all the other digits (no matter how many) are meaningless even under perfect conditions. By perfect conditions, I mean the reference voltage is dead steady, and the shut resister etc. does not pickup or generate any noise (is it enclosed in a Faraday-cage and immersed in liquid helium? ;-)

    The ADC reading may not be stable to the last bit, thus the readings will vary even more.

  • old_cow_yellow said:
    all the other digits (no matter how many) are meaningless even under perfect conditions

    Then we won't get the micro resolution! :(

    BTW, we decide to work on the pulse weight instead of resolution consideration .... still dunno how does it exactly work!

  • CaEngineer said:

    BTW, we decide to work on the pulse weight instead of resolution consideration .... still dunno how does it exactly work!

    I hard of pulse height, pulse width, etc. Never hard the term pulse wight before.

    In the context of a particular energy meter, may be (I am just guessing) that meter emits an IR pulse whenever it accumulates a certain fixed amount of kWattHr so that an external device could count the pulses. Is that fixed amount of kWattHr the "weight" of the each pulse?

    By the way, Steven Underwood finally answered one of your many postings. Did you forget that you want to contact him? 

  • old_cow_yellow said:
    Is that fixed amount of kWattHr the "weight" of the each pulse?

    Yes. Plan is to increase pulse granularity because as you did show previously - ADC have not enough resolution. I am just explaining this to you, cow - so you can understand.

  • llmars,

    Thank you. I hope they do not encode the weight in the pulse width or things like that, so that one only need to count the number of pulses.

    --OCY

  • old_cow_yellow said:
    In the context of a particular energy meter, may be (I am just guessing) that meter emits an IR pulse whenever it accumulates a certain fixed amount of kWattHr so that an external device could count the pulses. Is that fixed amount of kWattHr the "weight" of the each pulse?

    Correct! 

    It is a bucket it fills the bucket with watt hour and shows it with Total_consume to get the high resolution I need to change the size of bucket but still need to find out how!!!

    old_cow_yellow said:
    By the way, Steven Underwood finally answered one of your many postings. Did you forget that you want to contact him? 

    Where?! No! I did not see it!

  • The following is the energy calculation and I believe I need to apply some changes to get more decimal points!

    #if defined(TOTAL_ACTIVE_ENERGY_SUPPORT)
        /* We now play the last measurement interval's power level, evaluated
           in the foreground, through this measurement interval. In this way
           we can evenly pace the pulsing of the LED. The only error produced
           by this is the ambiguity in the number of samples per measurement.
           This should not exceed 1 or 2 in over 4000. */
        #if defined(LIMP_MODE_SUPPORT)
        if (operating_mode == OPERATING_MODE_NORMAL)
        {
        #endif
        
        #if defined(INHIBIT_NEGATIVE_TOTAL_POWER_ACCUMULATION)
            if (total_active_power > 0  &&  (total_active_power_counter += total_active_power) >= TOTAL_ENERGY_PULSE_THRESHOLD)
        #else
            if ((total_active_power_counter += total_active_power) >= TOTAL_ENERGY_PULSE_THRESHOLD)
        #endif
            {
                total_active_power_counter -= TOTAL_ENERGY_PULSE_THRESHOLD;
        #if TOTAL_ENERGY_PULSES_PER_KW_HOUR < 1000
                if (++extra_total_active_power_counter >= 16)
                {
                    extra_total_active_power_counter = 0;
        #endif
                    ++total_consumed_active_energy;
                    /* Ideally we want to log the energy each kWh unit, but doing
                       it with a mask here is good enough and faster. */
                    if ((total_consumed_active_energy & 0x3FF) == 0)
                        phase->status |= ENERGY_LOGABLE;
                    /* Pulse the LED. Long pulses may not be reliable, as at full
                       power we may be pulsing many times per second. People may
                       check the meter's calibration with an instrument that counts
                       the pulsing rate, so it is important the pulses are clear,
                       distinct, and exactly at the rate of one per
                       1/ENERGY_PULSES_PER_KW_HOUR kW/h. */
        #if defined(total_active_energy_pulse_start)
            #if defined(FINE_ENERGY_PULSE_TIMING_SUPPORT)
                    /* TODO: This will not work if extra_total_active_power_counter is in use */
                    /* Work out the fraction of an ADC interrupt, in 1/10ths of an ADC interrupt period,
                       at which the real transition occurs */
                    /* Break up the loop a bit, for efficiency */
                    xxx = total_active_power_counter << 1;
                    j = 10;
                    if (xxx >= total_active_power)
                    {
                        xxx -= total_active_power;
                        j = 5;
                    }
                    xxx += (xxx << 2);
                    do
                        j--;
                    while ((xxx -= total_active_power) > 0)
                        ;
                    /* j is now our fraction of an ADC interrupt. If we use this right now to control timer A
                       its effect would be indeterminate. We need timer A to be updated at the very start of an
                       ADC interrupt service, to ensure the fraction of an ADC interrupt is programmed into the
                       timer while its count is at a well defined value - zero. */
                    fine_pulse_operation = OUTMOD_5 | SCS;
                    TACCR2 = j;
            #else
                    total_active_energy_pulse_start();
            #endif
                    total_active_energy_pulse_remaining_time = ENERGY_PULSE_DURATION;
        #endif

  • It is said that the following DOES NOT AFFECT the process of Accumulation. I know it fills up the bucket but what is the way to change the process then?

    /*! This sets the number of pulses per kilo-watt hour the meter will produce at
    its total energy pulse LED. It does not affect the energy accumulation process. */
    #define TOTAL_ENERGY_PULSES_PER_KW_HOUR 1600

  • The value 1600 means there are 1600 pulses per kWh or one pulse every 3600000/1600 = 2250Ws. So if the bucket internally counts Ws, then every 2250Ws a pulse is emitted. If you change it to 3600, then every 1000Ws a pulse is generated. I don’t know the internal resolution of the bucket. You need to know it because the pulse rate (or rather the number of bucket units per pulse) needs to be an exact integer or you’ll get rounding errors that accumulate.
    Also, when the pulses are generated with an LED or an Optocoupler or relay (the commonly used potential-free S0-Interface), then there is a limit for the pulse frequency. And therefore for the maximum power that can be signaled with this pulse rate. (On S0, the typical pulsewidth is 20ms, resulting in max 25Hz pulse frequency.

    Ps..: yes, Steve has answered in one of your threads.: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/332172/1160987.aspx#1160987

**Attention** This is a public forum