PWM to analog or digital

Hello,
I have pwm signal of max 5v and min of 0v. i want to use opto coupler to change it to analog or digital signal of 0-5v, is it possible?

Thank you,

Its already digital...

lets say the duty cycle of the pwm is 50%, so the output will be 2.5v or pwm signal?

maor444:
lets say the duty cycle of the pwm is 50%, so the output will be 2.5v or pwm signal?

Use an RC filter, (or better filter for smoother result), and it's 2.5V, or don't use one and it's still PWM.
(I'm not sure where the opto-coupler comes in.)

maor444:
lets say the duty cycle of the pwm is 50%, so the output will be 2.5v or pwm signal?

both. The RMS voltage is 2.5.

what are you controlling with the pwm?
you can use pwm as is to control dc motor or LED.

In general, any pwm controlled device that accepts analog voltage can be fed digital pwm directly.
pwm controlled device that only accepts digital pwm cannot accept analog voltage (Meanwell LDD led drivers for instance).