2023-02-24 08:49 AM
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!
2023-04-03 02:46 PM
Ok, for now, I just manually created #ifdef declarations for each motor profile inside:
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.