From what you say in post #8 you seem to think the vref on the PIC16F628 is generated frim an internal precision voltage reference module s it is in some other PICs. It is just derived from the 5 volt power supply via a ladder network as shown on page 59 of the data sheet. (It is a bit like a DAC without the output buffering.) The PIC16F628 does not have an ADC so you can't use it to feed the voltage from the slider on the potentiometer into the PIC to control the PWM duty cycle. To do what you seem to want to do you will need a different PIC. I have done something similar to what I think you may be trying to do using a PIC16F876. This was for a closed loop motor speed controller driving the X axis of a milling machine. You would get better help if you provided more details of your project.