Skip to content

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

Open
purviyeshi wants to merge 13 commits into
SRA-VJTI:mainfrom
purviyeshi:main
Open

Updated MCPWM Implementation for servo control to support ESP-IDF 5.0 (#90)#94
purviyeshi wants to merge 13 commits into
SRA-VJTI:mainfrom
purviyeshi:main

Conversation

@purviyeshi
Copy link
Copy Markdown

@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

Comment thread src/servo.c Outdated
Comment thread 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
Copy Markdown
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?

Comment thread src/servo.c Outdated
Copy link
Copy Markdown
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.

Comment thread include/servo.h
int read_servo(servo_config *config);

#endif No newline at end of file
#endif
Copy link
Copy Markdown
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.

Comment thread src/servo.c
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

aPR0T0 commented Apr 14, 2024

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

@VedantParanjape
Copy link
Copy Markdown
Member

Same here @5iri

@5iri
Copy link
Copy Markdown
Member

5iri commented Nov 9, 2025

this should be tested on current board to ensure this even works actually. will update this if we need this or not once we actually can test with the complete setup

@VedantParanjape
Copy link
Copy Markdown
Member

VedantParanjape commented Nov 11, 2025

this should be tested on current board to ensure this even works actually. will update this if we need this or not once we actually can test with the complete setup

https://github.com/SRA-VJTI/sra-board-component/actions/runs/19231537063/job/54970998805?pr=100#step:5:1171

I think you should get this PR merged as current MCPWM code is deprecated. Check the build logs, it gives a warning. Not a high priority as Wall-E doesn't use PWM, but keep it in mind

@5iri
Copy link
Copy Markdown
Member

5iri commented Nov 12, 2025

from what I heard from @Shankari02, this pr is not complete as this is not resolved for servos.

I'll test this code and update the progress.

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.

5 participants