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.

TMS320F280049C: ADC Sampling

Part Number: TMS320F280049C


Hello Support Team,

I need to sample 6 ADC input signals. At least 2 of them need to be sampled at high frequencies (200 ksp per second). Furthermore, these two need to be simultaneous.

The two high simultaneous triggered ADC inputs are set to ADCA and ADCB (for simultaneous sampling).

At least 5 signals need to be triggered by an EPWM, one signal can be triggered by Software only. 

My problem: The UC is not able to sample all my signals, the resulting load is too high (it is alreay to high when I try to sample one input signal with 200 ksp/s). So I need to reduce load. But how can I achieve equidistant sampling for 5 signals when using continuous or burst mode. The best option maybe using continuous mode and let the DMA shift at least the high frequency inputs. 

The sampling rate of the other signals is 12.800 and 25.600 samples per second.

But if I set ADCA and ADCB into burst mode, I cannot guarantee the 5 Signals triggered by EPWM to be triggered equidistant...

Do you have any suggestion what to do? Something like SOC0-7 of ADCA/ADCB are used for adca0, adcb0 (the two simultaneous signals) and the other SOC for the 3 remaining signals which need to be triggered by epwm and the 6 signal I could simply trigger from software only at ADCC. It is important that my samples are equidistant, I don’t want to oversample…

Furthermore, I tried to use burst mode and set it to 16 SOCs, and I measure the time by using the count event option, it results in about 1077 cycles when configured the EPWM to trigger every 500 CPU cycles.

I expect an event every 16*500 cycles....

Setting the Burst mode to 8, same EPWM, I still receive an interrupt after 2000 CPU cycles. I am using the driverlib.

Thanks in advance.

  • Hi Jan,

    I guess there are a couple things to untangle/address here. 

    ---

    First: burst mode.  This doesn't make the ADC sample any faster, but instead allows a single global trigger to cause a burst of conversions.  For example, if ePWM3A is the burst trigger and the burst size is 4, each time ePWM3A trigger is received, the next 4 SOCs will convert.  In the case of all round-robin SOCs, the first trigger will cause SOC0-SOC3 to convert, the next trigger will cause SOC4-SOC7 to convert, ... etc.  This can provide two main benefits: buffering of the ADC results past just the last conversion, and undersampling of some signals (both of which may be helpful for you).

    Consider the following setup:

    • ADC-A + B: burst mode, all SOCs round-robin (no high priority SOCs), burst size = 2, burst trigger = 200kHz ePWM
    • SOC0, 2, 4, ... 14 = channel A0 or B0
    • SOC1 = A1 / B1 
    • SOC3 = A2 / B2
    • SOC5, 7, 9, ... 15 = dummy channel
    • ADC ISR triggered by ADC-A SOC15 

    The ISR will get triggered after 8 ePWM triggers.  RESULT14 for ADC-A and ADC-B will have the latest A0/B0 result and RESULT 12 will have t-1 A0/BO result ... to RESULT0 which has the t - 7 A0/B0 results.  The effective sampling rate for A0/B0 is 200kHz and the ISR rate is 200kHz / 8 = 25kHz.  Samples are equidistant. 

    Each ISR will also generate 1 new result for A1 / B1 / A2 / B2 so the sampling rate for these channels is 25kHz (undersampled relative to the trigger frequency)

    Note: Maybe a better strategy for your specific case would be to use ADC-C for the non-simultaneous samples, with all ADCs in burst mode with burst size = 1.  This would allow 16 A0/B0 results to be processed per ISR and under sampling of up to /16 on the other channels, which gets you to the ~12kHz rate you need. 

    ---

    Second: DMA

    Definitely use the DMA if you are trying to build up a longer record or A0/B0 without taking a control action on every new A0/B0 sample.   You can use this with or without burst mode with the DMA being triggered the same way as the ISR (from the ADCINT).  In the burst mode case, you can trigger both the DMA and an ISR (perhaps the ISR processes the misc. conversions but the DMA is allowed to build up a record of A0/B0 conversions).

    ---

    Third: async. triggering

    One important thing to keep in mind is that if your slower ePWM triggers are asynchronous to the ~200kHz ePWM, you may not be able to get equally spaced samples if the samples share an ADC.  This is because even in the case of 'high priority' SOCs the ADC will not abandon an in-process conversion, so if your slower loop has an ADC conversion in progress, the faster loop's conversions may still be delayed.

    • The PPB delay capture feature can actually be used to determine if and how long (in cycles) a conversion was delayed, if that is helpful
    • The maximum delay in this case would also be approximately the time for 1 ADC conversion, if that is tolerable

    The other alternative would be to allocate your async. conversions to a single ADC (say ADC-C).  This unfortunately isn't recommended/supported on this device because the async. ADCs will cause interference with each other, resulting in poor analog performance. 

    ---

    Overall, can the 3 ADC burst mode situation work for you? Or do your slower ePWM based conversions occur asynchronously or with variable timings relative to the faster ePWM?    

  • Hello Devin,

    thanks a lot for the input. To be honest, this is my first TI device, so I need to ask some further question:

    Is in burst mode the priority always removed? Or do I need to call further routines than ADC_enableBurstMode .

    ______

    To your note: ADC C cannot be configured to use a EPWM if I got the documentation right. But they should also be triggered by an epwm. I could possibly free one timer, but actually they are currently in use. 

    In general we will do a redesign and my hardware said I can choose free which signal are going to be on which ADC.

    ______

    Is there any example to use DMA and burst mode together, or is it simply to setup the config and use DMA_TRIGGER_ADCA0 here?

      DMA_configMode(DMA_CH1_BASE, DMA_TRIGGER_ADCA0,
    (DMA_CFG_ONESHOT_DISABLE | DMA_CFG_CONTINUOUS_DISABLE |
    DMA_CFG_SIZE_32BIT));

    ______

    Third: async. triggering

     What do you mean with asynchronous to 200 ksp.

    ---

    Your Questions:

    Overall, can the 3 ADC burst mode situation work for you? Or do your slower ePWM based conversions occur asynchronously or with variable timings relative to the faster ePWM?    

    The slower ePWM based signals are just average filtered to reduce noise. In this context, I think it is ok, if the samples are not totally equidistant. So the less frequent signals are influenced by the A0/B0, but do not depend on them. Furthermore, I just need to process them let’s say every 100 or 500 ms and I only look at the samples measured during the last A0/B0 periode (one sinus wave of A0/B0 2.5 ms).

    Currently I just use a ISR for every signal, so when processing the signal, I just can stop the EPWM from triggering. If I could move the other signals to ADCC I could just stop the epwm and I do not need to implement a dual head buffer saving memory, but like I asked, ADC cannot use EPWM right? 

    The high sampled signals also should be processed by the CLA, here a DMA could be used to directly move the data to the CLA shared mem?

    Thanks in advance.

    Jan

  • Hi Jan,

    No worries, we'll get things sorted out.   The ADC wrapper is extremely flexible, but this gives it a bit of learning curve.  I'm going to hit the important points here, feel free to ask a follow-up if I missed a sub-question:

    ADC C cannot be configured to use a EPWM

    ADC-C has the same trigger options as the other other ADCs; you can definitely set it up to use ePWM based triggering

     What do you mean with asynchronous to 200 ksp.

    This would be a situation if say ePWM1 was 200kHz and triggering SOC0 - SOC3 while ePWM2 was say 13kHz (or variable frequency) and triggering SOC4-SOC7.  The frequencies aren't evenly divisible, so the ePWM2 triggers will somewhat randomly occur before or after the ePWM1 triggers causing SOCs in both sets to be sometimes delayed.  Based on how things sound, I don't think you'll run into this.

    Is in burst mode the priority always removed?

    Burst mode uses the round-robin (not high priority) SOCs.  By default, all SOCs are round-robin, so burst mode uses all 16 SOCs.  

    If you wanted to do say 3 bursts of 3 conversions it wouldn't divide evenly into the 16 SOCs.  If you set the priority control such that SOC0 to SOC6 are high priority and SOC7 to SOC15 will be round robin then you end up with 9 SOCs for burst mode to use.  The first burst trigger would then convert SOC7-SCO9, the second one SOC10-SOC12, the next SOC13-SCO15, the next SOC7-SOC9, ... etc.  The high priority SOCs use the individual SOC triggers and not the burst triggers (so you can mix burst mode and SOC mode if you really wanted to).

    Is the soc correctly set up?

    Yeah, that looks like the way to set things up, but note that if you set burst size to 2 and set all SOCs to CH0 you'll get a conversion sequence:

    1st PWM1A trigger: 2 conversions, CH0 then CH0 back-to-back (stored in RESULT0 and RESULT1)

    2nd PWM1A trigger: 2 conversions, CH0 then CH0 back-to-back (stored in RESULT2 and RESULT3)

    ...

    Which I don't think is quite what you want. My original proposal used the 2nd conversion in each set to rotate through the slower conversions.

    ---

    Overall, after understanding your requirements more, I think you want:

    ADC-A

    • Burst mode, trigger = PWM1A, burstsize = 1, SOC0-SOC15 = channel 0 (A0)   

    ADC-B

    • Burst mode, trigger = PWM1A, burstsize = 1, SOC0-SOC15 = channel 0 (B0)   

    ADC-C

    • Burst mode, trigger = PWM1A, burstsize = 1
      • SOC0 = 25 ksps signal 1 on ADC-C chan V
      • SOC1 = 25 ksps signal 2 on ADC-C chan W
      • SOC2 = 12.5 ksps signal 1 on ADC-C chan X
      • SOC3 = 12.5 ksps signal 2 on ADC-C chan Y
      • SOC4 = 12.5 ksps signal 3 on ADC-C chan Z
      • SOC5 = dummy
      • SOC6 = dummy
      • SOC7 = dummy
      • SOC8 = 25 ksps signal 1 on ADC-C chan V
      • SOC9 = 25 ksps signal 2 on ADC-C chan W
      • SOC10 = dummy
      • SOC11 = dummy
      • SOC12 = dummy
      • SOC13 = dummy
      • SOC14 = dummy
      • SOC15 = dummy

    SOC15 from one of the ADCs triggers the ADC ISR (and/or DMA and/or CLA task)

    This will result in the 25 ksps and 12.5 ksps signals having equally spaced samples, but some phase offset from each other (because SOC1 and SOC2 will be sampled 1/200kHz = 5us apart, for example).  If that is a problem, I think you'd need to do something like use a slower ePWM module for each sample rate that is synchronized to the 200kHz ePWM. 

    The high sampled signals also should be processed by the CLA, here a DMA could be used to directly move the data to the CLA shared mem?

    I'm not sure if there is any memory that is mapped to both the DMA and CLA.  Generally, the CLA grabbing the results and processing them would eliminate the need for the DMA (since the task is already offloaded from the CPU) and the scheme above already reduces the ISR or CLA task trigger rate to 12.5kHz, which should be very manageable bandwidth wise. 

    I'd recommend getting the sampling scheme working the way you need it, then potentially creating a new thread to ask about CLA or DMA configuration.  This will result in the thread getting routed to someone more knowledgeable about those peripherals (feel free to link back to this thread).    

     

  • Thanks for the detailed answer. This sorted things out.