Motor noise and vibrations with PIDs at 0 gain

I have been having trouble with motor noise/vibration, It’s like a grinding rumbling type noise. It seems this is not electrical noise as MOSFET outputs on the scope are clean and sitting perfectly on 24khz. The only time the motor is smooth is during the calibration process. The odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION is very smooth and not a single noise. The odrv0.axis0.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH does the same grinding rumbling type noise.

Once in closed-loop vel control and 0 gains on PIDs, it’s jumping around 30 counts on my encoder. The encoder is 1800ppr. If I slowly put in any gains it just gets worse, where the motor will vibrate and I drop the gains in half until stable again. When I run the motor it’s noisy and not smooth. No matter what PID settings I try I can’t get it stable to the point the encoder is not moving and sitting on 0 counts.

This is causing issue’s as I’m trying to interface with closed-loop CNC controller and I can’t dial in the PIDs on the CNC controller because the Odrive Velocity can not sit perfectly on 0. If I use my CNC controller motor driver board which is also FOC control, it is dead silent and will sit on exactly 0 counts when I have the PIDs tuned close. Here is a link to the motor driver

https://www.dynomotion.com/SnapAmp.html

I have noticed the SnapAmp is 32khz rather than 24khz like the Odrive, whether this makes a massive difference. I did try changing #define TIM_1_8_RCR 2 to 4 for 40khz PWM but this did not work and still on 24khz. I have noticed if I tune the Odrive PIDs tight and responsive for velocity, I can’t get the PIDs anywhere close on my CNC controller, but if I leave the Odrive PIDs sloppy, I can then begin tuning the CNC controller and get it holding around 10-20 counts. The SnapAmp will hold spot on 0.

I have even used Chinese cheap BLDC controllers with better results than the Odrive. I am using devel branch with 0-100% PWM to interface with the Kflop CNC controller. Is there any way to run the FOC in an open-loop and use the encoder for motor timing and then I only have the CNC controller PIDs to tune rather than trying to mix the 2 control loops which are not working out at all.

UPDATE:

Changing odrv0.axis0.motor.config.current_control_bandwidth to 50 has solved the noise and vibration issues. I’m still having trouble getting the 2x PID loops to work. If I now tune in the Odrive spot on where it’s maybe moving 1 count the odd time with the CNC PIDs set to 0. If I bring up p gain really weak 0.001 on the CNC controller it still stays ok, but if I put in I gain around 0.00001 it starts jumping around 20 counts. In order to get motor to move, I need some I gain or nothing happens. I was hoping just P gain on top of the Odrive would be enough.

Wow, what motor do you have? What’s the motor.config.phase_inductance?

P gain on the CNC should be enough. Also you’re in CTRL_MODE_VELOCITY_CONTROL on the odrive, right?

Also, what frequency PWM are you using? There is no 0-100% PWM functionality on the ODrive at this time, so I’m not entirely sure how you’re actually controlling this lol

@Wetmelon I’m using a cheap nema17 BLDC motor.

motor.config.phase_inductance = 4

Yes, I’m using velocity. I’m using the devel branch merged with duty cycle PWM.

And this is my branch working on my custom single-axis hardware

I think the biggest problem I’m finding is the Odrive is set up for larger motors and there’s quite a few settings that need to be changed to use small motors that are not documented anywhere very well. The 0-100% PWM seems to be working quite well with direction pin and have tried up to 2.5khz with no issues. What exactly is the current control bandwidth? I could not find much info on it, but it made massive difference and motor is now super smooth with well tuned PIDs