Not the voltage regulator. That will try to give a constant voltage at the output, but PWM at the input won't allow this. Anyway, the regulator won't work, but your PWM signal will be lost.
A potentiometer will work, and allow you to vary the output level, but if you know what level you want (5V) then a resistor divider is cheaper. 3k9 for the higher resistor, and 1k for the lower one will give you 4.9V. Both values are E12, so they are more common that the values Nick suggests.
edit
Nick suggests higher resistance values, like 39k and 10k. Lower values mean less susceptibility to noise and other disturbances, and if you're working with stepper motors you can afford the extra few millis; the stepper motor will consume a lot more.
Low pass filtered PWM can do what you want, but you need the PWM frequency to be much higher than 500 Hz.
Yes, you can get hard-wired logic to do some of this task. Use the PWM hardware built into most microcontrollers. If yours doesn't have any PWM outputs, go use one of the many many micros that do.
PWM hardware in the micro will take care of producing the individual pulses for you. All you have to do is set the duty cycle, and the hardware takes it from there. Let's say the micro can clock the PWM hardware at 10 MHz (very easy to get), and that you want 8 bit resolution. That means each PWM pulse will take 255 clock cycles, which is 25.5 µs, which comes out to a frequency of 39 kHz. That is much easier to low pass filter to remove the 39 kHz pulse frequency but still leave a reasonable number of harmonics of the signal you want.
You can now update the duty cycle in the hardware register independently of the individual PWM pulses. With the right kind of PWM hardware, a new duty cycle will take effect at the start of the next period. However, if your periods are 255 instruction cycles long, then you can easily interrupt once for each one, adjusting the duty cycle each pulse.
To compute the desired duty cycle, use a byte or two or three of fraction bits below the integer duty cycle byte. For example, you can use a 32 bit counter which you think of as the high byte of the actual duty cycle you write to the hardware, and the low 24 bits as the fractional part for intermediate calculations. For whatever ramp speed you want, calculate the amount to add to this 32 bit value up front. Higher increment values will result in faster ramps. Each interrupt, add the increment into the 32 bit counter, then take its high byte and write it to the hardware PWM duty cycle register. Even a 8 bit micro can easily accomplish this in well under 255 instruction cycles.
Best Answer
Yes. The difference is that the PWM pulse will be centered within the train rather than against either edge (type 1).