You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current ComplementaryPwm API in Embassy does not provide fine-grained control over main and complementary outputs. Specifically, the enable(channel) method simultaneously enables both the main (e.g., CHx) and complementary (e.g., CHxN) outputs. Similarly, disable(channel) disables both. This design works well for scenarios like FOC or SVPWM where both outputs are always active with complementary polarity, but it limits the use case for six-step commutation (trapezoidal BLDC control), where:
Only the main output (CHx) or the complementary output (CHxN) is active at any time for a given phase.
Granular control is required to enable/disable CHx and CHxN independently. For example, in six-step commutation, the typical requirement for a phase is:
Step 0: CH1 active (main), CH2N active (complementary), all others off.
Step 1: CH1 active (main), CH3N active (complementary), etc.
This means the API should allow enabling/disabling CHx and CHxN independently for precise control of main and complementary outputs.
Proposed Solution
Add new methods to ComplementaryPwm to independently control the main and complementary outputs:
impl<'d,T:AdvancedInstance4Channel>ComplementaryPwm<'d,T>{/// Enable only the main output for a channel (CHx).pubfnenable_main(&mutself,channel:Channel){self.inner.enable_complementary_channel(channel,false);self.inner.enable_channel(channel,true);}/// Enable only the complementary output for a channel (CHxN).pubfnenable_complementary(&mutself,channel:Channel){self.inner.enable_channel(channel,false);self.inner.enable_complementary_channel(channel,true);}/// Disable both main and complementary outputs for a channel.pubfndisable_all(&mutself,channel:Channel){self.inner.enable_channel(channel,false);self.inner.enable_complementary_channel(channel,false);}}
Benefits
Support for six-step commutation:
This API addition will enable applications that require trapezoidal BLDC control, a widely used method in motor control.
More flexibility:
The changes will allow Embassy users to use a single timer with complementary PWM for applications that require selective enabling/disabling of main and complementary outputs.
Backward compatibility:
The current enable and disable methods can remain unchanged, ensuring existing users are not impacted.
Description
The current ComplementaryPwm API in Embassy does not provide fine-grained control over main and complementary outputs. Specifically, the enable(channel) method simultaneously enables both the main (e.g., CHx) and complementary (e.g., CHxN) outputs. Similarly, disable(channel) disables both. This design works well for scenarios like FOC or SVPWM where both outputs are always active with complementary polarity, but it limits the use case for six-step commutation (trapezoidal BLDC control), where:
Only the main output (CHx) or the complementary output (CHxN) is active at any time for a given phase.
Granular control is required to enable/disable CHx and CHxN independently. For example, in six-step commutation, the typical requirement for a phase is:
Proposed Solution
Add new methods to ComplementaryPwm to independently control the main and complementary outputs:
Benefits
Support for six-step commutation:
This API addition will enable applications that require trapezoidal BLDC control, a widely used method in motor control.
More flexibility:
The changes will allow Embassy users to use a single timer with complementary PWM for applications that require selective enabling/disabling of main and complementary outputs.
Backward compatibility:
The current enable and disable methods can remain unchanged, ensuring existing users are not impacted.
Appendix
My previous six-step commutation implementation based on stm32f4xx-hal: https://github.com/zephyr-atomi/stm32f4-exp/blob/master/examples/motor-exp.rs
The text was updated successfully, but these errors were encountered: