Error using 2 motors: ERROR_MODULATION_IS_NAN

Hi,

I have two 9235 motors coupled by one gear to one shaft, and I use one encoder on the shaft. I have therefore coupled inputs A & B (I don’t use Z for now) to the same encoder.
I can get both motors running in a closed loop alone, but as soon as I add the second motor, the error MOTOR_ERROR_CONTROL_DEADLINE_MISSED appears in dump_errors(odrv0). By looking at odrv0.axis0.motor.error it shows 16 which would be 0x00010000 - ERROR_MODULATION_IS_NAN

I did a test with a different motor + encoder separated, so no coupling there, and it gave the same results when I tried running both motors at the same time. So I don’t think it has anything to do with the encoder inputs being coupled, but have no idea what it could be. The control loop does work fine for each of the motors when I run them alone.

Any idea how this problem may occur, or what I could change in the firmware to make this work?

FYI: I’m using a 24V Odrive V3.6, software version 5.2.

What control mode are you running? Are you using the INPUT_MODE_MIRROR on one of the motors?

So both motors effectively have a gearing between the motor and the encoder?
This is generally a Bad Idea.
The tiniest amount of backlash / elastic compliance in this gearing can cause a commutation/control stability issue.
Can you put an encoder on each motor?

I’m not sure about the modulation_is_nan error though - i’ve never seen that before. :frowning:

The control_deadline_missed is usually a side effect of another error i.e. the modulation_is_nan error

Hi Towen,

Thanks for the reply!
I may not have explained this well enough, but I did test a ‘normal’ setup as well: Two motors each with their own encoder, where there is no coupling between those motors. I receive the same error when I use both motors simultaneously, but NOT when I use either one of the motors alone. So as I said, I don’t think it has anything to do with the motors being coupled mechanically, or using the same encoder.

I’m using CONTROL_MODE_TORQUE_CONTROL and INPUT_MODE_PASSTHROUGH where I give torque commands via usb. I am therefore not using INPUT_MODE_MIRROR, and I do not wish to.

I’ll give some more background for why I am using two motors on one shaft though, since this may seem stupid! The end goal is to eliminate all backlash from this gear, by driving it with two motors. In theory, this is possible by letting motor1 do the positioning control in the CW direction, while letting motor2 push back in the CCW direction (for example with -10 percent of the torque that is used for the positioning). If the direction changes, the roles of the motor should change as well. I want to write a custom controller to achieve this. But for now, I was just hoping to put x torque on the motor1 and -x on motor 2 such that they grip the gear and eliminate backlash, while being able to move the shaft by hand.

Can anybody explain to me what ultimately could cause the modulation_is_nan error?

Ok, update from my side: The error seems to be solved, It was my own stupid mistake :expressionless: . I had modified the firmware just for the purpose of testing if I could modify it. I had changed the time to measure the inductance of the motors to ~5 seconds, such that you would hear a longer beep. However, I think this messed with the inductance measurement and ultimately caused the error. So I flashed the original firmware again, and now the error is gone.

I still would love to hear anyone’s opinion on what I am trying to achieve with eliminating the backlash.

1 Like

Good news, I just got working what I described about removing the backlash from a gear, using dual motors! :slight_smile: I have just tested it and it worked better than I had tought.
I’ll post the code below for anyone who might want to use it in the future:

// Backlash elimination
// This section is intended to serve as a way to enable position control on two motors that drive one shaft.
// the clamp_torque is a way to eliminate the backlash i.e. it lets the motors clamp the gear with a constant torque.
// the result of this is that sometimes motor 0 and sometimes motor 1 is the driving motor. But at all times the torque on 
// one motor is negative, and on motor 1 is positive. 

float clamp_torque = 0.3f;
if (axis_->config_.motor_side == 1){
    if(torque <= 0.0f){
        torque = clamp_torque;
    }
    else{
        torque += clamp_torque;
    }
}
else if (axis_->config_.motor_side == 0){
    if(torque <= 0.0f){
        torque -= clamp_torque;
    }
    else{
        torque = -clamp_torque;
    }
}
  • It is placed right before the line torque_output_ = torque; in controller.cpp
  • I added one attribute motor_side to the axis config in axis.hpp & in odrive-interface.yaml.
  • During calibration the backlash must be eliminated by hand (Or an elastic object that keeps the motors clamped to the gear), if you don’t do this, the motor angle does not correspond correctly to the encoder angle.

Regards, JP

2 Likes