cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Motor Profiles on same MCWorkbench Application

PCama.1
Associate III

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!

1 REPLY 1
PCama.1
Associate III

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.