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.

InstaSpin FOC TMS320F28027F ADC Sample delay

Other Parts Discussed in Thread: TMS320F28027F

I am using the InstaSpin FOC in the TMS320F28027F chip. I moved my PWMs from PWM1,2,3 to PWM2,3,4 for the motor control. I am using PWM1A to generate an independent PWM signal for another part of my circuit. PWM1A is setup to produce a 50% duty cycle. I am then able to control its frequency from 20Khz to 25KHz in 1Hz steps using the High Res feature. The PWMA signal is filtered in hardware with a corner frequency of about 30KHz. This gives me a fairly good sine wave to drive a part of my circuit. 

My goal is to be able to sample the resulting sinewave output of my circuit at any point along the PWA1 period. I will use the CMPA to trigger my ADC sample and change the CMPA to allow me to sample at any point along the sinewave period. It is very important that these samples occur as close to the CMPA point as possible. However, I also have my motor control samples happening at 15KHz. If someone could answer the below questions, it would help me choose what direction to take to accomplish this. 

Can you confirm that the ADC clock is 60MHz? I did see one note that the ADC clock needs to be under 45MHz, but I think this is for the internal Temperature reading only. It appears the ADC is set for 60 MHz clock, but I want to make sure. 

Would it affect the motor control if some of its samples were delayed or skewed one way or the other by three ADC sample periods? In other words if some of the motor samples got randomly moved by 3*(7+13) = 60 cycles = 1us with 60MHz clock. I would guess that this would not be a good thing for the motor control. 

I believe to prevent skewing the motor samples, I can give the motor samples priority and if the motor sample is in my way I can wait a little bit for it to move and then sample at the exact place on my sinewave. The good thing about my system is I can wait a little to take my sample since I am in control of the frequency, but I need to sample as close to the exact time as possible. 

Is it necessary to still do the dummy adc read on the first read? I would think this is not a problem on the 28027F since it would always be Rev A die. 

Are there any other errata I need to be aware of in my journey to try and get this working? 

By answering the above questions I can proceed with more confidence.

P.S.
I have the motor running and it works Great!. I cannot thank all you guys at TI
for the great job you have done with the InstaSpin. I have been using TI to do
motor control with C2000 since 2009. This InstaSpin stuff works much better
than the original SMO for FOC and is easy to use and tune the motor. I am able
to achieve much lower RPMs, much better starting torque, and much better
control of the motor all around. It makes me look like I know what I am doing
to my boss and peers. I just hope I can get the rest of my system working
without messing it up too much.

  • Gary,

    For the F28027F device, 60MHz is indeed the max clock.  For the note you saw, that may be some unwanted cross referencing in the code/docs.  That note most likely applies to the F28069F where the max SYSCLK = 90MHz, and as such the next available speed of the ADC <=60MHz is DIV2 or 45MHz.

    In terms of moving the sample position by 1us, I suppose that depends on what you expect the signal of interest to do. Typically the main concern with the loop is finishing in enough time to change the next PWM's DC, which from above doesn't seem to be the limiter(assuming 40us period and moving the sample out by 1us).  But if there is significant change expected, and given your statement on using the CMPA to trigger the ADC there might be then this could be significant in terms of what is measured.  Keep in mind there is some prop delay for that CMPA trigger to get to the PWMx and back to the ADC.  The physical delay is around 50ns; but there will be a few more clocks @60Mhz to latch it and send it back to the ADC and for the ADC to use that to initiate a SOC.

    We can have some more dialogue on this depending on the granularity of which you need to place that SOC.

    You will need to continue to do the dummy first sample, even with revA.  There are some additional hooks in that device like ADCNONOVERLAP and DIV2 bits that can be used as a workaround but at the expense of sample rate.  If you are pleased with the motor performance I would stick to leaving these bits alone and throw out the first sample.

    Best regards,

    Matthew

  • Thanks for the reply and the convermation of the dummy sample. I have figured out a way to sample my signals without interfering with the motor control samples. I use the below if statement to insure I am not sampling during a motor control sample.

    //(Note: In my system I have shifted the PWMs from 1,2,3 to 2,3,4 for the Motor control, so PWM2 is the ADC trigger source and not PWM1 as in the original InstaSpin code)

    if(HAL_getPwmTBCTR(halHandle,PWM_Number_2) > 500)
    {

    HAL_SocFrcO2(halHandle);

    }


    I added the below code to my Hal.h file

    static inline void HAL_SocFrcO2(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_Obj *)handle;

    // force start of conversion on SOC0
    ADC_setSocFrc(obj->adcHandle, ADC_SocFrc_12);
    ADC_setSocFrc(obj->adcHandle, ADC_SocFrc_13);

    return;
    } // end of HAL_SocFrcO2() function


    Since there are 8 ADCs conversions by the Motor control and they are triggered in my system when PWM2 period reaches zero, I just make sure my samples only occur outside that time by more than 8*(13+7) = 160 PWM clocks. I chose 500 just to be safe and give plenty of room to do my samples. It seems to work well. I used SOC 12 and SOC 13 to do my samples and I use the software trigger to initiate both samples. Both SOC12 and SOC13 are for the same channel so that I get a dummy sample each time for SOC12 and then I read SOC13’s conversion for my data sample.