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.

Trying to use PWM Macro

Other Parts Discussed in Thread: CONTROLSUITE

I am trying to modify the starting ePWM duty cycle on a 28335.  I began with the PMSM FOC example.

No matter how small I set the inputs to the PWM_Macro, I never get a PW less than 20%. 

I need to begin turning the motor with something less than 10% duty cycle.

 

 

 

 

 

 

 

 

 

 

I have a question regarding the Motor Control Library.  (Just as background - PMSM FOC Sensorless 28335)

More specifically,  I am trying to use the PWM_MACRO.  In order to start my motor spinning, I need the initial duty cycle to be below 10% on all three high side phases.

No matter what inputs I give the macro (e.g.  svgen_dq1.Ta, b and c) I can not get the duty cycle below 20%

Do I need to make changes to the PWM Macro or is their a nice way to do this in the main routine?

 

 

 

 

 

 

 

 

  • I am still trying to understand the 28335 PWM_MACRO in Control Suite.

    The PDF not only does not explain the algorithm, it does not match the number of parameters in the code.

    Finally, Why does the module pass PWM parameters back rather that just setting them in the macro? 

    I assumed that you needed the values down the line, but I see not evidence of that in the HV PMSM FOC example code.

    Thanks in advance

    Will

     

     

     

  • Hi Will,

    Updating the PWM duty cycles with PWM_MACRO is a (3) step process:

    • Update the duty cycle % values using a fractional number represented by Q15 (pwm1.MfuncC1)
    • Call PWM_MACRO(pwm1) to compute the integer value (Q0)to be loaded into the duty cycle registers (compare registers)
    • Update the actual PWM registers with the computed value (pwm1.PWM1out)

    Using these steps you should be able to produce any duty cycle %. 

    The macro was intended to provide convenience.  You can update the compare registers directly anytime in your software without using the PWM_MACRO.

    Jeff

  • Thanks Jeff,  I might be new to this TI terminology, but I have been programming for 35 years.  (Yes I know what a Hollerith card is)

    Bear with me as I try to follow the code in the macro itself,

    First shift the PeriodMax left 15 bits (or said differently mult by 7FFF).   Then shift it right 16 bits  (this feels like a long way to go to get a divide by 2)

    Right now tmp has half of the PeriodMax  Then I add to that, half of the PeriodMax  (So I think that I now have a value that equals the original PeriodMax)

    This leads me to believe that there was more to this once upon a time.

    Now we write this value into 1-3 TBPRD registers.  But we already did that during the Initialization. (I guess that someone might want to change the PWM speed someday)

    Next multiply this same period by the calculated ratios from SV-Gen and store the result in the "out" fields in the pwm1 structure.

    I am just guessing, but I assume that the resulting value is the number of clock cycles of the PWM pulse.

    After all of that, Nothing gets written to the registers until we exit this macro and return to the main code.

    So how close am I?

     

     

  • In addition to all of that above, I passed an IQ 1 in all three MfuncCx's.

    Instead of getting an expected 1 out in all three phases I got ""374"".

    Thus I can safely say that I do not have complete control of the width of every pulse.

    I need to be able to scale the width as a function of  rc1.SetpointValue.

    In order to get there, I need to understand what PWM_MACRO is doing to help me.  Why does it ignore my 3 ones.

    Will Friesen

  • Oh I almost forgot. . .

    I am assuming that the PWM_MACRO module that I am using is:

    C:\TI\controlSUITE\libs\app_libs\motor_control\drivers\f2833x_v1.1\f2833xpwm.c  

    Based on what I am seeing i must be running a different version.

    Will

     

     

  • Will,

    You are asking good questions and it is clear we need to add more documentation to this MACRO and probably others.  With that said, let me give some feedback to your questions.

    The MfuncCx's are scaled for Q15 which has a range of 8000 to 7FFF (hex) which is -1 to almost.  So 1 cannot be represented with a 16-bit variable using Q15.  That is why it is "ignoring" your 3 ones.

    MfuncPeriod is a Q15 number that allows you to vary the period value.  For example, if you have a 10kHz PWM carrier frequency you will have noise emitted at 10KHz.  If you vary the period value then the energy is spread across multiple frequencies reducing the peak emissions.  This is optional and MfuncPeriod can be set to 0.

    Once the PWM_MACRO executes, the data in the pwm structure is updated but the PWM registers still need to be written.  It is debatable whether this macro and structure format is the "best" way.  Our goal is to make the code easy to use and provide excellent performance.

    Hopefully this helps,

    Jeff

     

  • Thanks Jeff,

    That does explain a bunch.  I can take it from here.

    I tried to read the _IQ Math and numbers at least 3 times. . .I could only take so much before needing an afternoon nap. 

    It probably says that the high bit of a Q15 is the "sign" bit.  I have seen that on many other platforms for integer numbers.

    Also your Q15 number description might also explain why every thing is in PU.  Or the PU focus gave us Q15. Either way they work well together.

    Thanks again for your response. .

    I did not see the "Verify" button.

    Will

     

  • Jeff,

    I still need affirmation to my assumption that the output from PWM_Macro is related to duty cycle.

    I have been playing with this all day and the waves on my silly-scope do not reflect a change in duty.

    Will

  • Jeff,

    Never mind. . . I get it now. . . Up means down . . .and down means up.

    Will