I wish to use the PID Arduino library to create a PI controller with a sampling frequency of 100Khz. for a power factor correction boost converter.
Is this possible? Because i believe that maximum sampling time of arduino UNO is 10Khz? i heard somewhere it can reach to 100Khz.
in the code the sampling time is divided by 1000 so if sampling time is 1000, then it 1 sec.
So in this method, the sampling time would need to be set to .001 to get the 100Khz needed.
I feel having a decimal tho wouldn't work.
any help would be much appreciated.
void SetTunings(double Kp, double Ki, double Kd)
{
double SampleTimeInSec = ((double)SampleTime)/1000;
kp = Kp;
ki = Ki * SampleTimeInSec;
kd = Kd / SampleTimeInSec;
}
void SetSampleTime(int NewSampleTime)
{
if (NewSampleTime > 0)
{
double ratio = (double)NewSampleTime
/ (double)SampleTime;
ki *= ratio;
kd /= ratio;
SampleTime = (unsigned long)NewSampleTime;
}
}