You need to sample the voltage and current being fed to a winding. The power factor is the COS of the angle between them. If you are adjusting the capacitor you don't have to actually measure the angle, just minimise it. You can either use a pair of A to Ds and do your maths in the micro, or you can use a pair of opamps as zero point detectors, so you have two square waves. Put the square waves into an exclusive OR gate (you get an output if the inputs are different). If they are in phase then the output will be 0V, if the inputs are 180 degrees out of phase you get the the Vcc output, Its linear for all intermediate phases. So just measure the MEAN output, express as Vo/Vcc X 180 degs.
Frank