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.

MSP430F67791: The question about the library is EmSwLib.h (Dividing energy into exports and imports)

Part Number: MSP430F67791
Other Parts Discussed in Thread: MSP430F67641

We use the MSP430F67791 microcontroller for the electricity meter. In our implementation, it is necessary to divide energy into exports and imports. There is no such division in the implementation of the emswlib.h library. The library itself is closed.


Previously, the MSP430F67641 microcontroller was used, for this there was support for the division of energy into import and export.

Please tell me how we can get the opportunity to divide Active and Reactive energy into imports and exports?

  • Hi Dennis,

    Can you tell me what is import and export? import to where and export to where?

    Can you tell me the method about your application, then I can help to think how to give you help?

    Why F67641 can work? Do you use old e-meter driverlib on it?

    Eason

  • Hello.

    By import and export, I mean the division of energy storage into four registers (Active+, Active-, Reactive+, Reactive-)
    So that active and reactive energies are accumulated not according to absolute values, but according to sign values.
    If the active power has the + sign, then the active energy + is accumulated, if the active power has the - sign, then the active energy is accumulated with the - sign in a separate register, and for reactive energy it is the same so that the inductive energy and separately the capacitive one are accumulated separately.
    Below is a picture.
    Yes, for the F67641 we used the old drivers, below, also a part of the code from the old driver, where you can see how the accumulated energy is divided depending on the direction in separate registers.

    #if defined(ACTIVE_ENERGY_SUPPORT)  ||  defined(TOTAL_ACTIVE_ENERGY_SUPPORT)
        APP_ACTIVE_ENERGY_IMPORTED,
        APP_ACTIVE_ENERGY_EXPORTED,
    #endif
    
    #if defined(REACTIVE_ENERGY_SUPPORT)  ||  defined(TOTAL_REACTIVE_ENERGY_SUPPORT)
        APP_REACTIVE_ENERGY_QUADRANT_I,
        APP_REACTIVE_ENERGY_QUADRANT_II,
        APP_REACTIVE_ENERGY_QUADRANT_III,
        APP_REACTIVE_ENERGY_QUADRANT_IV,
    #endif
    
    #if defined(ACTIVE_ENERGY_SUPPORT)
        *((uint64_t *) &tx16[1]) = energy_consumed[phx][APP_ACTIVE_ENERGY_IMPORTED];
        *((uint64_t *) &tx16[5]) = energy_consumed[phx][APP_ACTIVE_ENERGY_EXPORTED];
    #else
    
    #if defined(REACTIVE_ENERGY_SUPPORT)
        *((uint64_t *) &tx16[9]) = energy_consumed[phx][APP_REACTIVE_ENERGY_QUADRANT_I];
        *((uint64_t *) &tx16[13]) = energy_consumed[phx][APP_REACTIVE_ENERGY_QUADRANT_II];
        *((uint64_t *) &tx16[17]) = energy_consumed[phx][APP_REACTIVE_ENERGY_QUADRANT_III];
        *((uint64_t *) &tx16[21]) = energy_consumed[phx][APP_REACTIVE_ENERGY_QUADRANT_IV];
    #else

  • Hi Dennis,

    I got it. So you want to accumulate the positive and negative energy spready.

    The attached file will tell you how the EMlib calculate the result. Maybe can give a little help.

    Energy Library Specifications KV.docx V5.pdf  

    As the driverlib is not open source to customer, I think you can do some compare with the energy result after the function runs in ADC ISR. Then you can spread the positive and negative result manually.

    Eason

  • Hello.

    Thanks for your reply.

    As far as I understand, in the old driver, the math and calculations were performed through hardware multipliers, accumulators and through assembler inserts. In a EMlib library, it is not clear how the calculation takes place?

  • It use IQmathlib. For IQmathlib, it will automatically use the hardware multiplier to do the calculation. Besides, for the math function, it also use the assembly code. 

    Anyway, sorry we have no plan to open this version EMlib to customer. I advice you to handle the problem based on the high level parameters. If you meet any problem, please let me know.

**Attention** This is a public forum