It is really not a job of the tech support to tell you what should be the values the P I and D value as these are dependent on individual system.
What is the open loop transfer function of your system? i.e. what is the speed with respect to the PWM duty cycle? Can you draw a graph of speed vs duty cycle.
Your last post mentioned that at 3% duty cycle would return 47000 and 25% duty cycle would return 300. That doesn?t quite make sense since a small duty cycle means less power and yet the motor runs faster?
Lets assume an example that your motor runs in the speed range from 0 to 1000 rpm between 3% and 25% duty cycle (i.e. 300 to 2500 in SETPWM), That means:
(change in duty cycle) (2500-300) 2200
---------------------------- = -------- = ------ (%*100/rpm)
(change in speed) 1000 1000
This means that in order to run the motor at X rpm in open loop, you need to set the duty cycle = (X*22)/10 + 300.
In a control system that only has the P term, there will always be a steady state error between the SETPOINT and the FEEDBACK value in order for the control system to work. Assuming that you can tolerate a 50rpm steady state error in order to generate a proportional output of 500rpm, that means your P term should be 10 times that of the transfer function.
So P = 10*22/10 = 22 may be a good starting point.
You can try with a small value of I = 1. With the introduction of the integral the control system will eliminate the steady state error so that ACTUAL SPEED = SETPOINT at steady state. ?I? term will control how fast or how slow the control system reach steady speed and you can experiment with it.
So the algorithm could be as follow:
E.g. P = 22: I = 1 (PIDDEF in a separate custom function)
E = SETPOINT ? FEEDBACK VALUE in RPM
C = PIDCompute(E) + 300
SETPWM 1, C, 16 ? assuming 16Hz works for you.
The custom function that runs the PIDcompute and SETPWM should be called periodically (e.g. using a clock pulse with period 0.1, 0.2 or 0.5 second) so that the control system can work.
Note that if the P term is too small you may want to use a fixed point representation. E.g. each unit of P can be = 0.1. So for P = 22 it can be represented as 220 and I = 1 can be represented as 10. The PIDcompute will output a control action that is scaled up by 10 times and you just need to divide the computed value by 10 before applying to PWM. (The integral limit should also be 10 x higher than the actual preferred limit.)
E.g. P = 220, I = 10 (PIDDEF in a separate function)
E = SETPOINT ? FEEDBACK VALUE
C = PIDCompute(E)/10 + 300
SETPWM 1, C, 16 ? assuming 16Hz works for you.
Note that PIDDEF should be placed in a different custom function (could be in an INIT function) and run only ONCE before the control action starts. Otherwise each time it is executed the integral and differential results are lost.