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

Motor Control Pulse Width Modulator (MCPWM) #93

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 147 additions & 1 deletion src/mcpwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,171 @@ impl From<CounterMode> for mcpwm_counter_type_t {
// TODO: Note that `red` and `fed` from the IDF's perspecitve is time as in number of clock cycles after the
// MCPWM modules group prescaler. How do we want to expose this? Do we expose it as just that, a cycle count?
MabezDev marked this conversation as resolved.
Show resolved Hide resolved
// Or do we expose it as a time which we then calculate the cycle count from?
/// Deadtime config for MCPWM operator
/// Note that the dead times are calculated from MCPWMXA's flanks unless explicitly stated otherwise
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum DeadtimeConfig {
// TODO: Figure out what all of those options do and give them nice descriptions
/// MCPWM_BYPASS_RED
///
/// . . .
/// . . .
/// .--------------------. .
/// | | .
/// MCPWMXA in | | .
/// | | .
/// --------------- ---------------------
/// . . .
/// . . .
/// .--------------------. .
/// | | .
/// MCPWMXA out | | .
/// | | .
/// --------------- ---------------------
/// . . .
/// . . .
/// .------------------------.
/// | >. |< fed
/// MCPWMXB out | . |
/// | . |
/// --------------. . -----------------
/// . . .
BypassRisingEdge { fed: u16 },

/// MCPWM_BYPASS_FED
///
/// . . .
/// . . .
/// .--------------------.
/// | . |
/// MCPWMXA in | . |
/// | . |
/// --------------- . ---------------------
/// . . .
/// . . .
/// . .----------------.
/// red >. |< |
/// MCPWMXA out . | |
/// . | |
/// ------------------- ---------------------
/// . . .
/// . . .
/// .--------------------.
/// | . |
/// MCPWMXB out | . |
/// | . |
/// --------------- . ---------------------
/// . . .
BypassFallingEdge { red: u16 },

/// MCPWM_ACTIVE_HIGH_MODE
///
/// . . . .
/// . . . .
/// .--------------------. .
/// | . | .
/// MCPWMXA in | . | .
/// | . | .
/// --------------- . ---------------------
/// . . . .
/// . . . .
/// . .----------------. .
/// red >. |< | .
/// MCPWMXA out . | | .
/// . | | .
/// ------------------- ---------------------
/// . . . .
/// . . . .
/// .------------------------.
/// | . >. |< fed
/// MCPWMXB out | . . |
/// | . . |
/// --------------. . . -----------------
/// . . . .
ActiveHigh { red: u16, fed: u16 },

/// MCPWM_ACTIVE_LOW_MODE
///
/// . . . .
/// . . . .
/// .--------------------. .
/// | . | .
/// MCPWMXA in | . | .
/// | . | .
/// --------------- . ---------------------
/// . . . .
/// . . . .
/// ------------------. .--------------------
/// red >. |< | .
/// MCPWMXA out . | | .
/// . | | .
/// . ------------------
/// . . . .
/// . . . .
/// --------------. . . .----------------
/// | . >. |< fed
/// MCPWMXB out | . . |
/// | . . |
/// --------------------------
/// . . . .
/// . . . .
ActiveLow { red: u16, fed: u16 },

/// MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE
// TODO: Is this actually true? --------
// |
// v
/// MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE - The most common deadtime mode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most common deadtime mode
This mode seemed like the one making most sense to me... Is this true or should I remove that comment? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be true (idk :D) but I'd say remove the comment regardless.

///
/// . . . .
/// . . . .
/// .--------------------. .
/// | . | .
/// MCPWMXA in | . | .
/// | . | .
/// --------------- . ---------------------
/// . . . .
/// . . . .
/// . .----------------. .
/// red >. |< | .
/// MCPWMXA out . | | .
/// . | | .
/// ------------------- ---------------------
/// . . . .
/// . . . .
/// --------------. . . .----------------
/// | . >. |< fed
/// MCPWMXB out | . . |
/// | . . |
/// --------------------------
MabezDev marked this conversation as resolved.
Show resolved Hide resolved
/// . . . .
/// . . . .
ActiveHighComplement { red: u16, fed: u16 },

/// MCPWM_ACTIVE_LOW_COMPLIMENT_MODE
///
/// . . . .
/// . . . .
/// .--------------------. .
/// | . | .
/// MCPWMXA in | . | .
/// | . | .
/// --------------- . ---------------------
/// . . . .
/// . . . .
/// ------------------. .--------------------
/// red >. |< | .
/// MCPWMXA out . | | .
/// . | | .
/// . ------------------
/// . . . .
/// . . . .
/// .------------------------.
/// | . >. |< fed
/// MCPWMXB out | . . |
/// | . . |
/// --------------- . . -----------------
/// . . . .
/// . . . .
ActiveLowComplement { red: u16, fed: u16 },

/// MCPWM_ACTIVE_RED_FED_FROM_PWMXA
Expand Down