Close

PID

A project log for Arduino AC motor PID

An arduino shield that lets you control an AC motor with closed loop feedback.

matt-vennmatt venn 08/03/2014 at 09:330 Comments

So finally, the PID part. I have used PID before, on a home made servo (just for fun), and a dump load for a wind turbine power controller. I've never really felt like I got to grips with it though, so that's one reason why I decided to do this project.

I used the PID library which has some decent info on it, and I also read up on PID over on this PID for dummies page.  It's really a very simple algorithm. We subtract the current RPM from the target RPM, and this is the error. The error is then multiplied by 3 different terms, P (proportional), I (integrated), D (derivative). The results are summed and this is used as the output to the motor speed control. 

Take a look at the PID::Compute function in the PID library. You can see the proportional part is just the P term multipled by the error. The I term is the accumulated error (integrated), and the D term is the difference between this input and the input last time. The results are summed together and returned (they are also sanity checked to avoid going too fast or slow).

I plugged in the variables, had a guess at the PID values and let it rip! The first few attempts were wild oscillations, but after a while I got some values that seemed to work OK. P = 0.01, I = 0.001 and D=0. 

The router spindle finds the target within a few seconds, and if I push against the spindle I can hear it trying to go faster. Then when I let go I hear a little spike in speed as the PID algorithm adjusts to the loss of the load.

I plan to do some more loop tuning later on, when I see how well it cuts.

Discussions