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.

CCS/TMDSHVMTRPFCKIT: TMDSHVMTRPFCKIT

Part Number: TMDSHVMTRPFCKIT

Tool/software: Code Composer Studio

Hello to TI TMDSHVMTRPFCKIT group,

I will implement my induction motor speed control using TMDSHVMTRPFCKIT with tms320f28035 control card, but i have some complexity related to ADC(how to measure lower side inverter two phase current and dc bus voltage). we have the calculation based on TMDSHVMTRPFCKIT

for DC BUS VOLTAGE ADC A7 PIN sensed input voltage= DC BUS VOLT*(9.09/(9.09+820+300)), lets assume DC BUS VOLT=200V then we get 1.61v in ADC A7 pin, I i want to lower this value to 0.5v i want to read this from AdcResult.ADCRESULT7 register.

My question is based on HVACI_Sensorless.c

your code written as volt1.DcBusVolt = _IQ12toIQ(AdcResult.ADCRESULT7); // DC Bus voltage meas. can i modify/write this code like this

ADCINA7=AdcResult.ADCRESULT7;

VDC= (ADCINA7*(1/3))*(1.5/1.65); // this line gives me the voltage between 0&1 depend on the DC BUS VOLTAGE, please correct me if am I wrong (according to 200v it i will get ~0.48v)

//////////////////////////////////////////////////////////////

For two phase current measurements

// ------------------------------------------------------------------------------
// Measure phase currents, subtract the offset and normalize from (-0.5,+0.5) to (-1,+1).
// Connect inputs of the CLARKE module and call the clarke transformation macro
// ------------------------------------------------------------------------------
clarke1.As = _IQmpy2(_IQ12toIQ(AdcResult.ADCRESULT1)-offsetA); // Phase A curr.
clarke1.Bs = _IQmpy2(_IQ12toIQ(AdcResult.ADCRESULT2)-offsetB); // Phase B curr.
CLARKE_MACRO(clarke1)

also can i write the above code like this shown below, i do not consider offset and IQ IN my case

also we have the calculation for the current sensor

vout=-8.25*vin+1.65;// vout=Ifb_U&V is input to pin A1&B1; vin=VSH_U&V is the lower side voltage value

VSH_U=Rshunt(0.02)*IphaseU. MAX value of VSH_U=0.02V

// sensed current from lower side inverter after OPA2350

ADCINA1=AdcResult.ADCRESULT1;

ADCINB1=AdcResult.ADCRESULT2;

SCALING AND OFFSET adjustment(between -1 &1 )

ia = ADCINA1*(2/3);// not in between (-1&1)
ib = ADCINB1*(2/3);
ia1 = (ia-(0.995*1.65/1.5))*(1.5/1.65);// this makes between (-1 & 1)
ib1 = (ib-(0.995*1.65/1.5))*(1.5/1.65);//this makes between (-1 & 1)

  • Hi Tesafye

    I'm working through your question and hope to provide an answer within the next 24 hours

    Thanks
    Sean
  • Dear sean

    i am waiting your answer, 

    thanks in advance,

    Tesfaye

  • It's better to refer to the code using IQ format if you are using a fixed point C2000 controller (F28035) that has a good code efficiency. Not recommend using the code as you mentioned.

    You might refer to the example project in the following folder if you prefer to use float point as well.
    C:\ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.1\HVACI_Sensorless_2833x
  • offset 1.65v, in the HVM KIT for current sensor, according to( 4096*analog input/3.3), 1.65v equals 2048=0x07ff, based on this, the code below written based on C:\ti\controlSUITE\device_support\f2803x\v125\DSP2803x_examples_ccsv4\adc_soc and  DSP2803x_Adc.c,

    void init_adc(void)
    {
    extern void DSP28x_usDelay(unsigned long Count);
    // Default ADC initialization
    int ChSel[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    //int TrigSel[16] = {5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5};
    int ACQPS[16] = {8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8};
    // Initialize ADC for DMC Kit Rev 1.1
    ChSel[0]=1; // Dummy meas. avoid 1st sample issue Rev0 Picollo*/
    ChSel[1]=1; // ChSelect: ADC A1-> Phase A Current
    ChSel[2]=9; // ChSelect: ADC B1-> Phase B Current
    ChSel[7]=7; // ChSelect: ADC A7-> DC Bus Voltage
    ChSel[3]=3; // ChSelect: ADC A3-> Phase C Current
    ChSel[4]=15; // ChSelect: ADC B7-> Phase A Voltage
    ChSel[5]=14; // ChSelect: ADC B6-> Phase B Voltage
    ChSel[6]=12; // ChSelect: ADC B4-> Phase C Voltage
    EALLOW;
    DELAY_US(ADC_usDELAY);
    AdcRegs.ADCCTL1.all=0x4000;
    asm(" NOP ");
    asm(" NOP ");
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
    (*Device_cal)();
    EDIS;
    AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
    DELAY_US(ADC_usDELAY);
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select interal BG
    AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
    AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
    AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
    asm(" RPT#100 || NOP");
    AdcRegs.ADCCTL1.bit.INTPULSEPOS=1;//int generate at the end of conversion
    AdcRegs.ADCCTL1.bit.TEMPCONV=0;
    EDIS;
    DELAY_US(ADC_usDELAY);
    /******* CHANNEL SELECT *******/
    EALLOW;
    //AdcRegs.ADCCTL1.bit.INTPULSEPOS=1;
    AdcRegs.ADCSOC0CTL.bit.CHSEL =1;//dummy sample
    AdcRegs.ADCSOC1CTL.bit.CHSEL =1;//ADC A1 ia 1
    AdcRegs.ADCSOC2CTL.bit.CHSEL =9;//ADC B1 ib 9
    AdcRegs.ADCSOC3CTL.bit.CHSEL =7;// ADC A7 Vdc 7
    AdcRegs.ADCSOC4CTL.bit.CHSEL =ChSel[4];
    AdcRegs.ADCSOC5CTL.bit.CHSEL = ChSel[5];
    AdcRegs.ADCSOC6CTL.bit.CHSEL = ChSel[6];
    AdcRegs.ADCSOC7CTL.bit.CHSEL = ChSel[3];
    AdcRegs.ADCSOC8CTL.bit.CHSEL = ChSel[8];
    AdcRegs.ADCSOC9CTL.bit.CHSEL = ChSel[9];
    AdcRegs.ADCSOC10CTL.bit.CHSEL = ChSel[10];
    AdcRegs.ADCSOC11CTL.bit.CHSEL = ChSel[11];
    AdcRegs.ADCSOC12CTL.bit.CHSEL = ChSel[12];
    AdcRegs.ADCSOC13CTL.bit.CHSEL = ChSel[13];
    AdcRegs.ADCSOC14CTL.bit.CHSEL = ChSel[14];
    AdcRegs.ADCSOC15CTL.bit.CHSEL = ChSel[15];

    //===============================================================================
    AdcRegs.ADCSOC0CTL.bit.ACQPS = ACQPS[0];/* Set SOC0 S/H Window to 6+1 ADC Clock Cycles */
    AdcRegs.ADCSOC1CTL.bit.ACQPS = ACQPS[1];
    AdcRegs.ADCSOC2CTL.bit.ACQPS = ACQPS[2];
    AdcRegs.ADCSOC3CTL.bit.ACQPS = ACQPS[3];
    AdcRegs.ADCSOC4CTL.bit.ACQPS = ACQPS[4];
    AdcRegs.ADCSOC5CTL.bit.ACQPS = ACQPS[5];
    AdcRegs.ADCSOC6CTL.bit.ACQPS = ACQPS[6];
    AdcRegs.ADCSOC7CTL.bit.ACQPS = ACQPS[7];
    AdcRegs.ADCSOC8CTL.bit.ACQPS = ACQPS[8];
    AdcRegs.ADCSOC9CTL.bit.ACQPS = ACQPS[9];
    AdcRegs.ADCSOC10CTL.bit.ACQPS = ACQPS[10];
    AdcRegs.ADCSOC11CTL.bit.ACQPS = ACQPS[11];
    AdcRegs.ADCSOC12CTL.bit.ACQPS = ACQPS[12];
    AdcRegs.ADCSOC13CTL.bit.ACQPS = ACQPS[13];
    AdcRegs.ADCSOC14CTL.bit.ACQPS = ACQPS[14];
    AdcRegs.ADCSOC15CTL.bit.ACQPS = ACQPS[15];

    // Enabled ADCINT1 and ADCINT2
    AdcRegs.INTSEL1N2.bit.INT1E = 1;
    AdcRegs.INTSEL1N2.bit.INT2E = 1;
    // Disable continuous sampling for ADCINT1 and ADCINT2
    AdcRegs.INTSEL1N2.bit.INT1CONT = 0;
    AdcRegs.INTSEL1N2.bit.INT2CONT = 0;
    AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINTs trigger at end of conversion
    // Setup ADCINT1 and ADCINT2 trigger source
    AdcRegs.INTSEL1N2.bit.INT1SEL = 6; //EOC6 triggers ADCINT1
    AdcRegs.INTSEL1N2.bit.INT2SEL = 3; //EOC4 triggers ADCINT2, this interrupt is used for my code
    // Setup each SOC's ADCINT trigger source
    AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 2; //ADCINT2 starts SOC0-7
    AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC2 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC3 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC4 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC5 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC6 = 2;
    AdcRegs.ADCINTSOCSEL1.bit.SOC7 = 2;
    AdcRegs.ADCINTSOCSEL2.bit.SOC8 = 1; //ADCINT1 starts SOC8-15
    AdcRegs.ADCINTSOCSEL2.bit.SOC9 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC10 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC11 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC12 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC13 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC14 = 1;
    AdcRegs.ADCINTSOCSEL2.bit.SOC15 = 1;
    EDIS;
    AdcRegs.ADCSOCFRC1.all = 0x00FF; // Force Start SOC0-7 to begin ping-pong sampling
    }

    void adc_signals(void)
    {
    AdcRegs.ADCSOCFRC1.all = 0x00FF; // Force Start SOC0-7 to begin ping-pong sampling
    while (AdcRegs.ADCINTFLG.bit.ADCINT2 == 0){}
    AdcRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //Must clear ADCINT1 flag since INT1CONT = 0
    ADCINA1=AdcResult.ADCRESULT1;//
    ADCINB1=AdcResult.ADCRESULT2;
    ADCINA7=AdcResult.ADCRESULT3;
    //Disable ADCINT1 and ADCINT2 to STOP the ping-pong sampling
    AdcRegs.INTSEL1N2.bit.INT1E = 0;
    AdcRegs.INTSEL1N2.bit.INT2E = 0;
    // Phase voltages are measured and fed to ADC pins
    ia1 = ((AdcResult.ADCRESULT1)-0x07FF)*0.000483871;// GIVES THE VALUE B/N 0.0495&-0.0495 and then 0.03&-0.03 after multiplying 0.000483871,
    ib1 = ((AdcResult.ADCRESULT2)-0x07FF)*0.000483871;
    ic1 = -(ia1+ib1);

    can the above code work?

    it may not be exact.

  • That's fine, but you need to convert the result to SI value according to the base current/voltage that defines the coefficient is 0.00024414 or 0.000488281. Please refer to the example project as recommended above, the 0.909 coefficient is for the ADC sampling range is 0~3.0V, and the base current is for 3.3V in the project.
    Btw, you should do the offset calibration that makes sure get a correct sampling value.
  • Hi Tesafye,

    It's been a week since we heard from you, so I am assuming you no longer need clarification for your question that will be marking this thread as closed. You can reply with a post or create a new thread if you have any further question on this topic. Thanks.