Git Product home page Git Product logo

Comments (2)

askuric avatar askuric commented on July 17, 2024

Hey @byDagor ,
I'm having trouble reproducing this behavior, what is the arduino-esp32 version that you're using?

from arduino-foc.

askuric avatar askuric commented on July 17, 2024

So I've done some testing on this issue today and I'm having trouble understanding where the problem comes from and why this new code solves it. :D

Basically, as the phases A,B and C of the motor (both 3pwm and 6pwm) are synced, there is no need to do interrupt for every one of them separately, one is enough. Additionally, eve if you enable interrupts on all of them they are just gonna fire at the same time (but they are gonna fire the same interrupt calling the same function only once).
I've tested this in my code and both in case of enabling one or two phases the interrupt is called only once per pwm cycle, but the status flags mcpwm_intr_status_0 and mcpwm_intr_status_1 are both in 1 if both phase interrupts are enabled.

Scope testing

I've so far only tested on my scope.
So what I can see in my scope, both your new implementation and the old one have exactly the same behavior. Updating the same registers and at the same time.

Here is the comparison on by scope

  • cyan line is the PWM at 0.5 duty cycle at 15kHz
  • yellow is the call of the interrupt (twice per cycle) - just like an impulse when the mcpwm0_isr_handler is called.
  • blue is the reading of the adcRead for phase current 1
  • violet is the reading of the adcRead for phase current 2
    Old code:
    IMG_20240302_124859

New code:
IMG_20240302_125429

Potential explanations

The adcRead function takes around 10us to read the current value which ic pretty terrible. For the pwm frequencies above 20kHz the low-side current sensing will not work well. So if you've been using it with more than that the current readings have probably been done in some part during the part of the PWM where the high side is on.

Here is the 20kHz PWM - for 0.5 duty cycle (the center) its already almost entering the high-side active part of the duty cycle - this is not good. For any non-zero phase voltage the adcRead will enter this period.
IMG_20240302_125846

And 25kHz PWM, it is even worse. Even for 0 phase voltage the adcRead enters the high-side active PWM period.
IMG_20240302_130119

I have no idea why the new code has solved the issue though.
This issue will need further investigation.

from arduino-foc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.