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.

TMS320F28335: 28335

Part Number: TMS320F28335

Hi,

I have generated 2 kHz pwm pulse from ePWM pins. But I want chop the pulse or Doing 'AND' operation between output pulse and high frequency pulse of frequency not more than 10Khz. I cannot use chopper module since the minimum frequency i will get is 1.56MHz. Can you please let me know how to implement chopped pulse without using chopper module or external AND gates?

Thanks, 

  • Hi,

    I am writing to let you know that a C2000 team member has been assigned to answer to this post.

    Thanks
    Vasudha
  • Siva,
    it should be technically possible to configure the PWM at the chopping frequency and then use a timer to control the PWMs non-chopped duty cycle. I have never tried this, but it may work for some frequencies.

    I will ask around if anyone has ever tried to implement a 2KHz PWM that is chopped at 10KHz.

    Regards,
    Cody
  • Siva,
    Would you be willing to run the device slower? You may be able to find a solution if you provide a slower clock to the PWM and use the divide function included with the chopper submodule.

    Regards,
    Cody
  • Dear Cody,

    I also have same issue but is not possible without reducing frequency?

    Thanks,

  • To use the PWM Chopper submodule you would need to run the PWM at a frequency multiple of the chopper's divider.

    If you need your device to run a full speed: Another way to chop the frequency would be to configure two PWMs, one at the chopping frequency(10KHz) and one at the desired PWM frequency(2KHz). You could then configure an interrupt or a TZ from one PWM to force the output of the other to Zero as appropriate. If you're OK with doing this external to the device you may be able to add some external 'AND' logic.

    On newer C2000 devices you may be able to use the Digital Compare submodule to do something similar.
    Regards,
    Cody
  • Has this been resolved?
    If so please mark any helpful posts.

    Regards,
    Cody
  • Dear Cody,

    I have generated chopped pulse by writing software loop. Suppose I have 100us square wave with 50% duty cycle and I toggled that pulse every 20us using timer.

    Here square wave not generated from epwm. Its generated by comparing timer generated triangle and reference. There is synchronization issue if I am using epwm module output for generating chopped pulses. The synchronization between epwm module and chopped gpio pin is not same so I am not getting synchronization between chopped pulse and original pulse.

    So what I have done was generated own triangle using timer and compared with reference to generate pwm pulse. Then putiing another loop to generate chopped pulses on another gpio pin.

    Can you let me know is it a good solution? (Generating own triangle wave and comparing with reference to generate pulses so that synchronization is there between generated pulse and chopped pulse). Below is the generated chopped pulses

    Note: If I am using own generated triangle or ramp using timer with 20us then for 1000hz I am getting only 50 samples i.e discrete samples so even though I set duty cycle some value (52.5%) exact value not reflecting in output square wave because its not continuous triangle its formed by discrete points.

    Thanks,

  • Siva,

    I don't know what you mean by a "generated triangle" and "Reference"... If you explain it another way I may be able to comment more.

    I think the best solution would be to use two PWMs, one running at the chopping frequency and the other running at twice the desired PWM frequency. The higher frequency(chopper) PWM should be connected to the desired output pin. Then the lower frequency PWM can enable and disable the higher frequency PWM in a CTR=PRD ISR. You could disable it using the trip-zone submodule or at the IO buffer, I can think of a reason one way would be better than the other.

    siva swami said:
    Note: If I am using own generated triangle or ramp using timer with 20us then for 1000hz I am getting only 50 samples i.e discrete samples so even though I set duty cycle some value (52.5%) exact value not reflecting in output square wave because its not continuous triangle its formed by discrete points.


    Increasing the frequency of your chopping PWM will help you gain more resolution in your final PWM output.

    Regards,
    Cody

  • I think triangle means time base counter

  • Dear Cody,

    Firstly we are using counter in up mode so indirectly we are generating high frequency triangle by using time base counter. Then we are comparing getting desired duty by comparing it with reference  ( by setting CMPA  or CMPB value to reference value ). So by setting CMPA  or CMPB values to reference, we are comparing high frequency triangle with reference signal to get deisred duty at the epwm output follow the pwm version of reference wavform.

    Secondly there is limitation on chopping pulse with that each pulse should be at least 20us. So I cannot incraese chipping frequency yo high value.

    let me know generating triangle using software code ( time base counter triangle ) and comparing to refrence to generate square wave is it ok? And issue of getting exact duty can be resolved??

    I will share code with you if you need better understanding.

    Thanks,

  • Siva,

    after thinking on this for a while I believe I understand what you are doing, and the issues you are having.

    Please confirm my understanding:

    1. The "high frequency triangle" is actually a PWM that has a period of 40uS (this is you chopping frequency)
      1. Shown by the green line in the scope capture above.
    2. The "reference signal" is also a PWM, this has a slower period than the high frequency triangle.
      1. Shown by the red line in the scope capture above

    The solution you have seems to work pretty well, however it seems like you need to update the CMPA and CMPB values quite often in software. As well as your issue of an inexact pulse width.

    If my understanding is correct I think you will have better results if you use the Trip-Zone submodule to control the output of the high frequency triangle.

    Try this: Set to the desired pulse width of the high frequency triangle and then leave the compare values static. Then enable the one-shot trip of the high frequency triangle, this will allow you to enable and disable the output. 

    Now you need to force and reset the one-shot trip of the high frequency triangle using the SW force. You should use the force the trip or clear the trip in the ISR of the the reference signal. Note you will likely need to double the frequency of the reference signal, this will allow you to enable and disable the high frequency triangle twice per period.

    If i didn't interpret your post correctly then I assume all of this makes no sense at all.

    Good luck,
    Cody 

  • Dear Cody,

    Even though I didn't convey that much clearly, you have understand quite well. Thanks for the efforts. Whatever you understood it's correct main issue is not using epwm.

    Because inorder to eleiminate symcronization issues I have generated my own counter ( triangle) and I am comparing it with reference to get square pulse shown in red waveform above. I wrote software loop whenever it's high I am contiously toggling using software loop where we can control frequency of chopping and pulse width of chopping. Result of chopped pulse using software loop shown in green waveform above.

    Only issue is the generated triangle will have discrete points it's depends on carrier frequency and ISR time period. If I put carrier frequency 1000Hz and ISR time 20us, I will get 50 points in which 25 for for counting up and 25 for counting down. So if I go higher time for isr or high frequency number of sample points reduces which will give inaccurate results even though synchronization issue resoleved using this method. ( Because while comparing refrence might not get in-between points since triangle or counter has discrete points that too less)

    1. Is it a good way to generate own traingle ( counter) and produce chopped wavforms using software loop? (because by this I can eliminate synchronization isssues)

    2. How to improve the accuracy without compromising carrier frequency ( frequency of traingle or counter) and timer ISR? (Counter or traingle accuracy depends on number of sample points generated which inturn depends on above factors)

    I hope you understand. Issue of chopping for lower frequnecies has been resolved by the above implemention and same waveforms shown in previous mail with no issue of syncronization. Only concern is mentioned issues.

    Thanks,

  • Siva,
    What are your synchronization issues?

    When syncing PWMs be sure to sync the faster PWM from the slower PWM otherwise the slow PWM will never work correctly. If you had a small phase off set that can be accounted for in TBPHS the typical value between master and slave is 2.

    Regards,
    Cody