convertion 0.5v-2v to 0v-5v

hi all how can i convert analog in (voltage) 0.5v-2v to output 0v-5v
i know that the out will be pwm and i need RC filter
in the hardwer side its easy but i need some helf with the software

thank , netanel

netanbi:
i know that the out will be pwm and i need RC filter
in the hardwer side its easy but i need some helf with the software

Or just use an op-amp?

A simple digital way is to analogRead that voltage, and use map() to convert 102-410 (0.5 to 2volt) to 0-255.

analogWrite(pwmPin) = map(analogRead(voltagePin), 102, 410, 0, 255);

Then use an RC filter to smoothen PWM to a voltage.
But that might not be as fast and clean as an opamp.
Need more details.
Leo..

The following Analog Computer may solve your voltage transformation problem which is of the form:

vo = (10/3)*vi - 5/3

Adjustment procedures:
?