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.
Hello,
I am currently in the process of implementing the possibility of only firing a single PWM pulse when a specific command is send from a MATLAB GUI. Before and after the command the PWM unit should output 0. For that a trip zone event is forced, in which the output of the EPWM is forced low. In order to detect the single pulse, I want to utilize an EPWM interrupt, that detects when the CMPA counter is decrementing. I verified that this interrupt is indeed being triggered and also at the correct position. However when I start the EPWM, so when I clear the trip zone flag, I always receive two unexpected triggers of the interrupt. For testing purposes I always toggle a GPIO pin, which is the yellow line in the picture below. The blue line is the pulse. As you can see after the first two unexpected triggers of the interrupt, the interrupt then is triggered always at the falling edge of the pulse, which is correct. For now I uncommented the force trip zone event in the interrupt, so the EPWM is never forced low by the interrupt, as I first want to understand why the interrupt is unexpectedly triggered. Below you can also find my code.
In menu.c the specific commands are called when starting the PWM unit. Before starting the EPWM, the cases PWMFREQ and PWMDUTY are triggered in the switch statement, after that RUNPWMSINGLE is called. The corresponding function calls as well as the interrupt implementation can be found in pwm.c. Note that I only use EPWM1, so all other initializations of the other EPWM units can be ignored. I initially thought that the the two while loops in the runPWMSINGLE function may cause the problem, however when removing these from the code, the behavior regarding the interrupt is still the same.
I also attached the Matlab GUI that sends all the commands. You may have to adjust the COM-Port for your system. You first have to flash the code to the C2000, after that start the Matlab script, press the connect button enter the desired frequency/duty cycle and click start. Pressing start again terminates the EPWM.
Thank you very much for your help.
Best Nikitadelfino_cpu1.zip
Hello Nikita,
At a glance through your initialization, I believe I've located your problem. Basically, you're correctly forcing the EPWM's output to always be low except when you send your trip signal, but that's not actually what you're using to control the system's output. While you have set up your OST correctly, I believe, you've also set up the event trigger submodule to run the same interrupt whenever the counter reaches CMPA while counting down. (EPWM_setInterruptSource() controls the ET submodule, which doesn't touch the actual ePWM output signals!)
Here's a visual of what I'm trying to say:
Does that make sense? So your system is still responding to the CTR=CMPA signal.
I hope this helps,
Jason Osborn