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.

MSP430i2041: MSP430i2041 sub-metering EVM

Part Number: MSP430I2041
Other Parts Discussed in Thread: MSP430I2041

Dear Mates,

I am using a SPI based DAC to control output current of an external DC circuit. The issue I have is that, I can send predefined values, and the output DC value corresponds to it, but when I use the the AC current measured by the MSP430i2041, I only get the maximum output DC current value.Regarding this, I have a few questions:

  1> Is 'rms_current(ph)' the correct variable which contains the measured RMS Current? 

  2> If yes, then what's the variable type? If no, then which variable contains the correct RMS Current measurement, and what's its data type?

Attached below is the bit of the modified example code: 

// line number 239 of emeter-main.c
#if NUM_PHASES == 1
                calculate_phase_readings();
                LED3_ON ();
                  
                  static unsigned long CL = 0x2AAA; //4mA = 0x2AAA, the required offset
                  //CL = CL + (int16_t)(rms_current(1)/1000); // this yields the same result as the bottom one
                  
                  CL = ((int)rms_current(0))/1000; // I have tried a lot of variations, but none seem to work 
                  if (CL > 0xDA8E)
                  {
                    CL = 0xDA8E;
                  }
                  updateCurrentOutput( (unsigned short)(CL)); // function to send data to DAC through SPI
#else
                calculate_phase_readings(ph);
                LED3_OFF ();

Any help would be much appreciated.

Thanks in advance

With Warm Regards

Subhronil

  • Got it!
    just changed; CL = ((int)rms_current(0))/1000; to CL = (unsigned short)(rms_current(0)/100.00);
  • Hello Subhronil,

    Thank you for letting everyone know that you resolved your issue. For your reference, the "rms_current()" function does return a 32-bit signed integer. You can see this in the 'metrology-types.h' file, but if you don't have that file, you can also see where int32_t type casting was done for this function in the 'emeter-dlt645.c' file. Notice that the index for the tx16[] buffer goes from 3 to 5 indicating that the RMS current data field requires two 16-bit values.

    metrology-types.h

    /* We store voltages in 1mV steps. A 32 bit unsigned number supports the range
       1mV to 2147483.647V, which seems OK for all forseeable uses. */
    typedef int32_t rms_voltage_t;

    emeter-dlt645.c

    #if NUM_PHASES == 1  &&  defined(NEUTRAL_MONITOR_SUPPORT)
        *((int32_t *) &tx16[3]) = rms_current(FAKE_PHASE_LIVE);
        *((int32_t *) &tx16[5]) = active_power(FAKE_PHASE_LIVE);
    #else

    Hopefully this helps.

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum