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.

TMS320F28377D: PWM wavefrom generation

Part Number: TMS320F28377D


Hi.

I have a special PWM waveform that i need to produce for my converter. It's shown in Fig.1. EPWM chanel has be updated three times in a switching cycle. 

My question is: There are only two CMP events (A and B) available on the ePWM module. Is there a way to use the third one somehow? Or can I use some kind of inner logic to couple two pwm channels to produce one common waveform? How can I generate such a waveform on 28377D? Is it possible? 


Thank you for your responce!!!

  • Hello Aleksander,

    The good news is that there is a CMPC/D in the ePWM module! All four CMPx compare signals act as inputs into the Event Trigger (ET) sub-module. However, only CMPA/B are set up to directly affect the duty cycle of the ePWM outputs via the Action Qualifier (AQ) sub-module, so they are more commonly referenced than C/D.

    The ET sub-module is able to generate an interrupt based on CMPC/D (as shown below, pulled from the device TRM), and in that interrupt, you should be able to configure an AQ software-forced-event to toggle the ePWM signal.

    CMPC/D signal-to-interrupt path

    Keep in mind, however, that I have not tried this implementation myself, it would be something that you would have to test within your application.

    Additionally, there's a few things you'll need to be careful of. If CMPC is very close to, for example, CMPB, the software-force AQ actions take first priority, meaning you could potentially miss an AQ action.

    Also, if you set up an interrupt for when CMPC is incrementing and decrementing, both events will 'map' to the same ISR, so you'll need to figure out whether the counter is counting up or down. You could simply perform a toggle via the AQ so that this doesn't need to be considered, but depending on the complexity of your application, this may not be sufficient. If that's the case, you can check the interrupt flags to figure it out, but this will be additional conditionals and time spent in the ISR.

    All that said, this should allow you to utilize CMPC in an analogous way to how CMPA/B are used. Hope this was able to help!

    Regards,

    Jason

  • If I use the Event Trigger and Interrupt to toggle or act on my PWM waveform, does this mean that DeadBand module would be skipped and i should use some other means to make sure there is deadband time between ePWMA and ePWMB?

  • Hello Aleksandr,

    As the implementation above ultimately routes back into the AQ sub-module, everything that comes after the AQ is still utilized- including the deadband. As mention previously, the timing of the signal's arrival into the deadband may be thrown off a bit from a more typical implementation, and it may require you to adjust values from what would be expected if it were a direct connection. AQ->Deadband and AQ->ET->software (ISR)->AQ->Deadband are going to inevitably have different execution times, after all! I wouldn't expect any adjustments (if needed at all) to be particularly drastic, but again, I've not had the opportunity to try this implementation myself.

    Always happy to help,

    Jason

  • Hi, Jason.

    According to your suggestion I implemented the code for CMPC.

    The problem that I found that it takes around 500ns from the moment the CMPC up event happened till the actual toggle of the PWM output waveform. Is it normal that interrupt routine takes that much?

    I set up unused ePWM1 module to generate interrupt when CMPC event is met. Also, because I have the main interrupt where the FOC Motor Control (ePWM6 interrupt) code is running I had to use a nested interrupts where ePWM1 interrupt is of the highest priority to be able to toggle PWM output both when counter goes up and down. Here is the code:

    The waveforms that i get with this realization are in the picture below. You can see that it's not equally spaced around the center (center of the yellow pulse is the center of counter PRD) which gives me a conclusion that interrupt routine is kinda slow. The dead-band time is 0.  For my case 500ns is not tolerable. 



    Also, i'd like to ask if it is possible to set up the interrupt generation events of CMPC to both counter up and down cases?  In the datasheet i found that only one ca nbe used at a time.



    Best regards!

  • Hello again Aleksandr! Apologies for how long it took to get back to you, I was unfortunately out of office for a bit.

    From what you're describing, it seems like the AQ->ET->SW->AQ cycle that I described above is taking quite a bit of time, as I discussed being worried that it might. Thankfully, a colleague of mine suggested a much more intuitive, straightforward, and significantly speedier alternative to this that's built into our device- the CLB, Configurable Logic Block! As a side note, this approach should also let you bypass the issue of the ET's up/down interrupt generation entirely. It still allows you to use everything that follows the AQ, but lacks some of the safety and edge-case handling that the AQ provides.

    Basically, the CLB can take certain internal signals to the device and manipulate them with customized logic. In this particular instance, we'd be taking the the CTR=CMPC and PWMx[AQ] signals as inputs to our CLB logic tile. These are, respectively, the signal indicating that the counter has reached CMPC and the (A or B) output of the AQ module. Then, we can set the output of the CLB logic tile to override the PWMx[AQ] signal, feeding back into the rest of the ePWM module as normal!

    The CLB tile can be set up to act as a simple finite state machine, FSM. Since we're doing an up/down counter and doing nothing other than toggling the waveform each time the signal hits, the internal behavior is relatively simple. Each time the value of CTR=CMPC pulses, toggle whether or not the tile is outputting the PWMx[AQ] signal or NOT(PWMx[AQ]).

    If you are unfamiliar with how to set up the configuration of the CLB, the CLB training for C2000 MCUs video series provides a fantastic starting point for learning how to use the tool! I highly recommend these videos- along with the relevant C2000 Academy section, they're the foundation of my knowledge on using the CLB.

    Overall, this approach is significantly faster and more reliable than what I had suggested previously, not requiring use of the ET, any software interrupts, or the SW force AQ event- apologies for that!

    I hope I could help,

    Jason Osborn