Sorry but PWM won't work to emulate an encoder. PWM has a fixed frequency and the on/off time ratio (DUTY CYCLE) determines the output average DC value. An encoder is a device that, when the encoder is rotating at a constant speed will have 2, 90 degree out of phase, signals of 50% duty cycle.
What you want to do is use 2 digital outputs, and 4 delays of equal value -
output 1 High,
delay
output 2 High
delay
output 1 Low
delay
Output 2 low.
delay
repeat.
the delay is what determines the speed. Shorter the delays - the faster the speed, longer the delays - the slower the speed. the frequency changes with speed, not the duty cycle like PWM.