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.

TMS320F28379S: CMPSS offset

Expert 1570 points
Part Number: TMS320F28379S


Hi,

we're using the TMS320F28379S for motor control application.

we have current sensors in-phase with the motor windings.

we've configured the CMPSS and the ADC to sample the channel.

on the CCS window we can see that the samples on ADCRESULT are stable around mid-point, i.e. 2040-2050.

We're trying to set the CMPSS to trip both at high and low compare values and set the TZ for the PWMs.

we've setup DACLVALS=1900 and DACHVALS=2100.

However the low compare triggers the TZ.

we found that we need to go down to around 1800 so the low comp will not trigger.

with the hi compare with can go down to around 1900 WITHOUT getting any trigger.

it seems like there's some offset of about 200 points on the compare input.

Any idea where that can come from?

on the ADC we're not using any PPB to offset the measurements.

Thanks!!

here's the CMPSS init :

EALLOW;
    //Enable CMPSS
    v->COMPCTL.bit.COMPDACE = 1;
    //NEG signal comes from DAC for the low comparator
    v->COMPCTL.bit.COMPLSOURCE = NEGIN_DAC;
    //NEG signal comes from DAC for the high comparator
    v->COMPCTL.bit.COMPHSOURCE = NEGIN_DAC;
    //Use VDDA as the reference for comparator DACs
    v->COMPDACCTL.bit.SELREF = REFERENCE_VDDA;
    //Set DAC to H~75% and L ~25% values
    v->DACHVALS.bit.DACVAL = Hi;
    v->DACLVALS.bit.DACVAL = Lo;
    // comparator oputput is "not" inverted for high compare event
    v->COMPCTL.bit.COMPHINV = 0;
    // Comparator output is inverted for for low compare event
    v->COMPCTL.bit.COMPLINV = 1;

    // Configure Digital Filter - High
    //Maximum CLKPRESCALE value provides the most time between samples
    v->CTRIPHFILCLKCTL.bit.CLKPRESCALE = clkPrescale;  //30;   /* Max count of 1023 */
    //Maximum SAMPWIN value provides largest number of samples
    v->CTRIPHFILCTL.bit.SAMPWIN        = sampwin;  //0x1F;
    //Maximum THRESH value requires static value for entire window
    //  THRESH should be GREATER than half of SAMPWIN
    v->CTRIPHFILCTL.bit.THRESH         = thresh;  //0x1F;
    //Reset filter logic & start filtering
    v->CTRIPHFILCTL.bit.FILINIT        = 1;


    // Configure Digital Filter - Low
    //Maximum CLKPRESCALE value provides the most time between samples
    v->CTRIPLFILCLKCTL.bit.CLKPRESCALE = clkPrescale;  //30;   /* Max count of 1023 */
    //Maximum SAMPWIN value provides largest number of samples
    v->CTRIPLFILCTL.bit.SAMPWIN        = sampwin;  //0x1F;
    //Maximum THRESH value requires static value for entire window
    //  THRESH should be GREATER than half of SAMPWIN
    v->CTRIPLFILCTL.bit.THRESH         = thresh;  //0x1F;
    //Reset filter logic & start filtering
    v->CTRIPLFILCTL.bit.FILINIT        = 1;

    // Configure CTRIPOUT path

    //Digital filter HIGH output feeds CTRIPH and CTRIPOUTH
    v->COMPCTL.bit.CTRIPHSEL           = CTRIP_FILTER;
    v->COMPCTL.bit.CTRIPOUTHSEL        = CTRIP_FILTER;

    //Digital filter LOW output feeds CTRIPH and CTRIPOUTH
    v->COMPCTL.bit.CTRIPLSEL           = CTRIP_FILTER;
    v->COMPCTL.bit.CTRIPOUTLSEL        = CTRIP_FILTER;

    // Make sure the asynchronous path compare high and low event
    // does not go to the OR gate with latched digital filter output
    v->COMPCTL.bit.ASYNCHEN = 0;
    v->COMPCTL.bit.ASYNCLEN = 0;

    //Comparator hysteresis control , set to 2x typical value
    v->COMPHYSCTL.bit.COMPHYS = 4;
    // Dac value is updated on sysclock
    v->COMPDACCTL.bit.SWLOADSEL = 0;
    // ramp is bypassed
    v->COMPDACCTL.bit.DACSOURCE = 0;
    // Clear the latched comparator events
    v->COMPSTSCLR.bit.HLATCHCLR = 1;
    v->COMPSTSCLR.bit.LLATCHCLR = 1;

    EDIS;

  • Hi Mojo,

    Can you clarify a few things. I noticed you have inversion enabled on the low comparator and you are also using hysteresis so i need you to clarify the logic you are expecting.

    Do you want the low comparator to go high when the voltage on the positive input crosses DACL or vise-versa?

  • Hi,

    we would like to have the following trips:

    - input voltage higher than DACH.

    - input voltage lower than DACL

    that is why the inversion.

    we actually took the example of setting up the CMPSS from IDDK_PM_Servo_F2837x example (with some fixes about the DACL registers).

    It seems there's some offset but maybe that's the hysteresis? seems like the number (~200 points) is too big though.

    thanks!

  • Mojo,

    You are seeing a combination of gain and offset errors from DACL. Hysteresis will subtract from those so what you are seeing is quite big. Few questions:

    1. Is this behavior seen for all the CMPSSs or is it just one CMPSS?

    2. What happens when you disable hysteresis, do you still see this large delta?

    3. The CMPSS needs time to power-up. Do you have a delay in your code somewhere after you write to this register "COMPCTL.bit.COMPDACE = 1"?

  • Hi Frank

    1. This is seen on all CMPSSs. However, they are all configured the same...

    2. Will check and update.

    3. Yes we have delay. But we're also checking with the JTAG so writing directly to the register after long time of power-up...so I don't think any issue here.

    thanks a lot and will update soon

  • Hi,

    We found the source of the problem.

    We're using Vrefhi=3V for the ADCs.

    however VDDA for the comparators is 3.3V.

    our signals are shifted in HW to be around 1.5V, rather than 1.65V - so that's the offset we're seeing.

    we also need to take into account the gain 3.3/3 when setting the values for the compare.

    does this make sense?

    It might be a good point for the datasheet to highlight this...

    thanks!

  • Hi Mojo,

    Glad your issue is resolved and yes, that makes sense. If you are using the ADC and COMPDACs together, you will need to scale the values of one of them if they are using different reference voltages.