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.

piccolo exp_kit_F28069 : PM Sensorless

Expert 1800 points
Other Parts Discussed in Thread: INSTASPIN-BLDC

Hi,

I was trying to capture the F28069 PWM signals thru ADC while implementing the PM_Sensorless.c project with CCSV4.  The following changes was done to the project.

--> F2806xileg_vdc_PM.h :  (initialising the ADC's)

---> PM_Sensorless.c : (Capturing the result in ADC registers)

int16 PWM_ADC[7];

Added the following lines in Level 1 just after PWM_DRV module i.e., at line 645

  • //-------------------------------------------------------------------------------
  • //Capture PWM
  • //-------------------------------------------------------------------------------
  • PWM_ADC[1] = AdcResult.ADCRESULT7 >> 4;
  • PWM_ADC[2] = AdcResult.ADCRESULT8 >> 4;
  • PWM_ADC[3] = AdcResult.ADCRESULT9 >> 4;
  • PWM_ADC[4] = AdcResult.ADCRESULT10 >> 4;
  • PWM_ADC[5] = AdcResult.ADCRESULT11 >> 4;
  • PWM_ADC[6] = AdcResult.ADCRESULT12 >> 4;

With the above changes in the code the ADC pins were connected to PWM1 to 6.  However the graphs / watch window does indicate the PWM wave form generation.  Could you please review and suggest how to integrate the ADC capturing of PWM's.  What changes would be needed.

Thx & Rgds

 

  1. AdcRegs.ADCSOC7CTL.bit.CHSEL = 3; /* PWM1*/ \
  2. AdcRegs.ADCSOC7CTL.bit.TRIGSEL = 5; \
  3. AdcRegs.ADCSOC7CTL.bit.ACQPS = 6; \
  4. \
  5. AdcRegs.ADCSOC8CTL.bit.CHSEL = 4; /* PWM2*/ \
  6. AdcRegs.ADCSOC8CTL.bit.TRIGSEL = 5; \
  7. AdcRegs.ADCSOC8CTL.bit.ACQPS = 6; \
  8. \
  9. AdcRegs.ADCSOC9CTL.bit.CHSEL = 5; /* PWM3*/ \
  10. AdcRegs.ADCSOC9CTL.bit.TRIGSEL = 5; \
  11. AdcRegs.ADCSOC9CTL.bit.ACQPS = 6; \
  12. \
  13. AdcRegs.ADCSOC10CTL.bit.CHSEL = 6; /* PWM4*/ \
  14. AdcRegs.ADCSOC10CTL.bit.TRIGSEL = 5; \
  15. AdcRegs.ADCSOC10CTL.bit.ACQPS = 6; \
  16. \
  17. AdcRegs.ADCSOC11CTL.bit.CHSEL = 13; /* PWM5*/ \
  18. AdcRegs.ADCSOC11CTL.bit.TRIGSEL = 5; \
  19. AdcRegs.ADCSOC11CTL.bit.ACQPS = 6; \
  20. \
  21. AdcRegs.ADCSOC12CTL.bit.CHSEL = 14; /* PWM6*/ \
  22. AdcRegs.ADCSOC12CTL.bit.TRIGSEL = 5; \
  23. AdcRegs.ADCSOC12CTL.bit.ACQPS = 6; \

---> PM_Sensorless-DevInit_F2806x.c (Initialising PWM)

  1. // GPIO-00 - PIN FUNCTION = PWM1
  2. GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // 0=GPIO, 1=EPWM1A, 2=Resv, 3=Resv
  3. // GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // 1=OUTput, 0=INput
  4. // GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // uncomment if --> Set Low initially
  5. // GpioDataRegs.GPASET.bit.GPIO0 = 1; // uncomment if --> Set High initially
  6. //--------------------------------------------------------------------------------------
  7. // GPIO-01 - PIN FUNCTION = PWM2
  8. GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // 0=GPIO, 1=EPWM1B, 2=EMU (0), 3=COMP1OUT
  9. // GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; // 1=OUTput, 0=INput
  10. // GpioDataRegs.GPACLEAR.bit.GPIO1 = 1; // uncomment if --> Set Low initially
  11. // GpioDataRegs.GPASET.bit.GPIO1 = 1; // uncomment if --> Set High initially
  12. //--------------------------------------------------------------------------------------
  13. // GPIO-02 - PIN FUNCTION = PWM3
  14. GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // 0=GPIO, 1=EPWM2A, 2=Resv, 3=Resv
  15. // GpioCtrlRegs.GPADIR.bit.GPIO2 = 0; // 1=OUTput, 0=INput
  16. // GpioDataRegs.GPACLEAR.bit.GPIO2 = 1; // uncomment if --> Set Low initially
  17. // GpioDataRegs.GPASET.bit.GPIO2 = 1; // uncomment if --> Set High initially
  18. //--------------------------------------------------------------------------------------
  19. // GPIO-03 - PIN FUNCTION = PWM4
  20. GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // 0=GPIO, 1=EPWM2B, 2=SPISOMIA, 3=COMP2OUT
  21. // GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; // 1=OUTput, 0=INput
  22. // GpioDataRegs.GPACLEAR.bit.GPIO3 = 1; // uncomment if --> Set Low initially
  23. // GpioDataRegs.GPASET.bit.GPIO3 = 1; // uncomment if --> Set High initially
  24. //--------------------------------------------------------------------------------------
  25. // GPIO-04 - PIN FUNCTION = PWM5
  26. GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // 0=GPIO, 1=EPWM3A, 2=Resv, 3=Resv
  27. // GpioCtrlRegs.GPADIR.bit.GPIO4 = 0; // 1=OUTput, 0=INput
  28. // GpioDataRegs.GPACLEAR.bit.GPIO4 = 1; // uncomment if --> Set Low initially
  29. // GpioDataRegs.GPASET.bit.GPIO4 = 1; // uncomment if --> Set High initially
  30. //--------------------------------------------------------------------------------------
  31. // GPIO-05 - PIN FUNCTION = PWM6
  32. GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // 0=GPIO, 1=EPWM3B, 2=SPISIMOA, 3=ECAP1
  33. // GpioCtrlRegs.GPADIR.bit.GPIO5 = 1; // 1=OUTput, 0=INput
  34. // GpioDataRegs.GPACLEAR.bit.GPIO5 = 1; // uncomment if --> Set Low initially
  35. // GpioDataRegs.GPASET.bit.GPIO5 = 1; // uncomment if --> Set High initially
  • We ported over the DRV8312-C2-KIT / DRV830x-HC-C2-KIT version of InstaSPIN-BLDC (GUI Source) to F28069 controlCARD.  This may be useful to you

    https://rapidshare.com/files/222476525/GUI_project_f2806x.zip

     

  • Indiantuktuk,

    I just want to confirm your question.  You want to capture your PWM with an ADC, probably to confirm its operation.  However, in the CCS's graphs/watch windows you are not seeing the value change. 

    If I am right above, then I would suspect that the issue is with the ADC triggering.  From your code, it looks like all the ADC samples are being triggered on a PWM1 Start Of Conversion (SOC).  I don't see the lines of code that tell when the PWM1 SOC will be generate relative to the PWM waveform (EPwm1Regs.SOCASEL), however this will be critical in achieving what you are trying to do.  Note that with the ADC will only be able to capture whether the PWM went high and/or low at a preconfigured time instant, it will not be able to tell you duty cycle, etc.

    Another method of checking the PWM is by using the eCAP module.  By using the eCAP you can count how many cycles the PWM has been high and how many cycle the PWM has been low.  From this data you can reconstruct the PWM's duty cycle and period.


    Thank you,
    Brett