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.
Respected Sir,
I am using Ti’s energy meter code based on MSP430i2040 (Two phase energy meter). In this I am using one function
set_V_rms_scaling(0, 0, calib_val[0] );
Now calib_val[0] is the new calibration value to be written in the flash. But when I use this function it doesn’t write exact value as of calib_val[0].
e.g. default scaling factor is 13428 for phase 1. If I put value in calib_val[0] as 12500 it will write 12372. Why is so?
Regards.
Hello,
It's possible there's an offset getting subtracted from the value you're setting, but I'm not sure. I would recommend looking through this function's code to confirm. Please keep in mind that the legacy Energy library has been replaced with the newer Energy Measurement Design Center (EMDC) and Software Library. Support for the Energy library will be limited moving forward.
Energy Measurement Design Center for MSP430 MCUs Overview Video
Regards,
James
Hello,
Can you please point me to the code and app note you're using? Is it SLAA637? How are you sending these calibration values? Over the GUI, from another Host MCU, or in the code? Your issue could stem from Flash memory corruption. If you are using SLAA637 code, there's a bug where the Flash Controller clock isn't set up. I would recommend adding the FCTL2 code below in the 'emeter-main.c' file before the "system_setup();" function, then rebuild the toolkit > metrology > app projects.
emeter-main.c code updates
#if defined(__IAR_SYSTEMS_ICC__) || defined(__TI_COMPILER_VERSION__) void main(void) #else int main(int argc, char *argv[]) #endif { #if NUM_PHASES == 1 #define ph 0 #else int ph; #endif #if defined(TRNG_SUPPORT) uint16_t randy; #endif #if defined(TRNG_PURITY_TESTS) int fips_result; #endif static int32_t x; int phase_state; #if (defined(PHASE_REVERSED_DETECTION_SUPPORT) && defined(ON_REVERSED_SELECT_POSITIVE_READING)) || defined(PHASE_UNBALANCED_DETECTION_SUPPORT) int metrology_state; #endif #if !defined(__MSP430__) if (start_host_environment(argc, argv) < 0) exit(2); #endif // [Modified code] Added FCTL2 configuration for Flash controller speed // to keep Fftg between 257kHz and 476kHz. This should be done before // system_setup() and metrology_init() functions since they may // read/write to Flash/INFO memory. FCTL2 = FWKEY | FSSEL1 | FN5 | FN4; // [Modified code] Fftg = ~334kHz system_setup(); #if defined(TRNG_PURITY_TESTS) fips_init(); fips_result = -1; #endif
Regards,
James
Dear James,
Thanks for your reply. I did programming using EMDC and could load code in device.(In this case when i supply 230 Vac it shows 17128 in "gEmSWResult.phaseResults[0].VRMS;").
Now in this case can you suggest me is this a correct value? Also if so please suggest calibration steps for the same.
As far as your last solution related to flash clock is concern i have added this code modification with no effect.
Also i would like to tell yyou when code gets initialize it writes correct values from the default array. This issue is only with the function set_V_rms_scaling(0, 0, calib_val[0] );
Do you have any alternative steps to write the same in flash?
Hello,
Pallav Gandhi said:Thanks for your reply. I did programming using EMDC and could load code in device.(In this case when i supply 230 Vac it shows 17128 in "gEmSWResult.phaseResults[0].VRMS;").
Now in this case can you suggest me is this a correct value? Also if so please suggest calibration steps for the same.
If you used one of our EMDC example projects or programmed the device using one of the provided EMDC binaries, they come pre-calibrated at 230V. Thus, if you were applying 230V, it should show 2300000 if you're using the EVM430-i2040S. What's the value shown in the EMDC GUI under the Results tab? Are you using a different board or your own custom board? If so, I suspect that the voltage divider may have been changed which could skew the results if you're applying 230V and the code was calibrated at 230V. You can adjust the voltage sensor resistor divider in the EMDC GUI as well, then re-generate the code.
As far as calibration goes, you'll need to use an accurate test source to provide the voltage and current to your board. If you don't have access to a test source like this, you could potentially use an external load like a resistor/inductor to get close to 60 degrees phase angle (PF = 0.5) for phase calibration (discussed in greater detail here). The calibration instructions can be found in the EMDC Technology Guide.
Pallav Gandhi said:As far as your last solution related to flash clock is concern i have added this code modification with no effect.
Also i would like to tell yyou when code gets initialize it writes correct values from the default array. This issue is only with the function set_V_rms_scaling(0, 0, calib_val[0] );
Do you have any alternative steps to write the same in flash?
Let's maintain distinction between the EMDC and legacy Energy Library code. The EMDC code has resolved those Flash issues that may have existed in the legacy Energy Library. For now, let's stay focused on the EMDC code and getting it working since it's the recommended approach.
Regards,
James
Hi Pallav,
Pallav Gandhi said:We have developed our own board taking reference of SLAA637A. As shown in figures and reference components used we have modified R1 & R2 ratio from 1000 & 1K to 990 & 2.7K.
That's great! Nice work. For the EVM430-i2040S_SH_1V_1C EMDC example projects, we calibrated them using the EVM430-i2040S at 230V. However, R2 on that board is 1.5K, not 2.7K. Thus, if you use one of the example projects, they won't measure the RMS voltage correctly since R2 has been changed even though they've been calibrated.
Let's keep 990K and 2.7K for R1 and R2 for now since EMDC can adjust for this and it's less than the max ADC input voltage.
Pallav Gandhi said:Also for current parameters changed burden ratio from 10 ohm to 13 ohm and transformer ratio from 1000:1 to 2000:1. Maximum current from 60A to 100A.
This is also fine - at 100A, the max ADC input voltage isn't exceeded. Again, EMDC can handle this.
Pallav Gandhi said:Generated code after changing this in EMDC and tested the same. Now for testing also we are not using TI's software as GUI. Internally we have modified communication to 9600 baud and on RS485. (We also don't have Kit available to use as bridge).
Thanks for sharing this information. It's very helpful knowing what you're doing and what you've changed. For your initial testing, I would highly recommend using the EMDC GUI since you can trust the results. We used a high baud rate (250kBaud) to ensure that worst case three phase configuration with all parameters could get send from the MCU to the GUI between sample interrupts. For you, it sounds like a single- or double-phase configuration, so you may be fine. It may be good to double-check that the communication happens between the SD ADC interrupts. A slower ADC sampling rate helps too.
Again, I'd recommend doing testing with the EMDC GUI before moving to a host device at a slower baud rate. Too many things changing at once adds confusion about where the issue occurs.
Pallav Gandhi said:Now in this when we connect a load at 230VAC values displayed in "gEmSWResult.phaseResults[0].VRMS" is 17128. Also for current ideally it shows 179 as value and when connected to 40W load we get 210 as value.
If you've created a new EMDC project and haven't calibrated it, then this result makes sense. If your source is close to 230VAC, use the EMDC GUI to calibrate your system and store the calibration factors in Flash and save the EMDC project after calibration to preserve them in the project settings.
Pallav Gandhi said:I am not sure if GUI is doing some calculation behind to dislay proper values or the functions i am calling is wrong.
Yes, the GUI knows what your high voltage AC test source is providing when you enter them in the calibration window inside EMDC. Then, it reads the un-calibrated values from the MCU, calculates the difference and applies a new scaling factor for Gain calibration (essentially taking the ADC value and scaling it to a value that makes sense to humans). The same applies to the phase calibration but we can address that later.
Pallav Gandhi said:Please suggest simple two query for reading phase 1 voltage and calibrating phase 1 voltage.
For the communication commands, you can refer to the protocol section in the EMDC Technology Guide. Please note there's a typo (I've filed a bug that will get resolved in the next release) and the commands are not 0xB_ but 0x8_.
I hope this helps!
Regards,
James
Hello,
The calibration factors can be found in the 'EM_userConfig.c' file. The default non-calibrated values are shown below.
EM_Phase_Calibration g_emPhaseCalibration[EM_PHASE_LENGTH] = { //PHASE_A { .voltageSF = _IQ24(1.000000000), .currentSF = _IQ24(1.000000000), .activePowerSF = _IQ30(1.000000000), .reactivePowerSF = _IQ30(1.000000000), .phaseCorrection = 0x0080, },
After completing calibration with the EMDC GUI, these factors are updated with the calibrated values.
Here's a quick test. I would recommend that you open one of the EMDC example projects for MSP430i2041 and generate the code. Modify your project with the calibration factors found in the generated 'EM_userConfig.c' file, rebuild your project and then reprogram the device with your project. Then, replace R2 on your board with a 1.5kOhm resistor like the EVM430-i2040S. Then, apply 230V and see what you're measuring for VRMS.
EM_Phase_Calibration g_emPhaseCalibration[EM_PHASE_LENGTH] = { //PHASE_A { .voltageSF = _IQ24(23.711392999), .currentSF = _IQ24(16.260255575), .activePowerSF = _IQ30(0.385561275), .reactivePowerSF = _IQ30(0.385561275), .phaseCorrection = 0x0071, }, };
Again, it will help you to purchase the HID bridge board and isolation board for your development. It will save you a lot of time in your development by analyzing the communication between the GUI and the MCU.
Regards,
James
Yes. I manually set calibration values such that i get calibrated values displayed in communication.
Thanks for the suggestion. Now my .voltageSF = _IQ24(1.000000000), comes out to be .voltageSF = _IQ24(1.310000000), is it ok?
Secondly i modified EMDC generated code sothat i can communicate on my RS485 port. Now to debug i want you to guide me for realisation of the value.
e.g. for voltage i get *vrms which has vrms[0], vrms[1], vrms[2], vrms[3]. To get proper value in the form of hex how should i place it?
Also for the other values like active power has actPower[0] to actPower[7]. How to convert it to meaningful value?
Thanks.
Hi Pallav,
Pallav Gandhi said:Yes. I manually set calibration values such that i get calibrated values displayed in communication. Thanks for the suggestion.
That's great!
Pallav Gandhi said:Now my .voltageSF = _IQ24(1.000000000), comes out to be .voltageSF = _IQ24(1.310000000), is it ok?
I'm not sure. They look different than the calibration factors from the calibrated EMDC example projects. Are these calibration factors providing the correct results? For details on how to convert between _IQ24() values and an integer value, please refer to the user's guide. For gain calibration, you just need to scale these according to the difference observed. If the measured result is 10.75x smaller than applied signal, then you need a scaling factor that's 10.75x bigger.
Pallav Gandhi said:Secondly i modified EMDC generated code so that i can communicate on my RS485 port. Now to debug i want you to guide me for realisation of the value.
For modifications, I would have two versions:
Overall, don't try to do too much too quickly. Start by understanding the EMDC communication protocol and how the data gets sent. Then after that's done, start changing the communication interface and protocol. Keeping these steps simple helps reduce issues.
Pallav Gandhi said:e.g. for voltage i get *vrms which has vrms[0], vrms[1], vrms[2], vrms[3]. To get proper value in the form of hex how should i place it?
Also for the other values like active power has actPower[0] to actPower[7]. How to convert it to meaningful value?
I've addressed this question in detail in the following thread. Basically, the first element in the array (e.g. vrms[0], actPower[0], etc.) is equal to the LSB and the last element is the MSB.
Here's another useful thread for your reference.
MSP430i2040: Interfacing EMDC with another MCU over UART
Regards,
James
**Attention** This is a public forum