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

Updated MCPWM Implementation for servo control to support ESP-IDF 5.0 (#90) #94

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

purviyeshi
Copy link

@purviyeshi purviyeshi commented Apr 8, 2024

Added v5.1 ESP-IDF support for servo control

  • Refactored servo configuration
  • Updated enable_servo function to create timers, operators, comparators, and generators for each servo group (A-B and C-D) separately
  • Modified set_angle_servo_helper function to set servo angles using the new MCPWM library functions
  • Updated servo angle calculation to ensure compatibility with the new configuration
  • Adjusted logging statements to maintain consistency with the changes in function calls and parameter names.
  • provides more detailed logging messages and utilizes the full capabilities of the MCPWM library for servo control

src/servo.c Outdated Show resolved Hide resolved
src/servo.c Outdated
}

static esp_err_t set_angle_servo_helper(int servo_pin, int servo_max, int servo_min_pulsewidth, int servo_max_pulsewidth, unsigned int degree_of_rotation, mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t gen)
static esp_err_t set_angle_servo_helper(int servo_pin, int servo_max, int servo_min_pulsewidth, int servo_max_pulsewidth, int cmp_num, unsigned int degree_of_rotation)
Copy link
Member

Choose a reason for hiding this comment

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

cmp_num is used and just 0 or 1 is the value, then how will it identify which out of 4 motors are going to turn?

src/servo.c Outdated Show resolved Hide resolved
Copy link
Member

@SuperChamp234 SuperChamp234 left a comment

Choose a reason for hiding this comment

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

The enable_servo() code can be refactored for creating multiple objects, for each servo respectively. Please look into this.

#endif
Copy link
Member

Choose a reason for hiding this comment

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

Please fix these types of newline diffs. They are unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

There is a lot of repetitive logic in this code. Can’t we just create an object of the servo for three different GPIOs? Hardcoding this seems unnecessary.

Copy link
Member

@aPR0T0 aPR0T0 left a comment

Choose a reason for hiding this comment

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

Can you please share testing results?

Refactor the structs in mario-repo

@aPR0T0
Copy link
Member

aPR0T0 commented Apr 14, 2024

@SuperChamp234 I think this fork is ready to be merged, please share your reviews

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

Successfully merging this pull request may close these issues.

3 participants