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.

Sampling ADC during "on" and "off" times of a PWM input

Other Parts Discussed in Thread: CONTROLSUITE

Hello,

I've adapted the adc_soc example from the controlSUITE for my application. I want do ADC conversions on the "ton" and "toff" times of an input PWM which is in sync with my ePWMA/B. I can do ADC conversions on either one or the other by setting PWM_SocPulseSrc_CounterEqualCmpAIncr or PWM_SocPulseSrc_CounterEqualCmpADecr however I cannot find a setting where I can do both conversions on the same SOC0.

I've played around with the following ideas -

1. Declaring multiple interrupts (as I would like to distinguish ton and toff data anyway)
2. Using a single interrupt and declaring two SOCs.
3. Having a separate clock 2x my input frequency.
4. I even tried dynamically changing PWM_SocPulseSrc_CounterEqualCmpAIncr  to PWM_SocPulseSrc_CounterEqualCmpADecr 
 

I experienced challenges in implementing all ideas - couldnt get any working as I wanted. Can anyone point me the right direction to go ... or any examples doing something similar? Thanks!

JC.

  • Hi,

    I would like you to go through the Event trigger sub-module from this doc:

    http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spruge9&fileType=pdf

    Regards,

    Gautam

  • Hi Jay,

    I am not sure if I exactly understood your sampling requirements and the difficulties therein; it may be helpful to draw out the waveforms to specify exactly where you want the sampling to occur.  

    However, based on my limited understanding, is it possible to use two SOCs instead of one (say SOC0 and SOC1 instead of just SOC0)? You could use different triggers, but the same acquisition window and channel selection.  You could also map both ISRs to the same function.  In this case, in the ISR function, you would alternate between reading ADCRESULT0 and ADCRESULT1.

  • Devin,

    See rough sketch below.

    Yes, I agree that multiple SOCs have to be used on same channel. That is my current setup. However I mapped the ISRs to multiple functions adc_isr_ton and adc_isr_toff. 

    Even using that technique I still had some difficulty making the conversion happen on both ton and toff ...

    Using the PWM_setSocAPulseSrc(myPwm1, PWM_SocPulseSrc_CounterEqualCmpAIncr/Decre) and writing CMPA register just caused my duty cycle to change (as I right expected), it does not shift the point where the conversion starts ...


    JC.

  • Devin, did you take a chance to look at the sketch? ... Any further recommendation? I can post some of my code ...

  • Jay,

    It may be possible for duty cycle to change but SOC trigger not to change depending on how the ePWM is configured.  I think you should refer to these diagrams:

    What is the counting mode of the ePWM? If up/down I think you may want one SOC to be triggered off of CMPA up and the other off of CMPA down.  If up-count mode, then you probably want one to be triggered off CMPA up and the other to be off of CMPB up.