emSwLib.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,TI
2  *MSP Source and Object Code Software License Agreement
3  *
4  *
5  **IMPORTANT - PLEASE CAREFULLY READ THE FOLLOWING LICENSE AGREEMENT, WHICH IS LEGALLY BINDING. AFTER YOU READ IT, YOU WILL BE ASKED WHETHER YOU ACCEPT AND AGREE TO ITS TERMS. DO NOT CLICK "I ACCEPT" UNLESS: (1) YOU WILL USE THE LICENSED MATERIALS FOR YOUR OWN BENEFIT AND PERSONALLY ACCEPT, AGREE TO AND INTEND TO BE BOUND BY THESE TERMS; OR (2) YOU ARE AUTHORIZED TO, AND INTEND TO BE BOUND BY, THESE TERMS ON BEHALF OF YOUR COMPANY.
6  *
7  *
8  **Important - Read carefully: This Source and Object Code Software License Agreement ("Agreement") is a legal agreement between you and Texas Instruments Incorporated ("TI"). In this Agreement "you" means you personally if you will exercise the rights granted for your own benefit, but it means your company (or you on behalf of your company) if you will exercise the rights granted for your company's benefit. The "Licensed Materials" subject to this Agreement include the software programs and any associated electronic documentation (in each case, in whole or in part) that accompany this Agreement, are set forth in the applicable software manifest and you access "on-line", as well as any updates or upgrades to such software programs or documentation, if any, provided to you at TI's sole discretion. The Licensed Materials are specifically designed and licensed for use solely and exclusively with MSP microcontroller devices manufactured by or for TI ("TI Devices"). By installing, copying or otherwise using the Licensed Materials you agree to abide by the provisions set forth herein. This Agreement is displayed for you to read prior to using the Licensed Materials. If you choose not to accept or agree with these provisions, do not download or install the Licensed Materials.
9  *
10  **Note Regarding Possible Access to Other Licensed Materials: The Licensed Materials may be bundled with software and associated electronic documentation, if any, licensed under terms other than the terms of this Agreement (in whole or in part, "Other Licensed Materials"), including, for example Open Source Software and/or TI-owned or third party Proprietary Software licensed under such other terms. "Open Source Software" means any software licensed under terms requiring that (A) other software ("Proprietary Software") incorporated, combined or distributed with such software or developed using such software: (i) be disclosed or distributed in source code form; or (ii) otherwise be licensed on terms inconsistent with the terms of this Agreement, including but not limited to permitting use of the Proprietary Software on or with devices other than TI Devices, or (B) require the owner of Proprietary Software to license any of its patents to users of the Open Source Software and/or Proprietary Software incorporated, combined or distributed with such Open Source Software or developed using such Open Source Software.
11  *
12  **If by accepting this Agreement, you gain access to Other Licensed Materials, they will be listed in the applicable software manifest. Your use of the Other Licensed Materials is subject to the applicable other licensing terms acknowledgements and disclaimers as specified in the applicable software manifest and/or identified or included with the Other Licensed Materials in the software bundle. For clarification, this Agreement does not limit your rights under, or grant you rights that supersede, the terms of any applicable Other Licensed Materials license agreement. If any of the Other Licensed Materials is Open Source Software that has been provided to you in object code only under terms that obligate TI to provide to you or show you where you can access the source code versions of such Open Source Software, TI will provide to you, or show you where you can access, such source code if you contact TI at Texas Instruments Incorporated, 12500 TI Boulevard, Mail Station 8638, Dallas, Texas 75243, Attention: Contracts Manager, Embedded Processing. In the event you choose not to accept or agree with the terms in any applicable Other Licensed Materials license agreement, you must terminate this Agreement.
13  *
14  **1. License Grant and Use Restrictions.
15  *
16  **a. Licensed Materials License Grant. Subject to the terms of this Agreement, TI hereby grants to you a limited, non-transferable, non-exclusive, non-assignable, non-sublicensable, fully paid-up and royalty-free license to:
17  *
18  * i. Limited Source Code License: make copies, prepare derivative works, display internally and use internally the Licensed Materials provided to you in source code for the sole purpose of developing object and executable versions of such Licensed Materials, or any derivative thereof, that execute solely and exclusively on TI Devices, for end use in Licensee Products, and maintaining and supporting such Licensed Materials, or any derivative thereof, and Licensee Products. For purposes of this Agreement, "Licensee Product" means a product that consists of both hardware, including one or more TI Devices, and software components, including only executable versions of the Licensed Materials that execute solely and exclusively on such TI Devices.
19  *
20  * ii. Object Code Evaluation, Testing and Use License: make copies, display internally, distribute internally and use internally the Licensed Materials in object code for the sole purposes of evaluating and testing the Licensed Materials and designing and developing Licensee Products, and maintaining and supporting the Licensee Products;
21  *
22  * iii. Demonstration License: demonstrate to third parties the Licensed Materials executing solely and exclusively on TI Devices as they are used in Licensee Products, provided that such Licensed Materials are demonstrated in object or executable versions only and
23  *
24  * iv. Production and Distribution License: make, use, import, export and otherwise distribute the Licensed Materials as part of a Licensee Product, provided that such Licensee Products include only embedded executable copies of such Licensed Materials that execute solely and exclusively on TI Devices.
25  *
26  * b. Contractors. The licenses granted to you hereunder shall include your on-site and off-site contractors (either an individual or entity), while such contractors are performing work for or providing services to you, provided that such contractors have executed work-for-hire agreements with you containing applicable terms and conditions consistent with the terms and conditions set forth in this Agreement and provided further that you shall be liable to TI for any breach by your contractors of this Agreement to the same extent as you would be if you had breached the Agreement yourself.
27  *
28  * c. No Other License. Nothing in this Agreement shall be construed as a license to any intellectual property rights of TI other than those rights embodied in the Licensed Materials provided to you by TI. EXCEPT AS PROVIDED HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHTS IS GRANTED HEREIN.
29  *
30  * d. Covenant not to Sue. During the term of this Agreement, you agree not to assert a claim against TI or its licensees that the Licensed Materials infringe your intellectual property rights.
31  *
32  * e. Restrictions. You shall maintain the source code versions of the Licensed Materials under password control protection and shall not disclose such source code versions of the Licensed Materials, to any person other than your employees and contractors whose job performance requires access. You shall not use the Licensed Materials with a processing device other than a TI Device, and you agree that any such unauthorized use of the Licensed Materials is a material breach of this Agreement. You shall not use the Licensed Materials for the purpose of analyzing or proving infringement of any of your patents by either TI or TI's customers. Except as expressly provided in this Agreement, you shall not copy, publish, disclose, display, provide, transfer or make available the Licensed Materials to any third party and you shall not sublicense, transfer, or assign the Licensed Materials or your rights under this Agreement to any third party. You shall not mortgage, pledge or encumber the Licensed Materials in any way. You may use the Licensed Materials with Open Source Software or with software developed using Open Source Software tools provided you do not incorporate, combine or distribute the Licensed Materials in a manner that subjects the Licensed Materials to any license obligations or any other intellectual property related terms of any license governing such Open Source Software.
33  *
34  * f. Termination. This Agreement is effective on the date the Licensed Materials are delivered to you together with this Agreement and will remain in full force and effect until terminated. You may terminate this Agreement at any time by written notice to TI. Without prejudice to any other rights, if you fail to comply with the terms of this Agreement or you are acquired, TI may terminate your right to use the Licensed Materials upon written notice to you. Upon termination of this Agreement, you will destroy any and all copies of the Licensed Materials in your possession, custody or control and provide to TI a written statement signed by your authorized representative certifying such destruction. Except for Sections 1(a), 1(b) and 1(d), all provisions of this Agreement shall survive termination of this Agreement.
35  *
36  **2. Licensed Materials Ownership. The Licensed Materials are licensed, not sold to you, and can only be used in accordance with the terms of this Agreement. Subject to the licenses granted to you pursuant to this Agreement, TI and its licensors own and shall continue to own all right, title and interest in and to the Licensed Materials, including all copies thereof. You agree that all fixes, modifications and improvements to the Licensed Materials conceived of or made by TI that are based, either in whole or in part, on your feedback, suggestions or recommendations are the exclusive property of TI and all right, title and interest in and to such fixes, modifications or improvements to the Licensed Materials will vest solely in TI. Moreover, you acknowledge and agree that when your independently developed software or hardware components are combined, in whole or in part, with the Licensed Materials, your right to use the combined work that includes the Licensed Materials remains subject to the terms and conditions of this Agreement.
37  *
38  **3. Intellectual Property Rights.
39  *
40  * a. The Licensed Materials contain copyrighted material, trade secrets and other proprietary information of TI and its licensors and are protected by copyright laws, international copyright treaties, and trade secret laws, as well as other intellectual property laws. To protect TI's and its licensors' rights in the Licensed Materials, you agree, except as specifically permitted by statute by a provision that cannot be waived by contract, not to "unlock", decompile, reverse engineer, disassemble or otherwise translate to a human-perceivable form any portions of the Licensed Materials provided to you in object code format only, nor permit any person or entity to do so. You shall not remove, alter, cover, or obscure any confidentiality, trade secret, trade mark, patent, copyright or other proprietary notice or other identifying marks or designs from any component of the Licensed Materials and you shall reproduce and include in all copies of the Licensed Materials the copyright notice(s) and proprietary legend(s) of TI and its licensors as they appear in the Licensed Materials. TI reserves all rights not specifically granted under this Agreement.
41  *
42  * b. Certain Licensed Materials may be based on industry recognized standards or software programs published by industry recognized standards bodies and certain third parties may claim to own patents, copyrights, and other intellectual property rights that cover implementation of those standards. You acknowledge and agree that this Agreement does not convey a license to any such third party patents, copyrights, and other intellectual property rights and that you are solely responsible for any patent, copyright, or other intellectual property right claim that relates to your use or distribution of the Licensed Materials or your use or distribution of your products that include or incorporate the Licensed Materials. Moreover, you acknowledge that you are responsible for any fees or royalties that may be payable to any third party based on such third party's interests in the Licensed Materials or any intellectual property rights that cover implementation of any industry recognized standard, any software program published by any industry recognized standards bodies or any other proprietary technology.
43  *
44  **4. Confidential Information. You acknowledge and agree that the Licensed Materials contain trade secrets and other confidential information of TI and its licensors. You agree to use the Licensed Materials solely within the scope of the licenses set forth herein, to maintain the Licensed Materials in strict confidence, to use at least the same procedures and degree of care that you use to prevent disclosure of your own confidential information of like importance but in no instance less than reasonable care, and to prevent disclosure of the Licensed Materials to any third party, except as may be necessary and required in connection with your rights and obligations hereunder; provided, however, that you may not provide the Licensed Materials to any business organization or group within your company or to customers or contractors that design or manufacture semiconductors unless TI gives written consent. You agree to obtain executed confidentiality agreements with your employees and contractors having access to the Licensed Materials and to diligently take steps to enforce such agreements in this respect. TI may disclose your contact information to TI's licensors.
45  *
46  **5. Warranties and Limitations. THE LICENSED MATERIALS ARE PROVIDED "AS IS". FURTHERMORE, YOU ACKNOWLEDGE AND AGREE THAT THE LICENSED MATERIALS HAVE NOT BEEN TESTED OR CERTIFIED BY ANY GOVERNMENT AGENCY OR INDUSTRY REGULATORY ORGANIZATION OR ANY OTHER THIRD PARTY ORGANIZATION. YOU AGREE THAT PRIOR TO USING, INCORPORATING OR DISTRIBUTING THE LICENSED MATERIALS IN OR WITH ANY COMMERCIAL PRODUCT THAT YOU WILL THOROUGHLY TEST THE PRODUCT AND THE FUNCTIONALITY OF THE LICENSED MATERIALS IN OR WITH THAT PRODUCT AND BE SOLELY RESPONSIBLE FOR ANY PROBLEMS OR FAILURES.
47  *
48  **TI AND ITS LICENSORS MAKE NO WARRANTY OR REPRESENTATION, EITHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE LICENSED MATERIALS, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER INTELLECTUAL PROPERTY RIGHTS. YOU AGREE TO USE YOUR INDEPENDENT JUDGMENT IN DEVELOPING YOUR PRODUCTS. NOTHING CONTAINED IN THIS AGREEMENT WILL BE CONSTRUED AS A WARRANTY OR REPRESENTATION BY TI TO MAINTAIN PRODUCTION OF ANY TI SEMICONDUCTOR DEVICE OR OTHER HARDWARE OR SOFTWARE WITH WHICH THE LICENSED MATERIALS MAY BE USED.
49  *
50  **IN NO EVENT SHALL TI OR ITS LICENSORS, BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, IN CONNECTION WITH OR ARISING OUT OF THIS AGREEMENT OR THE USE OF THE LICENSED MATERIALS REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF REMOVAL OR REINSTALLATION, OUTSIDE COMPUTER TIME, LABOR COSTS, LOSS OF DATA, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S OR ITS LICENSORS' AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF YOUR USE OF THE LICENSED MATERIALS EXCEED FIVE HUNDRED U.S. DOLLARS (US$500).
51  *
52  * Because some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages or limitation on how long an implied warranty lasts, the above limitations or exclusions may not apply to you.
53  *
54  **6. Indemnification Disclaimer. YOU ACKNOWLEDGE AND AGREE THAT TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY THIRD PARTY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON YOUR MANUFACTURE, USE, OR DISTRIBUTION OF THE LICENSED MATERIALS OR YOUR MANUFACTURE, USE, OFFER FOR SALE, SALE, IMPORTATION OR DISTRIBUTION OF YOUR PRODUCTS THAT INCLUDE OR INCORPORATE THE LICENSED MATERIALS.
55  *
56  **7. No Technical Support. TI and its licensors are under no obligation to install, maintain or support the Licensed Materials.
57  *
58  **8. Notices. All notices to TI hereunder shall be delivered to Texas Instruments Incorporated, 12500 TI Boulevard, Mail Station 8638, Dallas, Texas 75243, Attention: Contracts Manager - Embedded Processing, with a copy to Texas Instruments Incorporated, 13588 N. Central Expressway, Mail Station 3999, Dallas, Texas 75243, Attention: Law Department - Embedded Processing. All notices shall be deemed served when received by TI.
59  *
60  **9. Export Control. The Licensed Materials are subject to export control under the U.S. Commerce Department's Export Administration Regulations ("EAR"). Unless prior authorization is obtained from the U.S. Commerce Department, neither you nor your subsidiaries shall export, re-export, or release, directly or indirectly (including, without limitation, by permitting the Licensed Materials to be downloaded), any technology, software, or software source code, received from TI, or export, directly or indirectly, any direct product of such technology, software, or software source code, to any person, destination or country to which the export, re-export, or release of the technology, software, or software source code, or direct product is prohibited by the EAR. You represent and warrant that you (i) are not located in, or under the control of, a national or resident of Cuba, Iran, North Korea, Sudan and Syria or any other country subject to a U.S. goods embargo; (ii) are not on the U.S. Treasury Department's List of Specially Designated Nationals or the U.S. Commerce Department's Denied Persons List or Entity List; and (iii) will not use the Licensed Materials or transfer the Licensed Materials for use in any military, nuclear, chemical or biological weapons, or missile technology end-uses. Any software export classification made by TI shall not be construed as a representation or warranty regarding the proper export classification for such software or whether an export license or other documentation is required for the exportation of such software.
61  *
62  **10. Governing Law and Severability; Waiver. This Agreement will be governed by and interpreted in accordance with the laws of the State of Texas, without reference to conflict of laws principles. If for any reason a court of competent jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum extent possible to effectuate the intent of the parties, and the remainder of the Agreement shall continue in full force and effect. This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods, or by the Uniform Computer Information Transactions Act (UCITA). The parties agree that non-exclusive jurisdiction for any dispute arising out of or relating to this Agreement lies within the courts located in the State of Texas. Notwithstanding the foregoing, any judgment may be enforced in any United States or foreign court, and either party may seek injunctive relief in any United States or foreign court. Failure by TI to enforce any provision of this Agreement shall not be deemed a waiver of future enforcement of that or any other provision in this Agreement or any other agreement that may be in place between the parties.
63  *
64  **11. PRC Provisions. If you are located in the People's Republic of China ("PRC") or if the Licensed Materials will be sent to the PRC, the following provisions shall apply:
65  *
66  * a. Registration Requirements. You shall be solely responsible for performing all acts and obtaining all approvals that may be required in connection with this Agreement by the government of the PRC, including but not limited to registering pursuant to, and otherwise complying with, the PRC Measures on the Administration of Software Products, Management Regulations on Technology Import-Export, and Technology Import and Export Contract Registration Management Rules. Upon receipt of such approvals from the government authorities, you shall forward evidence of all such approvals to TI for its records. In the event that you fail to obtain any such approval or registration, you shall be solely responsible for any and all losses, damages or costs resulting therefrom, and shall indemnify TI for all such losses, damages or costs.
67  *
68  **b. Governing Language. This Agreement is written and executed in the English language and shall be authoritative and controlling, whether or not translated into a language other than English to comply with law or for reference purposes. If a translation of this Agreement is required for any purpose, including but not limited to registration of the Agreement pursuant to any governmental laws, regulations or rules, you shall be solely responsible for creating such translation.
69  *
70  **12. Contingencies. TI shall not be in breach of this Agreement and shall not be liable for any non-performance or delay in performance if such non-performance or delay is due to a force majeure event or other circumstances beyond TI's reasonable control.
71  *
72  **13. Entire Agreement. This is the entire agreement between you and TI and this Agreement supersedes any prior agreement between the parties related to the subject matter of this Agreement. Notwithstanding the foregoing, any signed and effective software license agreement relating to the subject matter hereof and stating expressly that such agreement shall control regardless of any subsequent click-wrap, shrink-wrap or web-wrap, shall supersede the terms of this Agreement. No amendment or modification of this Agreement will be effective unless in writing and signed by a duly authorized representative of TI. You hereby warrant and represent that you have obtained all authorizations and other applicable consents required empowering you to enter into this Agreement.
73  *
74  *
75  *
76  * --/COPYRIGHT--*/
77 
78 #ifndef _EMSWLIB_H_
79 #define _EMSWLIB_H_
80 
81 //#############################################################################
82 //
88 //
89 // Group: MSP
90 // Target Device: MSP430F677x1A, MSP430F673xA and MSP430i20xx
91 //
92 // (C) Copyright 2017, Texas Instruments, Inc.
93 //#############################################################################
94 // TI Release: MSP430_ENERGY_MEASUREMENT
95 // Release Date: 10Jul2018
96 //#############################################################################
97 
98 
99 //*****************************************************************************
100 // includes
101 //*****************************************************************************
102 #include <msp430.h>
103 
104 #include <stdint.h>
105 #include <stdbool.h>
106 #include "IQmathLib.h"
107 #include "QmathLib.h"
108 
109 #ifdef __cplusplus
110 
111 extern "C" {
112 #endif
113 
114 //*****************************************************************************
115 // defines
116 //*****************************************************************************
117 
120  #define EM_PHASE_RESULT_CALC_VRMS BIT0
121  #define EM_PHASE_RESULT_CALC_IRMS BIT1
124  #define EM_PHASE_RESULT_CALC_V_PEAK BIT2
127  #define EM_PHASE_RESULT_CALC_I_PEAK BIT3
130  #define EM_PHASE_RESULT_CALC_POWER_FACTOR BIT4
133  #define EM_PHASE_RESULT_CALC_FREQ BIT5
136 #define EM_PHASE_RESULT_CALC_ACTIVE_POWER BIT6
139 #define EM_PHASE_RESULT_CALC_REACTIVE_POWER BIT7
142 #define EM_PHASE_RESULT_CALC_APPARENT_POWER BIT8
145 #define EM_PHASE_RESULT_CALC_ACTIVE_ENERGY BIT9
148 #define EM_PHASE_RESULT_CALC_REACTIVE_ENERGY BIT10
151 #define EM_PHASE_RESULT_CALC_APPARENT_ENERGY BIT11
154 
157 #define EM_PULSE_GEN_PHASE_NONE (0x00)
158 #define EM_PULSE_GEN_PHASE_A (0x01)
161 #define EM_PULSE_GEN_PHASE_B (0x02)
164 #define EM_PULSE_GEN_PHASE_C (0x04)
167 #define EM_PULSE_GEN_PHASE_D (0x08)
170 #define EM_PULSE_GEN_PHASE_E (0x10)
173 #define EM_PULSE_GEN_PHASE_F (0x20)
176 #define EM_PULSE_GEN_PHASE_NEUTRAL (0x40)
180 #define EM_PULSE_GEN_PHASE_AGGREGATE (0x80)
184 
185 //*****************************************************************************
186 // typedefs
187 //*****************************************************************************
188 
192 typedef enum _EM_message_code_
193 {
194 
198 
199  // 1-20 reserved for system configuration messages
217 
218  // 21-40 reserved for algorithm configuration messages
227 
228  // 41-59 reserved for meter configuration messages
233 
234  // 60-249 reserved for calibration messages
237 
238  //240-255 error
243 
247 {
255 
258 typedef int64_t EM_Power_t;
259 
262 typedef uint64_t EM_Energy_t;
263 
266 typedef enum _EM_Phase_
267 {
282 } EM_Phase;
283 
284 
287 typedef struct _EM_Pulse_Settings_
288 {
344 
348 {
377 
378 
382 {
383  uint32_t voltageSF;
385  uint32_t currentSF;
387  uint32_t activePowerSF;
389  uint32_t reactivePowerSF;
393 
395 
399 {
425 
429 {
432  uint8_t phaseLength;
434  uint8_t *meterName;
438  uint8_t *meterPW;
439  //~< Pointer to meter password string
441 
445 {
452  uint8_t mainNomFreq;
458  uint16_t freqSampling;
468 
472 {
480 
481 typedef struct _EM_Metrology_
482 {
483  int16_t sampleCount;
486  int64_t actPowDotProd;
492  int16_t vDotProd[3];
497  int64_t iDotProd;
507  uint32_t mainPeriod;
509  uint32_t prevMainPeriod;
511  _iq30 oneDivSC;
513  uint16_t prevSampleCount;
516  uint8_t cycleCount;
519 } EM_Metrology;
520 
523 typedef struct _EM_Phase_BG_Results_
524 {
525  int32_t vDCEstimate;
527  int16_t iDCEstimate[3];
531  int16_t vPrevSample;
535  int32_t iPrevSample;
538 
541 typedef struct _EM_Phase_Results_
542 {
543  uint32_t VRMS;
545  uint32_t IRMS;
547  uint32_t vPeak;
549  uint32_t iPeak;
551  int32_t powerFactor;
553  uint16_t frequency;
556  EM_Power_t activePower;
558  EM_Power_t reactivePower;
560  EM_Power_t apparentPower;
562  EM_Energy_t activeEnergy;
564  EM_Energy_t reactiveEnergy;
566  EM_Energy_t apparentEnergy;
571 
574 typedef struct _EM_Total_Results_
575 {
576  EM_Power_t activePower;
578  EM_Power_t reactivePower;
580  EM_Power_t apparentPower;
582  EM_Energy_t activeEnergy;
584  EM_Energy_t reactiveEnergy;
586  EM_Energy_t apparentEnergy;
589 
593 {
607 
608 //*****************************************************************************
609 // globals
610 //*****************************************************************************
612 extern uint16_t * EMSWLIB_EM_HAL_ADC_maxFreqCount;
613 
615 extern uint16_t * EMSWLIB_EM_HAL_ADC_minFreqCount;
616 
617 //*****************************************************************************
618 // the function prototypes
619 //*****************************************************************************
620 
621 /*******************************************************************************
622  * EM SW LIBRARY CONFIGURATION APIS
623  ******************************************************************************/
624 //*****************************************************************************
625 //
628 //
629 //******************************************************************************
641  EM_SW_Lib_Config_Handle *config,
642  EM_SW_Lib_Result_Handle *result);
643 
651 extern void EM_initDCFilters(
652  EM_SW_Lib_Config_Handle *config,
653  EM_SW_Lib_Result_Handle *result);
654 
655 //******************************************************************************
656 //
657 // Close the Doxygen group.
659 //
660 //******************************************************************************
661 
662 /*******************************************************************************
663  * EM SW LIBRARY CALIBRATION APIS
664  ******************************************************************************/
665 //*****************************************************************************
666 //
669 //
670 //******************************************************************************
683  uint8_t *pWorkingCalibration,
684  uint8_t *pFlashCalibration);
685 
697  uint8_t *pWorkingCalibration,
698  uint8_t *pFlashCalibration);
699 
700 //******************************************************************************
701 //
702 // Close the Doxygen group.
704 //
705 //******************************************************************************
706 
707 /*******************************************************************************
708  * EM SW LIBRARY RESULT APIS
709  ******************************************************************************/
710 //*****************************************************************************
711 //
714 //
715 //******************************************************************************
729 extern int16_t EM_voltageDCFilter(
730  int32_t *p,
731  int16_t x);
732 
746 extern int32_t EM_currentDCFilter(
747  int16_t p[3],
748  int32_t x);
749 
761 extern void EM_perSample(
762  EM_Metrology *metro,
763  EM_Phase_Configuration *phase,
764  EM_Phase_BG_Results *bgData);
765 
778 extern void EM_perDataChunk(
779  EM_SW_Lib_Config_Handle *config,
780  EM_SW_Lib_Result_Handle *result,
781  uint16_t phaseIdx);
782 
796 extern void EM_delayCurrent90Degrees(EM_Metrology *metro,
797  EM_Phase_Configuration *phase,
798  EM_Phase_BG_Results *bgData);
799 
812 extern void EM_genPulseIndPhase(
813  EM_System_Configuration *config,
814  EM_Pulse_Settings *pulse,
815  EM_Phase_Results *result);
816 
829 extern void EM_genPulseTotalPhases(
830  EM_System_Configuration *config,
831  EM_Pulse_Settings *pulse,
832  EM_Total_Results *result);
833 
843 extern void EM_updateOneDivSC(
844  EM_Metrology *metro);
845 
854 extern void EM_clearMetrology(
855  EM_Metrology *metro);
856 
869 extern void EM_updateReactPowConst(EM_Metrology *metro,
870  EM_Phase_Results *result,
872 
882  EM_SW_Lib_Config_Handle *config);
883 
895 extern void EM_calcActivePowerMultAcc(
896  EM_Metrology *metro,
897  EM_Phase_Configuration *phase);
898 
912 extern void EM_calcActivePowerDiv(
913  EM_Metrology *metro,
914  EM_Phase_Configuration *phase,
915  EM_Phase_Results *result,
917 
930 extern void EM_calcActiveEnergy(
931  EM_Metrology *metro,
933  EM_Phase_Results *result);
934 
952 extern void EM_calcReactivePowerMultAcc(
953  EM_Metrology *metro,
954  EM_Phase_Configuration *phase,
955  EM_Phase_BG_Results *bgData);
956 
970 extern void EM_calcReactivePowerDiv(
971  EM_Metrology *metro,
972  EM_Phase_Configuration *phase,
973  EM_Phase_Results *result,
975 
988 extern void EM_calcReactiveEnergy(
989  EM_Metrology *metro,
991  EM_Phase_Results *result);
992 
1003 extern void EM_calcApparentPower(
1004  EM_Phase_Results *result);
1005 
1018 extern void EM_calcApparentEnergy(
1019  EM_Metrology *metro,
1021  EM_Phase_Results *result);
1022 
1033 extern void EM_calcPowerFactor(
1034  EM_Phase_Results *result);
1035 
1047 extern void EM_calcVRMSMultAcc(
1048  EM_Metrology *metro,
1049  EM_Phase_Configuration *phase);
1050 
1062 extern void EM_calcVRMSDivSqrt(
1063  EM_Metrology *metro,
1064  EM_Phase_Configuration *phase,
1065  EM_Phase_Results *result);
1066 
1078 extern void EM_calcIRMSMultAcc(EM_Metrology *metro,
1079  EM_Phase_Configuration *phase);
1080 
1092 extern void EM_calcIRMSDivSqrt(
1093  EM_Metrology *metro,
1094  EM_Phase_Configuration *phase,
1095  EM_Phase_Results *result);
1096 
1108 extern void EM_calcIPeak(
1109  EM_Phase_Results *result,
1111 
1123 extern void EM_calcVPeak(
1124  EM_Phase_Results *result,
1126 
1156 extern void EM_calcFreqPeriod(
1157  EM_Metrology *metro,
1158  EM_Phase_Configuration *phase,
1159  EM_Phase_BG_Results *bgData);
1160 
1172 extern void EM_calcFreq(
1173  EM_Metrology *metro,
1174  EM_Phase_Results *result,
1176 
1187 extern void EM_calcTotalActivePower(
1188  uint8_t *phaseIdx,
1189  uint8_t length,
1190  EM_SW_Lib_Result_Handle *result);
1191 
1202 extern void EM_calcTotalReactivePower(
1203  uint8_t *phaseIdx,
1204  uint8_t length,
1205  EM_SW_Lib_Result_Handle *result);
1206 
1217 extern void EM_calcTotalApparentPower(
1218  uint8_t *phaseIdx,
1219  uint8_t length,
1220  EM_SW_Lib_Result_Handle *result);
1221 
1222 
1233 extern void EM_calcTotalActiveEnergy(
1234  uint8_t *phaseIdx,
1235  uint8_t length,
1236  EM_SW_Lib_Result_Handle *result);
1237 
1248 extern void EM_calcTotalReactiveEnergy(
1249  uint8_t *phaseIdx,
1250  uint8_t length,
1251  EM_SW_Lib_Result_Handle *result);
1252 
1263 extern void EM_calcTotalApparentEnergy(
1264  uint8_t *phaseIdx,
1265  uint8_t length,
1266  EM_SW_Lib_Result_Handle *result);
1267 
1268 //******************************************************************************
1269 //
1270 // Close the Doxygen group.
1272 //
1273 //******************************************************************************
1274 
1275 #ifdef __cplusplus
1276 }
1277 #endif // extern "C"
1278 
1279 #endif // end of _EMSWLIB_H_ definition
Contains EM SW Lib System Configuration.
Definition: emSwLib.h:347
Contains EM SW Lib Result Handle.
Definition: emSwLib.h:592
struct _EM_Phase_BG_Results_ EM_Phase_BG_Results
Contains EM Phase Background Results.
EM_Total_Results * emTotalResult
Pointer to EM_Total_Results struct.
Definition: emSwLib.h:594
EM_Power_t reactivePower
Reactive Power for previous frame (uVAr)
Definition: emSwLib.h:558
Definition: emSwLib.h:481
Contains EM Phase Background Results.
Definition: emSwLib.h:523
void EM_calcVPeak(EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to calculate V Peak. This API updates the global Phase Result structure...
EM_System_Configuration * systemConfig
Pointer to EM_System_Configuration struct.
Definition: emSwLib.h:473
EM_Power_t apparentPower
Total Apparent Power since system initialization (uVA)
Definition: emSwLib.h:580
Definition: emSwLib.h:221
int32_t * currentSamplePtr
Pointer to the current sample.
Definition: emSwLib.h:400
Contains EM SW Lib Config Handle.
Definition: emSwLib.h:471
uint8_t * meterName
Pointer to meter name string.
Definition: emSwLib.h:434
void EM_calcVRMSDivSqrt(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result)
The following API is used to calculate the division and square root for VRMS. This API uses the dot p...
Definition: emSwLib.h:270
Contains EM SW Lib Algorithm Configuration.
Definition: emSwLib.h:444
int32_t iPrevSample
Previous Current sample used for the IIR filter in the Rogowski ADC current calculation.
Definition: emSwLib.h:535
int32_t rogowskiPrevI90
Previous I90 current used for the IIR filter in the Rogowski ADC current calculation.
Definition: emSwLib.h:533
void EM_calcTotalActivePower(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total active power. This API will aggregate the total power of...
struct _EM_Metrology_ EM_Metrology
uint8_t cycleCount
Definition: emSwLib.h:516
Definition: emSwLib.h:195
EM_Power_t activePower
Total Active Power since system initialization (uW)
Definition: emSwLib.h:576
enum _EM_Phase_ EM_Phase
Selects appropiate phase to provide results for.
uint8_t activePulseGpioPort
Definition: emSwLib.h:289
Contains EM SW Lib System Configuration.
Definition: emSwLib.h:398
EM_Phase_BG_Results * phaseBGResults
Pointer to the EM_Phase_BG_Results struct buffer.
Definition: emSwLib.h:598
uint32_t VRMS
VRMS for previous frame (mV)
Definition: emSwLib.h:543
EM_Metrology ** phaseMetrologyPong
Pointer to EM_Metrology struct Pong buffer.
Definition: emSwLib.h:602
void EM_genPulseTotalPhases(EM_System_Configuration *config, EM_Pulse_Settings *pulse, EM_Total_Results *result)
The following API is used to generate pulses for the total phase. This API checks if the config->puls...
void EM_calcIRMSDivSqrt(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result)
The following API is used to calculate the division and square root for IRMS. This API uses the dot p...
_iq30 * reactPowIIRTable
Definition: emSwLib.h:466
uint16_t totalPhasePulseDuration
Definition: emSwLib.h:363
EM_Energy_t reactiveEnergy
Reactive Energy for previous frame (uVArh)
Definition: emSwLib.h:564
void EM_updateFlashCalibrationValues(uint8_t *pWorkingCalibration, uint8_t *pFlashCalibration)
The following API is used store working (RAM) pWorkingCalibration values to the pFlashCalibration str...
void EM_initalizeCalibrationValues(uint8_t *pWorkingCalibration, uint8_t *pFlashCalibration)
The following API is used to copies calibration values from flapFlashCalibration to pWorkingCalibrati...
void EM_calcTotalApparentPower(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total apparent power. This API will aggregate the total power ...
EM_Algorithm_Configuration * algorithmConfig
Pointer to EM_Algorithm_Configuration struct.
Definition: emSwLib.h:475
Contains EM Total Results.
Definition: emSwLib.h:574
void EM_calcPowerFactor(EM_Phase_Results *result)
The following API is used to calculate power factor. The formula used to calculate it: activePower / ...
uint8_t phaseLength
Length of the emPhasePtr buffer.
Definition: emSwLib.h:432
uint16_t reactiveEnergyPulseRemaining
Counter used to keep track of remaining ADC samples to keep pulse high.
Definition: emSwLib.h:341
uint16_t * EMSWLIB_EM_HAL_ADC_maxFreqCount
The following variable is used as a maximum ADC count to detect frequency.
struct _EM_SW_Lib_Result_Handle_ EM_SW_Lib_Result_Handle
Contains EM SW Lib Result Handle.
uint32_t reactivePowerSF
Active Power Scaling Factor.
Definition: emSwLib.h:389
struct _EM_Total_Results_ EM_Total_Results
Contains EM Total Results.
struct _EM_Phase_Configuration_ EM_Phase_Configuration
Contains EM SW Lib System Configuration.
Contains EM SW Lib Phase Calibration.
Definition: emSwLib.h:287
_EM_Current_Sensor_
Selects appropriate EM Sensor for the corresponding channel.
Definition: emSwLib.h:246
EM_message_code EM_processSample(EM_SW_Lib_Config_Handle *config)
The following API is used process the samples. It is used to calculate intermediate dot product resul...
void EM_calcTotalReactiveEnergy(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total reactive energy. This API will aggregate the total energ...
uint8_t pulseArrayLength
Length of the pulseArray configuration.
Definition: emSwLib.h:352
int64_t EM_Power_t
Type for Power variables.
Definition: emSwLib.h:258
void EM_delayCurrent90Degrees(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
The following API is used to delay the current degree by 90 degrees. It uses an IIR filter with 1 pol...
void EM_updateReactPowConst(EM_Metrology *metro, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to look up the IIR G constant used to calculate the Reactive Power using th...
EM_Metrology ** phaseMetrologyPing
Pointer to EM_Metrology struct Ping buffer.
Definition: emSwLib.h:600
struct _EM_Algorithm_Configuration_ EM_Algorithm_Configuration
Contains EM SW Lib Algorithm Configuration.
Definition: emSwLib.h:278
void EM_calcFreq(EM_Metrology *metro, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to calculate frequency. This API updates the global Phase Result structure...
EM_Power_t residualPowerCutoff
Definition: emSwLib.h:446
Definition: emSwLib.h:276
Definition: emSwLib.h:268
int16_t * voltageSamplePtr
Pointer to the voltage sample.
Definition: emSwLib.h:402
int16_t sampleCount
Definition: emSwLib.h:483
_EM_message_code_
The following enumeration contain all possible EM SW Library return message codes.
Definition: emSwLib.h:192
void EM_calcTotalReactivePower(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total reactive power. This API will aggregate the total power ...
void EM_updateOneDivSC(EM_Metrology *metro)
The following API is used to calculate the 1/sample_count constant. This function must be executed af...
uint16_t activeEnergyPulseRemaining
Counter used to keep track of remaining ADC samples to keep pulse high.
Definition: emSwLib.h:337
EM_Energy_t activeEnergy
Active Energy for previous frame (uWh)
Definition: emSwLib.h:562
EM_Power_t totalResidualPowerCutoff
Definition: emSwLib.h:449
int16_t reactPowPrevV90
Previous V90 voltage used for the IIR filter in the reactive power calculation.
Definition: emSwLib.h:529
_EM_Phase_
Selects appropiate phase to provide results for.
Definition: emSwLib.h:266
uint64_t reactiveEnergyCounter
Ongoing Reactive Energy Sum.
Definition: emSwLib.h:339
void EM_calcTotalApparentEnergy(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total apparent energy. This API will aggregate the total energ...
Definition: emSwLib.h:274
EM_message_code EM_configureEnergyMeasurement(EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result)
The following API initializes the variables needed by the library at run time. This includes the G co...
uint32_t mainPeriod
This a running average of the length of a mains cycle. (samples/cycle * 256)
Definition: emSwLib.h:507
and indPhaseMeterConstant is 0
Definition: emSwLib.h:203
uint32_t vPeak
VPeak since system initialization (mV)
Definition: emSwLib.h:547
uint8_t pulseGeneration
Definition: emSwLib.h:366
uint8_t mainNomFreq
Nominal Freq value for the system (Hz)
Definition: emSwLib.h:452
uint64_t indPhaseMeterConstant
Definition: emSwLib.h:354
uint16_t indPhasePulseDuration
Pulse duration in ADC counts for each active / reactive energy.
Definition: emSwLib.h:357
Definition: emSwLib.h:239
uint16_t cycleSampleCount
Definition: emSwLib.h:502
Definition: emSwLib.h:280
int64_t reactPowDotProd
Definition: emSwLib.h:489
void EM_calcVRMSMultAcc(EM_Metrology *metro, EM_Phase_Configuration *phase)
The following API is used to calculate the dot product and accumulation for VRMS. This API reads the ...
uint32_t prevMainPeriod
This a running average of the length of a mains cycle. (samples/cycle * 256)
Definition: emSwLib.h:509
uint16_t phaseResultsSupported
Definition: emSwLib.h:406
uint64_t activeEnergyCounter
Ongoing Active Energy Sum.
Definition: emSwLib.h:335
struct _EM_SW_Lib_Config_Handle_ EM_SW_Lib_Config_Handle
Contains EM SW Lib Config Handle.
int16_t phaseCorrection
Phase Correction between voltage and current (register units)
Definition: emSwLib.h:391
EM_Meter_Configuration * meterConfig
Pointer to EM_Meter_Configuration struct.
Definition: emSwLib.h:477
void EM_calcIPeak(EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to calculate I Peak. This API updates the global Phase Result structure...
struct _EM_Pulse_Settings_ EM_Pulse_Settings
Contains EM SW Lib Phase Calibration.
void EM_calcFreqPeriod(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
The following API is used to calculate the period of the voltage signal. For systems with 2 voltages...
enum _EM_message_code_ EM_message_code
The following enumeration contain all possible EM SW Library return message codes.
void EM_calcActiveEnergy(EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
The following API is used to calculate the active energy result. The formula used to calculate active...
Contains EM SW Lib Meter Configuration.
Definition: emSwLib.h:428
EM_Energy_t apparentEnergy
Apparent Energy for previous frame (uVAh)
Definition: emSwLib.h:566
void EM_calcActivePowerMultAcc(EM_Metrology *metro, EM_Phase_Configuration *phase)
The following API is used to calculate the dot product and accumulation of Voltage and Current...
This error is returned if the phaseLength is equal to 0.
Definition: emSwLib.h:229
EM_Phase_Calibration * phaseCalibPtr
Pointer to EM_Phase_Calibration struct.
Definition: emSwLib.h:422
void EM_genPulseIndPhase(EM_System_Configuration *config, EM_Pulse_Settings *pulse, EM_Phase_Results *result)
The following API is used to generate pulses for an individual phase. This API checks if the config->...
uint16_t freqSampling
Sampling Frequency (Hz)
Definition: emSwLib.h:458
uint32_t activePowerSF
Active Power Scaling Factor.
Definition: emSwLib.h:387
EM_Power_t reactivePower
Total Reactive Power since system initialization (uVAr)
Definition: emSwLib.h:578
int64_t iDotProd
Definition: emSwLib.h:497
Contains EM Phase Result.
Definition: emSwLib.h:541
void EM_calcReactiveEnergy(EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
The following API is used to calculate the reactive energy result. The formula used to calculate reac...
int32_t EM_currentDCFilter(int16_t p[3], int32_t x)
The following API is intended for the removal of the DC content from 24 bit 50Hz/60Hz mains signals...
uint16_t reactPowIIRMinFreq
Min Frequency for the IIR coefficient table.
Definition: emSwLib.h:460
int16_t vPrevSample
Previous Voltage sample used for the IIR filter in the reactive power calculation.
Definition: emSwLib.h:531
uint32_t voltageSF
Voltage Scaling Factor - used to calculate VRMS.
Definition: emSwLib.h:383
struct _EM_System_Configuration_ EM_System_Configuration
Contains EM SW Lib System Configuration.
void EM_perSample(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
The following API is used update the previous voltage value for a phase and to increment the number o...
EM_Energy_t activeEnergy
Total Active Energy consumed since system initialization (uWh)
Definition: emSwLib.h:582
uint64_t totalPhaseMeterConstant
Definition: emSwLib.h:359
EM_Power_t apparentPower
Apparent Power for previous frame (uVA)
Definition: emSwLib.h:560
enum _EM_Current_Sensor_ EM_Current_Sensor
Selects appropriate EM Sensor for the corresponding channel.
_iq30 energyCalcConst
One dividing by (3600 x sampling frequency)
Definition: emSwLib.h:456
EM_Current_Sensor currentSensor
Sensor connected to the current (I) channel.
Definition: emSwLib.h:404
Contains EM SW Lib Phase Calibration.
Definition: emSwLib.h:381
_iq30 reactPowGConst
G Constant used for the IIR filter to calculate Reactive Power.
Definition: emSwLib.h:505
int32_t vDCEstimate
DC Estimate for Voltage.
Definition: emSwLib.h:525
_iq30 oneDivSC
Constant used to calculate the VRMS,IRMS, power and energy values (1/sample_count) ...
Definition: emSwLib.h:511
uint8_t * meterPW
Definition: emSwLib.h:438
uint8_t reactivePulseGpioPort
Definition: emSwLib.h:301
Shunt.
Definition: emSwLib.h:250
uint64_t EM_Energy_t
Type for Energy variables.
Definition: emSwLib.h:262
Definition: emSwLib.h:200
Definition: emSwLib.h:209
Rogowski Coil (RC)
Definition: emSwLib.h:252
void EM_calcApparentPower(EM_Phase_Results *result)
The following API is used to calculate apparent power. The formula used to calculate apparentPower (u...
uint16_t reactPowIIRLength
Length of the IIR coefficient table.
Definition: emSwLib.h:464
EM_Phase_Configuration * phaseConfigPtr
Pointer to the EM_Phase_Configuration struct buffer.
Definition: emSwLib.h:430
Definition: emSwLib.h:272
_iq29 sqrtTwoConst
Square of 2 constant used for Vpeak and Ipeak calculations.
Definition: emSwLib.h:454
uint16_t activePulseGpioPin
Definition: emSwLib.h:313
void EM_calcIRMSMultAcc(EM_Metrology *metro, EM_Phase_Configuration *phase)
The following API is used to calculate the dot product and accumulation for IRMS. This API reads the ...
uint16_t frequency
Definition: emSwLib.h:553
void EM_calcTotalActiveEnergy(uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
The following API is used to calculate total active energy. This API will aggregate the total energy ...
EM_Pulse_Settings * pulseArray
Definition: emSwLib.h:349
void EM_initDCFilters(EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result)
The following API initializes the voltage / current DC filters to 0.
uint32_t currentSF
Current Scaling Factor - used to calculate IRMS.
Definition: emSwLib.h:385
uint32_t iPeak
IPeak since system initialization (uA)
Definition: emSwLib.h:549
void EM_calcReactivePowerMultAcc(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
The following API is used to calculate the dot product and accumulation of Voltage_90 and Current...
EM_Phase_Results * phaseResults
Pointer to EM_Phase_Result struct buffer.
Definition: emSwLib.h:596
EM_Energy_t reactiveEnergy
Total Reactive Energy consumed since system initialization (uVArh)
Definition: emSwLib.h:584
EM_Power_t activePower
Active Power for previous frame (uW)
Definition: emSwLib.h:556
void EM_perDataChunk(EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result, uint16_t phaseIdx)
The following API is used to swap the metrology ping and pong pointers. This API must be executed aft...
This error is returned if the phaseConfigPtr is equal to 0.
Definition: emSwLib.h:231
EM_Phase phaseID
Present Phase ID Name.
Definition: emSwLib.h:568
struct _EM_Meter_Configuration_ EM_Meter_Configuration
Contains EM SW Lib Meter Configuration.
Current Transformer (CT)
Definition: emSwLib.h:248
uint16_t prevSampleCount
Definition: emSwLib.h:513
struct _EM_Phase_Calibration_ EM_Phase_Calibration
Contains EM SW Lib Phase Calibration.
This error is returned if the phase number is invalid.
Definition: emSwLib.h:235
void EM_calcActivePowerDiv(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to calculate the active power in the foreground code and store activePower ...
int32_t powerFactor
Power Factor calculated when the EM_powerFactor.
Definition: emSwLib.h:551
int16_t EM_voltageDCFilter(int32_t *p, int16_t x)
The following API is intended for the removal of the DC content from 16 bit 50Hz/60Hz mains signals...
void EM_calcApparentEnergy(EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
The following API is used to calculate the apparent energy result. The formula used to calculate appa...
int64_t actPowDotProd
Definition: emSwLib.h:486
EM_Energy_t apparentEnergy
Total Apparent Energy consumed since system initialization (UVAh)
Definition: emSwLib.h:586
uint32_t IRMS
IRMS for previous frame (uA)
Definition: emSwLib.h:545
This error is returned if the sampling frequency is not greater than 0.
Definition: emSwLib.h:219
uint8_t reactPowIIRShift
Number of shifts required to calculated index for IIR table.
Definition: emSwLib.h:462
uint16_t * EMSWLIB_EM_HAL_ADC_minFreqCount
The following variable is used as a minimum ADC count to detect frequency.
uint16_t reactivePulseGpioPin
Definition: emSwLib.h:324
void EM_calcReactivePowerDiv(EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
The following API is used to calculate the reactive power in the foreground code and store reactivePo...
struct _EM_Phase_Results_ EM_Phase_Results
Contains EM Phase Result.
uint8_t * libVersionNumber
Pointer to library version number string.
Definition: emSwLib.h:436
void EM_clearMetrology(EM_Metrology *metro)
The following API is used to clear the temporary variables inside the metro structure. This API must be called as the last API in the foreground code.
uint8_t phaseResultsSupportedLen
Length of the phaseResultsSupportedPtr buffer.
Definition: emSwLib.h:604
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale