Skip to main content
PCama.1
Associate III
February 24, 2023
Question

Multiple Motor Profiles on same MCWorkbench Application

  • February 24, 2023
  • 1 reply
  • 753 views

I have a motor control application generated with MCWorkbench and am successfully using it on my custom board. I added many custom features to the application such as CAN Bus, absolute encoder and my own position control to suit our application. T

I am handling different encoder configurations with #ifdef directives.

This firmware works great but I need to use it with a few different motors.

So what would be the simplest way to modify the application to handle multiple motor profiles and PID gains in the same file?

I don't think the mc_api.c has provisions for that. So I noticed that mc_config.c parameters are already available in main.c so I could change them directly. I considered including drive_parameters.h and pmsm_motor_parameters.h to re-define those parameters in main.c

Thank you in advance!

This topic has been closed for replies.

1 reply

PCama.1
PCama.1Author
Associate III
April 3, 2023

Ok, for now, I just manually created #ifdef declarations for each motor profile inside:

  • pmsm_motor_parameters.h
  • drive_parameters.h.

The caveat is that if code is updated using MC Workbench, these files would be overwritten since they have no "USER CODE" guarded areas. So I am keeping a copy in case I need it.