-
Notifications
You must be signed in to change notification settings - Fork 792
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
ESP_SimpleFOC 6PWM driver (AEGHB-889) #432
Comments
Support for the 6PWM driver will begin soon. The 6PWM driver can only run on chips that support |
ok, thanks. That's great to hear. |
@YanKE01 , I have tried to make a library for 6PWM but not sure why it doesn't work. If you could debug the code, that would be great, as we are running late on key milestones. Kindly note this is based on esp_hal_bldc_3pwm library files.
#pragma once #include #ifdef CONFIG_SOC_MCPWM_SUPPORTED #define _PWM_FREQUENCY 20000 /*!< default frequency of MCPWM / enum class DriverMode { class BLDCDriver6PWM : public BLDCDriver {
#ifdef CONFIG_SOC_MCPWM_SUPPORTED
private: Here is my esp_hal_bldc_6pwm.cpp
#include #ifdef CONFIG_SOC_MCPWM_SUPPORTED std::vector<std::pair<DriverMode, std::tuple<int, int>>> HardwareResource = { int auto_mcpwm_group = -1; BLDCDriver6PWM::BLDCDriver6PWM(int phA_h,int phA_l, int phB_h,int phB_l, int phC_h, int phC_l, int en1)
} void BLDCDriver6PWM::enable()
} void BLDCDriver6PWM::disable() void BLDCDriver6PWM::setPhaseState(PhaseState sa, PhaseState sb, PhaseState sc) // Set voltage to the pwm pin
} bool checkMcpwmGroupAvailable(int group_id)
} bool checkLedcAvailable(std::vector ledc_channels)
} int checkAvailableDriver()
} void setMcpwmGroupUsed(int group_id) void setMcpwmGroupUnUsed(int group_id) void setLedcChannelUsed(std::vector ledc_channels) void setLedcChannelUnUsed(std::vector ledc_channels) int BLDCDriver6PWM::init()
#ifdef CONFIG_SOC_MCPWM_SUPPORTED
#endif
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
} #ifdef CONFIG_SOC_MCPWM_SUPPORTED
} int BLDCDriver6PWM::init(std::vector _ledc_channels)
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
} int BLDCDriver6PWM::deinit()
#endif
} void BLDCDriver6PWM::halPwmWrite()
} |
Hi, @dayro-ram .We're glad to see your interest in TEST_CASE("test 6pwm driver", "[driver][6pwm]")
{
BLDCDriver6PWM driver = BLDCDriver6PWM(1, 2, 3, 4, 5, 6);
driver.init();
driver.dc_a = 0.2;
driver.dc_b = 0.4;
driver.dc_c = 0.8;
while (1) {
driver.halPwmWrite();
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
} |
@YanKE01 Thanks for your quick response. We will try following your suggestion to keep the 6PWM library in a separate component folder. For now we got 6PWM working by using Arduino as component. We look forward to get 6PWM working library soon. I have shared the code with a hope that the code help expedite the development. Thanks again. |
Hi @dayro-ram @HirenDayro017 . Thank you for your attention to esp_simplefoc. Support for the 6PWM mode has been added in version |
HI @YanKE01 Thanks for quick support. We have tested foc_velocity_control example by changing necessary object instantiations & tested. The code is working. We will explore more and provide update if we encounter any issues. |
Hi @YanKE01 ,I tried the foc_knob_example with my "SparkFun IoT Brushless Motor Driver" board. Here is the code snippet: /**********************************************************************************************************************/ /update motor parameters based on hardware design/ void tmag_init(void)
} /Motor initialization/
#if USING_MCPWM
} /**********************************************************************************************************************/ Here is the log: PS D:\Other\foc_knob_example> & set IDF_PATH='C:/Espressif/frameworks/esp-idf-v5.1.5/' rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) load:0x40080404,len:3876 I (0) cpu_start: App cpu up. /**********************************************************************************************************************/ Here is how it behaves, the motor keeps hunting. PXL_20241206_062958033.mp4 |
Hi, @HirenDayro017 .From the log, it seems to be an error in the pole number estimation. Please fill in the correct pole number based on the specific motor parameters. I have encountered a situation before where the distance between the magnetic encoder and the magnetic ring was too far, which led to an incorrect pole number estimation. In any case, you can check whether the magnetic encoder is functioning properly. Additionally, You can also troubleshoot the problem by comparing the hardware output of arduino-foc. I don't have any 6PWM drivers around, so if you can, send me the PCB and I'll prototype and test it. |
Hi @YanKE01 , have a look at the log from the code in which I have added SimpleFOC as Arduino Component. The code works pretty fine in this case. Simple FOC as Arduino Component: "components/arduino/libraries/Simple_FOC/src/" Here is the same configuration: #define DRIVER_FAULT_GPIO 12 using namespace std; BLDCMotor motor = BLDCMotor(7); /**********************************************************************************************************************/ PS D:\Dayro\Knob> & set IDF_PATH='C:/Espressif/frameworks/esp-idf-v5.1.5/' rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) load:0x40080404,len:3876 I (0) cpu_start: App cpu up. I (0) cpu_start: App cpu up. I (3728) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us MAIN: Sensor Init Success!! /**********************************************************************************************************************/ Here is the behaviour: sparkfun_board.mp4 |
It looks quite fascinating. Perhaps we could add print statements individually in the angle sensor or driver to investigate further. I usually use the 3PWM driver, so the 6PWM driver was only tested for feasibility with the waveform. I will try prototyping a board to test it out. You could also try investigating and submit a PR. |
sure @YanKE01 , I will let you know if I find anything useful. Thanks. |
Answers checklist.
General issue report
How soon can we get esp_hal_bldc_6pwm driver for a bldc driver that needs 6pwm?
The text was updated successfully, but these errors were encountered: