# Need help! I can't tune correctly the q/d PID

Hi all,
The motor is running correctly in position and velocity mode, but I’m facing some problems to tune correctly the foc_current PID (q/d PID).
I’ve also some doubt about the unit of measure of some parameters:
Are the q and d currents measured in Ampere or milliampere? and the desired current (Id) is Ampere o milliampere? (I assume are all in Ampere)
What is the correct way to tune q/d PID? What I have to control during the tuning? I have to check the q/d current, the q/d voltages (PID outputs) or something else?
To (try) tune the PID I usually do this:
I set the Id to 4 (I assume is Ampere) and then I start to increase the P and when the P is stable and I don’t hear strange noises from the motor I start with the I. Is correct that the speed of the motor is increasing while I increase the Id current? (trivial question but I wanna be sure that is “normal”)

Some specification about the board and the motor I’m using:
I made custom board based on stm32G4 (150 MHz) and the DRV8302 driver, to measure the current of two phases I’m not using the DRV8302 amplifiers.
I prefer to use the STM32CubeIDE so I adapted the simplefoc library to be used with the stm32 IDE.
The motor is a eaglepower 8308 160Kv.

Thank you

Hi Andrea. I think with current mode operation you really want to trim your PID values. By ten fold maybe and start from decimals. I thin Proportional gain in foc_current of 4 might be too high ?

Hi, I tried to tune di q/d PID
P - 0.05
I - 0.0
D - 0.0

but also with a low value of P the PID appears to be unstable

As you can see the q and d current are diverging, the motor has no load.

If I increase the I term (0.01) the iq slowly keep increasing.

Until the id increase and iq to zero