-
Notifications
You must be signed in to change notification settings - Fork 211
Motor Control Pulse Width Modulator (MCPWM) #93
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
Open
usbalbin
wants to merge
24
commits into
esp-rs:master
Choose a base branch
from
usbalbin:mcpwm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b42c6d5
The beginning of a first rough draft...
usbalbin 507dd8b
Fix some of the TODOs, disable example for esp variants without mcpwm
usbalbin e4ed558
Fix clippy lints
usbalbin 1e2a947
Update cfg's
usbalbin 6260781
use esp_idf_sys::*
usbalbin f2d6c0c
Address some of the comments and add deadtime support
usbalbin 7a76c5c
Clippy
usbalbin 5ef5013
Fix warnings in example
usbalbin eaf4ae7
Fix example
usbalbin 16df098
Add some docs for deadtime modes
usbalbin d989ba2
Added Mcpwm::operator_source_frequency
usbalbin 16657d9
cargo fmt
usbalbin 0d490fd
Add more documentation
usbalbin b17a9ff
Update example(crashing)
usbalbin 0af99da
Work around float printing issue
usbalbin b2ae6e7
Clarify deadtime
usbalbin 4820189
Some cleanup
usbalbin a12baad
Fix some methods missing their self
usbalbin 07691e7
Final(?) adjustments to doc
usbalbin 295f0bc
Explain example mcpwm-simple
usbalbin 018056a
Allow setting initial duty in OperatorConfig
usbalbin 9b9d9f6
Clamp timer resolution to not be greater than timer group resolution
usbalbin 52e4542
Expose Mcpwm's unit and Operator's timer
usbalbin 3d37b0c
Merge branch 'master' into mcpwm
usbalbin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #[cfg(any(esp32, esp32s3))] | ||
| fn main() -> anyhow::Result<()> { | ||
| use embedded_hal::delay::blocking::DelayUs; | ||
|
|
||
| use esp_idf_hal::delay::FreeRtos; | ||
| use esp_idf_hal::mcpwm::{Mcpwm, Operator, OperatorConfig}; | ||
| use esp_idf_hal::prelude::Peripherals; | ||
| use esp_idf_hal::units::FromValueType; | ||
|
|
||
| esp_idf_sys::link_patches(); | ||
|
|
||
| println!("Configuring MCPWM"); | ||
|
|
||
| let peripherals = Peripherals::take().unwrap(); | ||
| let config = OperatorConfig::default().frequency(25.kHz().into()); | ||
| let mcpwm = Mcpwm::new(peripherals.mcpwm0.mcpwm)?; | ||
| let mut operator = Operator::new( | ||
| peripherals.mcpwm0.operator0, | ||
| &mcpwm, | ||
| &config, | ||
| peripherals.pins.gpio4, | ||
| peripherals.pins.gpio5, | ||
| )?; | ||
|
|
||
| println!("Starting duty-cycle loop"); | ||
|
|
||
| for &duty in [0.0, 20.0, 40.0, 60.0, 80.0, 100.0].iter().cycle() { | ||
| println!("Duty {}%", duty); | ||
| operator.set_duty_a(duty)?; | ||
| operator.set_duty_b(100.0 - duty)?; | ||
| FreeRtos.delay_ms(2000)?; | ||
| } | ||
|
|
||
| loop { | ||
| FreeRtos.delay_ms(1000)?; | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(any(esp32, esp32s3)))] | ||
| fn main() {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.