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.

C2000 LaunchPad PWM and ADC Combining

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I have a PWM code for C2000 LaunchPad and it works correctly. In this code, I can change the duty ratio, the frequency, and deadband time.

I have also ADC code that is on the controlSuite. Now, I want to combine them. I mean, I want to change the duty ratio of the PWMs according to the voltage that I read from ADC.

Could you help me about this job?

Regards

Metin

  • Metin,

    I believe the basic way to do this would be to trigger the ADC off of the ePWM (I think the example code is already this way).  When the ADC completes, trigger an interrupt (I think this is also already in the example).  Inside the ADC interrupt, make decisions based on the ADC conversion results and select new duty cycle, frequency, and/or deadband time (this will need to be added). 

    You will also want to merge in your ePWM initializations.

    Alternatively, there are a variety of c2000 based application kits.  You can find the documentation and source code in ControlSUITE in ..\TI\controlSUITE\development_kits.  If you are doing something similar to these applications (mostly motor control and power conversion) the code + documentation may be useful even without having the actual kit.  

  • Devin,

    Thank you for your valuable responding.

    Actually, I do not use the PWM example that is in controlSuite, I have another PWM code. But I use 'adc_soc' example that is in controlSuite.

     And I want to combine this code with 'adc_soc' example in controlSuite for C2000 LaunchPad. I want to change my duty ratio according to voltage that I read from ADC.

    Thank you.

    Metin

  • Metin,

    I can't tell you exactly what will be required to merge these examples.  All I can provide is some basic advice:

    Start with a working example.  The above code should suffice.

    Understand every line in the above example.  Understand every line in the ADC example.

    Merge as little functionality as possible at a time, then verify that the working example still works.  You might do something like:

    -Add ADC initializations, verify that PWM still works.

    -Modify ADC SOCs to point to the desired control voltages (whatever you want to use to control duty cycle)

    -Add software force to verify that ADC can sample and that the desired pins are being samples, verify that PWM still works, remove software force

    -Add algorithm to transform ADC conversions to PWM duty cycle (don't connect to PWM yet).  Simulate inputs and verify that outputs are as expected.

    -Add ADC triggering from PWM.  Verify that ADC is converting correct signals and that PWM still works.

    -Verify that ADC conversions result in desired PWM duty cycle

    -Connect computed duty cycle to actual PWM

    -Do any further system tuning required