Comments (2)
Hey @byDagor ,
I'm having trouble reproducing this behavior, what is the arduino-esp32 version that you're using?
from arduino-foc.
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:
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.
And 25kHz PWM, it is even worse. Even for 0 phase voltage the adcRead
enters the high-side active PWM period.
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)
- Allow sensors to return no angle (or bad angle) HOT 1
- Unified init() method
- motor.run()
- [BUG] Strange behavior on ESP32 HOT 1
- [BUG] Fix KV initialization HOT 1
- [BUG] incorrect pins used in DRV8302 6-PWM example HOT 2
- [FEATURE] Two issues with MagneticSensorPWM HOT 3
- [FEATURE] Performance of setting the PWM duty cycles HOT 8
- [FEATURE] Add library.json to set libArchive? HOT 2
- [BUG] BLDCDriver6PWM issue with STM Nucleo HOT 14
- [BUG] OpenOCD init failed while using specific pin HOT 6
- Update KV estimation example to match new code
- [FEATURE] Allowing to choose SPI pins HOT 1
- Can't change PWM frequency - 550hz [BUG] HOT 8
- [BUG] Monitor downsampling cannot be disabled HOT 2
- 20bit magnetic encoder support
- [BUG] Error in doc: initFOC() cannot be used in open loop mode HOT 1
- driverAlign() ignores gain sign, always "MOT: Success: 3" HOT 3
- [BUG] PlatformIO adding SimpleFOC requires to specify SPI and WIRE lib_deps to prevent compile errors HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-foc.