So have tried to replace the resistor R1 from 10K to 240 (i find this value value in
the datasheet of the LM317), and it worked.
Now i can modulate the output from about 2.13 to 4.89, with 143 steps of a DAC (don't use PWM).
I am not skilled in Electronic: why replacing the Resistor did the job? And why the simulator was working with 10K?
The LM317 needs a certain minimum current to flow out of it for it to work properly (generally 5mA-10mA). With R1 as 10k (let's ignore R2 because it's much bigger) the current 125 microamps (0.125mA) so the LM317 doesn't work properly. This is because the voltage from the output to the ADJ pin is kept at 1.25V by the LM317.
With R1 as 240 ohms, the 1.25V voltage between the output and ADJ pin causes 1.25/240=5.2mA to flow which is usually enough to keep the LM317 happy.
--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
You have also learned that simulators are far from perfect. The one you used seems to have failed to consider the requirements of the non-linear device (the 317). This should not come as a great surprise since, for them to hold the data of all IC characteristics would entail one enormous database and hence cost the user an equally enormous licence fee.