Hi guys!

I need help to tune PID values for my configuration

I would like to use **Position Control** but, to do that, I need first to properly tweak the Velocity PID controller, since it is the inner loop of Position control mode:

My setup is based on Arduino Nano + TI Motor Driver DRV8305 + T-Motor 4004 + AS5047D Magnetic Encoder & SimpleFOC @2.1. Eventually, I will upgrade the MCU with a more poweful board:

I employed the heuristic *Ziegler–Nichols method* for **Velocity Controller** as follow:

- Set all PID values to zero (even the filter).
- Increasing P gain value until the output of the control loop has stable and consistent oscillations. In my case
**P**._{u}= 0.19 - Compute the period of these oscillations. As a result
**T**_{u}=3ms

Here the output from the serial and my calculation:

Now, using the Ziegler-Nichols table, I can get the proper values for P and I gains (at the moment, I don’t want to use D gain):

It turns out:

```
motor.PID_velocity.P = 0.08;
motor.PID_velocity.I = 34.2;
motor.PID_velocity.D = 0;
motor.LPF_velocity.Tf = 0.00;
```

However, using these two values and set the velocity to a certain value, i.e. 10 rad/s, the motor starts wobbling while spinning.

Here the video *in slow motion* with target velocity = 10 rad/s

Where do you think is the problem in my setup? How can I get sorted?

I also tried to tweak the **Tf** value, but it didn’t help me much.

Thanks in advance for your help!