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.

F28069 ADC setup to work as sequencer?

Hi,


I'm using the Piccolo F28069 and wanted to perform some ADC conversions in a way similar to the ADC sequencer that can be found in other DSP models. As Piccolo devices ADC is based on SOCs, it is being really difficult for me to achieve my targets in making the right setup to this peripheral.

What do I need? I'm trying to read twice 6 different channels in simultaneous sampling mode, but not all in a continuous way. Let me explain orderly what I want to get:

  1. SOC0+SOC2+SOC4 (6 simultaneous channels) generated by ET when EPWM1 incrementing counter equals CMPB; No interrupt generation after any EOC. Conversion results will appear in ADCRESULT0...5.
  2. In the next PWM period, i want to trigger SOC6+SOC8+SOC10 (same 6 channels simultaneously). I don't know how to trigger these SOCs. After EOC11, I need an interrupt, which I supose can be selected in INTSEL1N2.INT1SEL. Results will be saved in ADCRESULT6..11.
  3. Inside the ISR generated by EOC11, I'm going to read all 12 results and copy them into a buffer.
  4. After copying them, just start all over again.

I made a hand-made schematic.


To give more information: I'm using HRPWM1A and HRPWM2A to control a Full-bridge LLC converter. The switching frequency is variable (130kHz - 200kHz), so the control code (40kHz fixed) cannot be executed inside a pwm-synchronised interrupt. In this case, ADC is converting in every PWM period, I save the values and then make a mean with the last 4 values of each channel.


If you could help me with your experience, I'd be very grateful! Thanks,


Alex

  • Hi Alex,

    As I understand it, the ePWM is being used as a timer only to trigger the ADC, and it runs at a fixed frequency of 40KHz?

    Can you setup the ePWM to run at 20KHz with ePWM ADCSOCA and ADCSOCB evenly spaced (I think up/down count with A triggered on PRD and B triggered on ZERO).  Then setup SOC0-SOC4 to use ePWM ADCSOCA as the trigger and SOC6-SOC10 to use ePWM ADCSOCB as the trigger?

  • Hi Devin,

    Thanks for helping me.

    As I wrote before, I am using module ePWM1 and ePWM2 (High-resolution, only A outputs) to control the high-frequency full-bridge of the LLC converter. As MOSFETS of the full-bridge are switching in a diagonal way, I can manage to do it with just 2 PWM gate signals. The switching frequency (Fsw) changes between 130kHz and 200kHz.

    On the other hand, Timer0 is configured to generate interrupts at 40kHz. There's the mean calculation, state-machine and the controller.

    40kHz/Fsw = 4samples (aprox.) It's quicker to calculate the samples mean dividing by 4 (just shifting >>2) than by 3 or 5 samples. Suposing that I always take the last 4 samples of each channel to calculate the mean, I have to save these 24 ADC values. To save them, I purpose to use the ADC sequence explained before. Every 2 PWM periods, I'd like to have an interrupt where I would save the 12 result values in the highest positions of a 24-size buffer. When the next 2 PWM periods finish, I would have another interrupt, saving the 12 result values in the lowest positions of the buffer. For next periods, results are going to overwrite the oldest ones in the buffer.

    I could also do that (convert + channels + save to buffer) every PWM period, but it would take some time in every PWM period which I might need for other interrupts (like Timer0) or other issues. BTW, it would be better in refreshing the ADC values stored in the buffer.


    The idea you purposed could be right if the Fsw was fixed. As there's a closed loop, this frequency is always variing, so I'd have to synchronize constantly the PWM1,2 to a third PWM (PWM3 for example). PWM3 should be configured in every PWM1,2 period to make sure it is configured at half the Fsw. Also, synchronization pulses would make PWM3 counter to restart from 0, so in up-down mode, it would only appear the up-part (cause synchronization pulse would restart the counter at half the PWM3 period [not PRD] ). It would be different if the synchronization pulse could be generated every 2 PWM1,2 periods... but I think that's not possible.


    Any other idea? Is it so difficult to use the SOC based ADC as if it was a Sequencer based ADC? Does the Round-Robin wheel have any MAXCONV-equivalent parameter just to sample 3 SOCs every time?


    Thanks for your ideas,

    Alex

  • Actually, the fastest way to copy this values is using DMA. I've never used it, so I'm going to read all possible information from TI and try to configure it correctly.

    The main structure of the ADC saving is the same: convert 6 channels + save them in a buffer  (use a 24-size buffer to save 4 values of each channel).

    When doing so, I have two options of saving the values depending on the RESULTx allocation in the buffer:

    • RES0 - RES1 ... RES5 - RES0 - RES1 ... RES5 - RES0 - RES1... RES5 - RES0 - RES1... RES5

    or

    • RES0 - RES0 - RES0 - RES0 - RES1 - RES1 - RES1 - RES1 - RES2 - RES2 - RES2 - RES2 - RES3...

    I supose the second one is better when accessing the values to calculate the mean:

    (RES0+RES0+RES0+RES0) >>2

    And the first way to save them is easier to configure. Am I wrong? Any hint?

    Thanks,

    Alex

  • Alex,

    For the 40KHz ePWM, I think you can use it the same way you are using the CPU timer (asynchronous from the control ePWMs), but just have it have 2 synchronized trigger events.

    The DMA would also work.  I think you will want to go with the first method because it will only require a single DMA channel.  You should still be able to easily calculate the average for that case.  

     

  • Devin,

    I have finally used the DMA in the first method (all results from same channel together in the buffer). It's been quite easy to configure the DMA. It can also use one single DMA-channel. When reading the values in the timer interrupt, I've used "register" pointers, cause it's the fastest way I know to go through the buffer picking the values and calculating the mean.

    Thanks for your time,


    Alex