Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]simple dc_open_loop example not working with esp32 and L296n #293

Open
disc0018 opened this issue Jul 17, 2023 · 8 comments
Open

[BUG]simple dc_open_loop example not working with esp32 and L296n #293

disc0018 opened this issue Jul 17, 2023 · 8 comments
Assignees

Comments

@disc0018
Copy link

I tried to use I simple esp32 and L296n for test reasons.
I was not able to get a working PWM signal.
I changed the DCDriver to DCDriver1PWM2Dir driver = DCDriver1PWM2Dir(14, 2, 27);
(Hardwareconfig was ok. A simple ledcWrite(ledChannel, dutyCycle) was working for test.)

It seems like the following hardware specific code in esp32_ledc_mcu.cpp is never reached:
......

void _writeDutyCycle1PWM(float dc_a, void* params){
  ledcWrite(((ESP32LEDCDriverParams*)params)->channels[0], _constrain(_PWM_RES*dc_a, 0, _PWM_RES));
}
@runger1101001
Copy link
Member

Which ESP32 are you using?

The LEDC driver is only used on some ESP32 models, the ones that don’t have MCPWM peripherals…
To force the use of the LEDC driver, you can set the build flag:
-DSIMPLEFOC_ESP32_USELEDC

unfortunately, we don’t yet support 1-PWM on ESP32 with MCPWM, you have to use LEDC.

the DCDrivers and 1-PWM mode are quite new, you might be the first person testing it on ESP32. Please forgive any bugs you may encounter.

@runger1101001 runger1101001 self-assigned this Jul 18, 2023
@disc0018
Copy link
Author

disc0018 commented Jul 18, 2023 via email

@disc0018
Copy link
Author

disc0018 commented Jul 18, 2023 via email

@runger1101001
Copy link
Member

Hey,

that’s strange. Maybe we are missing some defines to handle this MCU?

normally the code should always prefer to use either LEDC or MCPWM on a MCU it recognizes.

are you using PlatformIO? If so, do you have the option lib_archive = false in your platformio.ini? That would be one explanation

@disc0018
Copy link
Author

disc0018 commented Jul 21, 2023 via email

@runger1101001
Copy link
Member

Where are you putting this flag, SIMPLEFOC_ESP32_USELEDC ?

it has to go in the board definition or platform files to make sure the library is compiled with it…

@disc0018
Copy link
Author

disc0018 commented Sep 3, 2023 via email

@runger1101001
Copy link
Member

Ok,understood, thank you!

We'll leave this open until we've added the 1PWM functions to the MCPWM driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants