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 controlSTICK AD conversion resulting wrong values.



Hi,
I'm rather new to C2000 family, currently trying to get some ADC to work, with best possible sampling rate. What i'm struggling with is adc generating noise-like errors while fed with onboard PWM (I have to add, similar thing was happening when using external sinewave generator as signal input).

I'm using F28069 controlSTICK, CCS v6. program i'm testing is Lab3 from C2000 One Day Workshop : http://processors.wiki.ti.com/index.php/C2000_Piccolo_One-Day_Workshop_Module_3

Program was modified so i could adjust period, and duty cycle of measured pwm.
Basically: ADC is triggered from ePWM, at rate of 50kHz. Additional PWM signal is generated (2kHz) and fed to ADC. I'm changing PWM signal period and duty cycle in watch expression window.

Issue is, ADC generates nice results for some frequencies, and errors for others (error group being bigger).
Here are examples:

2kHz (default for lab3)
2kHz PWM

3kHz PWM

10kHz PWM

3kHz graph looks like samples were corrupted or something. At first i thought, that it's related to start of conversion/end of conversion, but if that was the case, then middle samples should be fine. This noise like corruption happens at some frequencies, while others are totally fine. I have to add, oscilloscope shows that all pwms are totally fine, so issue must be adc-side.
I would greatly aprreciate any feedback on this issue.
Best regards,
Karol

  • Hi Karol,

    ADC and MCU work fine. You are hitting the Nyquist limit when the PC samples the date from MCU.
  • Mitja,
    From what you are saying, the problem would be PC-MCU sample rate? Is there any workaround for this issue? My goal is to view and analyze those graphs, and i cannot do that with that much distortion.
  • Karol,

    The system should work fine with 3 kHz PWM.  You are sampling at 50 kHz, so aliasing is not the problem.

    For 3 kHz PWM, you make the following change to the lab include file.  Comment out the 2 kHz settings, and add new 3 kHz settings:

    //#define PWM_HALF_PERIOD 22500 // period/2 for 2 kHz symmetric PWM w/ 90 MHz SYSCLKOUT
    //#define PWM_DUTY_CYCLE 16875 // 25% duty cycle

    #define PWM_HALF_PERIOD 15000 // period/2 for 3 kHz symmetric PWM w/ 90 MHz SYSCLKOUT
    #define PWM_DUTY_CYCLE 11250 // 25% duty cycle

    The graph for 3 kHz PWM looks like this:

    Regards,

    David

  • David,

    Thank You for Your reply.

    3kHz wave looks similar to the one You posted.

    I moved PWM_HALF_PERIOD, PWM_DUTY_CYCLE, and ADC_SAMPLE_PERIOD from .h file into main .c file, and changed their declarations, so i could access them from watch expression window:

    Uint16 ADC_SAMPLE_PERIOD = 1799; // 1799 = 50 kHz sampling w/ 90 MHz SYSCLKOUT Sampling =90/(ADC_Sample_period+1)

    Uint16 PWM_HALF_PERIOD = 9274; // period/2 for 2 kHz symmetric PWM w/ 90 MHz SYSCLKOUT

    Uint16 PWM_DUTY_CYCLE = 8500;

    Changed graph window to show 100 samples - 2 buffer lengths. While graph appears fine for "even" frequencies, it doesn't for odd ones, eg.  4852 Hz, 2760 Hz, 5555 Hz, those being set at random, yet still way below sampling rate. If it was something with buffer reading, with 100 samples on graph, and 50 samples in buffer i should have at least one proper reading.

    Another issue is changing sampling frequency (by adjusting ADC_SAMPLE_PERIOD) to 500kHz, 1MHz - again i'm getting weird readings, while those should be at least even to ones with lower frequency.

    ~5555 Hz, 50kHz sample:

    ~2760 Hz, 50kHz sample:

    2kHz, 1 MHz sample:

    2kHz, 1MHz, buffer length: 500

    Tried to set ACQPS to get longer sample window, it's not getting better.

    Karol.

  • Karol,

    In your first post, you showed a 3 kHz PWM graph that looked wrong. Now, you say your 3 kHz waveform looks correct. What did you do differently this time versus originally?

    - David
  • David,
    This time i started with editing code, so values for PWM_HALF_PERIOD and PWM_DUTY_CYCLE resulting in 3kHz waveform were at the start, while the other time i made change online, using watch expression window. I don't think that's the case - maybe i didn't wait long enough for buffer to get new values, or sampling rate was different - now i can set it both ways, and both ways seem to work. I just can't get those odd frequencies to work.
    - Karol.
  • Karol,

    I do not know what is going wrong with your setup, but I can assure you there is no problem with the ADC or PWM on the F2806x.  I setup my code to generate the ~5555 Hz PWM, sample rate of 200 kHz, and a 200 sample ADC buffer (similar to some of the setups you said you were having difficulty with).

    #define ADC_BUF_LEN 200 // ADC buffer length
    #define ADC_SAMPLE_PERIOD 449 // 449 = 200 kHz sampling w/ 90 MHz SYSCLKOUT
    #define PWM_HALF_PERIOD 8101 // period/2 for ~5555 Hz symmetric PWM w/ 90 MHz SYSCLKOUT
    #define PWM_DUTY_CYCLE 6076 // 25% duty cycle

    Here is the Code Composer graph of the AdcBuf:

    One thing you will notice is that the pulses at sample 100 and sample 120 are closer together than all the other pulses, which are nicely evenly spaced.  This is because you are graphing a circular buffer of ADC samples.  When I halted the processor, the pointer into the AdcBuf was filling new samples somewhere between about sample 112 and sample 122.  The frequency of the pulses does not match with the buffer size, so successive sweeps through the buffer do not overlay.  You will have at most one such spot in the graph where this occurs.  The discontinuity in the graph can take different forms.  In the above case, both sides of the input signal at the discontinuity were zeros (0 volt input to ADC), so the effect is that the two pulses on either side of the buffer filling point (the discontinuity) appear closer together.

    Your graph of 5555 Hz is way out of wack, so you have something else going on.  What I don't know.

    I've attached my code.  You can run it on your F28069 controlstick.  Note that it is a CCS v6.0.1 project (latest CCS as of this date).  Also, this code is similar to the F2806x 1-day workshop code you said you are using, but it is actually the code from appnote SPRA958 (on TI web).  Before you suspect the workshop lab code, believe me there is nothing wrong with the workshop code either.  It is based on the SPRA958 code!

    Regards,

    David

    F28069_PWM_nonBIOS_ram.zip

  • David,
    Thanks to You i found the issue, which was me trying to read data from running mcu - this resulting in overwriting values in buffer, while still reading it, and this giving errors for odd frequencies. Even ones seem to be sampled same points, every time, so even while reading those on running processor, overwritten values were the same as ones written before. So key to this was to halt MCU, and then refresh graph. This is good enough for my purpose. Thank You very much for Your help.
    - Karol.