There are many ways to achieve this.
More information on exactly what the application is would effect my advice.
If you have a moveAbsolute or moveVelocity, you can change the position or velocity, then drop the enable and re-enable. This will trigger a new move based on the BufferMode.
See https://infosys.beckhoff.com/content/1033/tcplclib_tc2_mc2/70147595.html?id=4401319670753010232 for more information
Alternatively you can set up a virtual axis, and then gear in dynamic to this axis, you can then alter the gear ratio positive or negative on the fly to make this update the velocity in a superfluid manner.
See https://infosys.beckhoff.com/english.php?content=../content/1033/tcplclib_tc2_mc2/70124939.html&id= for more information
Then there is camming, external setpoint, secondary encoders... so much more.
Feel free to explain your project more and I'll see if I can assist.
Based on
"moving an axis based on the height variations of a surface"
If you're trying to dynamically follow an object, I would use gear in dynamic.
Then I would:
gear in at 0 gearing
start Virtual axis using mc_movevelocity
take the sensor value and subtract from it your setpoint
use this error to feed the gear ratio in MC_GearInDyn
obviously you will need a gain, both I and P, I doubt you would need D. I and P are very easy to implement with the aid of a timer.
Regards
Hamish Lucas
Lucas Electronic Solutions P/L