Sample time for task 0 on CPU 0 too small - raise sample time or system clock rate

Hope everyone is doing well. I am using F2837xD LaunchPad for the PWM generation by using ePWM, I am facing two problems. The first problem is when I add the ADC converter in the PLECS for the implementation in F2837xD, then let’s say I am reading ADC A. Initially, I attach 3.3 V on that port so it works OK. But when I change the value according to the change, my duty cycle will be changed, but it is not changing and only showing the initial value calculation. From what I understand, it is not updating the real-time value. And also, why can I not see the ADC value by using the scope?

Link for the file: https://drive.google.com/file/d/1yB3Rro4tCg64PYwPEuFdEL_QL_JWsRci/view?usp=sharing

2nd problem: In the high switching frequency simulation (500 KHz), it shows this error (I also attach the file): Sample time period and/or offset [2e-06, 0] are not an integer multiple of the base step size (1e-05).

When I decrease the discretization time, then it shows: Sample time for task 0 on CPU 0 too small - raise sample time or system clock rate. What I can do for it. Link for the file: https://drive.google.com/file/d/1dpbqOuiEVPbCnqRRXGIykOfBUulxng-c/view?usp=sharing

Have a great day.

Hi Sahdev,

Hope you are doing well.

The first problem is when I add the ADC … also why can I not see the ADC value by using the scope? I also attach the PLECS file here.

I had a look at your model and the reason you are not seeing the scope update is because “External Mode” is not enabled. I would recommend you read the section “Start the External Mode” in our C2000 TSP documentation. It goes through details on how to configure and use external mode. Additionally, you may find this youtube playlist helpful as you get started.

In addition to the youtube playlist and TSP documentation, I recommend having a look at the demo model "Simple Model” that is part of the C2000 TSP → this shows examples of using multiple different peripherals

Also, just want to confirm that you are using are using a control card. If you are using a Launchpad then you’ll need to change your board configuration under “Coder Options > Target > General > Board”. .

I see that you are running your controller at 100kHz. When I try to compile your model as is, I am unable to connect to external mode likely because of the high controller execution frequency. Once I changed the switching frequency to something lower (I changed it to 1kHz just for testing) and was able to connect to it. I am able to see the duty cycle changing. I would recommend adding a visual indicator via a blinking LED to see if your compiled code is experiencing overrun issues. Please see the demo model “Simple Model” mentioned above for an example on how to do this.

Finally, could you elaborate on this part "What i understand, it is not updating the real-time value. “. Are you not seeing the PWM output duty cycle change? When I run it on my side I see the PWM change as I change the voltage on the ADC pin.

2nd problem: In the high switching frequency simulation (500 KHz), it shows this error (I also attach the file): Sample time period and/or offset [2e-06, 0] are not an integer multiple of the base step size (1e-05).

I’m not entirely sure what you’re trying to achieve in your second model. It appears that you’re feeding a 50% duty cycle into the PWM, but to generate that duty cycle you’re using a 500 kHz PWM signal. If your goal is to experiment with different duty cycles, I recommend using a Constant block with an inlined parameter instead. This allows you to use External Mode to connect to the MCU after programming, adjust the duty cycle from PLECS, and observe the PWM outputs on a scope. I also recommend going through the C2000 tutorial on our website (just search for “C2000” in the search bar).

Regarding your discretization step size of 1 µs (1 MHz control rate), there are a couple of considerations:

  • Your PWM switching frequency is 500 kHz, so running the control algorithm at 1 MHz is unusual. Is that your intention?

  • You may encounter controller overflow issues. As you add functionality to your control algorithm, you will likely need to slow down the control task to ensure the processor has enough time to complete all computations before the next cycle. See Problems with application of ePWM block in Digital Control - #4 by sullivan for guidance on setting controller execution time.

Best,

Munadir