Skip to content

Motor cleanup#235

Draft
cdn-lnk wants to merge 10 commits intopaulscherrerinstitute:masterfrom
cdn-lnk:motor_cleanup
Draft

Motor cleanup#235
cdn-lnk wants to merge 10 commits intopaulscherrerinstitute:masterfrom
cdn-lnk:motor_cleanup

Conversation

@cdn-lnk
Copy link
Contributor

@cdn-lnk cdn-lnk commented Sep 15, 2025

Hi @anderssandstrom ,

As per our last meeting this MR is a full review of the motor configurations for the EL7031, EL7037, EL7041, EL7041-0052 and EL7047 drivers.
This should also fix the current issue with the EL7037.

For those not present, summary and rationale are presented below.

IN PROGRESS
I will update the description and let you know when it is ready.


The current state of motor configuration has the 1) running current, 2) reduced current and 3) monitor voltage defined in the motor configuration file.

This is problematic because all 3 parameters are application dependent.
I.e.: the same motor/driver combo can run with different currents (higher current = more torque but less smooth) and/or different voltages (higher voltage = higher top speed but less smooth).

Going through the motor configuration files one can notice the parameters were chosen to fit the application of the original author (which may not be a good choice in every case).

After analyzing the 3 parameters via an oscilloscope connected to the output of the drivers I can confirm:

  1. running current (0x8010,0x1) corresponds to the amplitude of the phase current (implemented via PWM)
  2. reduced current (0x8010,0x2) corresponds to the combined DC current of both phases (implemented via PWM)
  3. monitor voltage (0x8010,0x3) has no effect on the output of the driver to the motor. It only monitors the voltage supplied by the PSU to the driver.

Items 1. and 2. are potentially hazardous since misconfiguration may lead to motor damage.
E.g. 1: if values are changed upstream an integrator may inadvertently change the motor current by simply updating to a newer version.
E.g. 2: an integrator may (wrongly) assume the values present on ecmccfg are safe for their particular application.

The following approach was initially considered:

For all motor configuration files: 1) add macros which allow the integrator to change the parameters when invoking configureSlave.cmd (example below) and 2) set sane default values for all the motors.

${SCRIPTEXEC} ${ecmccfg_DIR}configureSlave.cmd "HW_DESC=EL7047, CONFIG=-Motor-Nanotec-ST4118L1804, CFG_MACROS='I_RUN_MA=1000, I_STDBY_MA=500, V_MON_MV=24000'"

However we could not reach an agreement on sane values due to the risk of damage to existing applications.
Therefore we decided to implement macros without default values and exit on error if they are not defined by the integrator.

This breaks backward compatibility and will require the integrator to modify the applications when calling configureSlave.cmd.

For this reason I will ask @anderssandstrom to bump the major version (ecmccfg 12?) in case this MR gets approved.

Item 3. does not run into the problems mentioned above since a misconfiguration only leads to a (false) warning by the driver and consequently default values are provided.


Summary of changes:

  • Fixes and cleanups:
    • Remove explicit 200 steps/rev configurations: this is already the default value for the 0x8010,0x6 SDO.
    • Fix chkValidVoltageSetOrDie.cmd functionality.
    • Fix header information on multiple files.
  • Move voltage monitor configuration away from motor files:
    • macro $V_NOM_MV is provided to configure the voltage monitor while in the driver configuration file.
    • This means the value is applied even when calling addSlave.cmd.
    • EL7031, EL7041 and EL7041-0052 will automatically convert from mV to cV.
    • Defaults to 24 V for EL703x and 48 V for EL704x (user is presented a warning).
  • Two macros $I_RUN_MA and $I_STDBY_MA are provided to configure the running current and reduced current respectively.
    • Each driver define its maximum allowed current (the final current will be the minimum between the driver and the motor).
  • The changes above results in very similar configuration files and allows for unification:
    • all EL7031 motor configuration files now link to EL7041.
    • all EL7041-0052 motor configuration files now link to EL7041.
    • all EL7037 motor configuration files now link to EL7047.
    • all EL7047 motor configuration files now load EL7041 and apply inductance (0x8010,0xA) values afterwards.

Please note I did NOT double check the values against the respective datasheet.
I.e.: if the values were wrong before this MR, they will be wrong after.


Not strictly related to the MR but noteworthy: the resistance (0x8010,0x4) and inductance (0x8010,0xA) values are ignored when using velocity direct (see "Required parameter settings for the individual operating modes" on EL70x7 manual).

From my observations this also applies to the EL70x1.

This is already the default value for 0x8010,0x6
@cdn-lnk cdn-lnk force-pushed the motor_cleanup branch 17 times, most recently from 8d98e96 to 5079e43 Compare September 16, 2025 09:44
Carlos Doro Neto added 6 commits September 16, 2025 11:54
0x8010,0x3 configs a monitor on the voltage supplied by the PSU to the motor
It has no effect on the motion AFAIK
Consequently it is not tied to the motor but to the PSU
I.e.: multiple voltages are possible for the same driver+motor combo (lower voltage = smoother motion, higher voltage = higher top speed)
0x8010,0x3 configs a monitor on the voltage supplied by the PSU to the motor
It has no effect on the motion AFAIK
Consequently it should be safe to define a default value
@cdn-lnk cdn-lnk force-pushed the motor_cleanup branch 6 times, most recently from 238c309 to a8125c7 Compare September 16, 2025 12:14
@cdn-lnk cdn-lnk force-pushed the motor_cleanup branch 3 times, most recently from 3e4b64a to e90e665 Compare September 17, 2025 09:39
In preparation for an upcoming unification
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x4,450,2)"

#- Motor full steps count 200
ecmcConfigOrDie "Cfg.EcAddSdo(${ECMC_EC_SLAVE_NUM},0x8010,0x6,200,2)"
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens in the case that the drive has first been used in another application where this value already has been changed? Isnt there a risk that the changed value will remain when you take the drive into the new application?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mac-kan, for almost all slaves ecmc resets the CoE/SDO registers to factory default at IOC start (addSlave.cmd), and I think 200 steps is default for this register, so it can be removed.
However, this may be a problem for other parameters in your TwinCAT applications, I guess there the CoE/SDO is not set to default, or?

Copy link
Contributor

Choose a reason for hiding this comment

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

@anderssandstrom Good point, indeed is should not pose a problem to remove it then!
Yeah, we recommend to save important parameters as startup entries to the terminal. At least that should help cover some of this ground.

@cdn-lnk cdn-lnk force-pushed the motor_cleanup branch 3 times, most recently from a2f09fe to 4e1cb9c Compare September 17, 2025 11:43
In preparation for an upcoming unification
In preparation for an upcoming unification
@javicereijo
Copy link
Contributor

I think this is a very good idea.
I haven't look at the code yet, but what would happen if for example we pass as a parameter a current that is larger than what the driver/motor can support?

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.

4 participants