Generally, it is controlled by a limit switch, and if it is controlled by a program, there will generally be an error (even if there is no error, there must be a starting position).
It is recommended to use an adjustable limit switch to facilitate position adjustment, and you can also do multi-stage limit to adapt to different working needs.