Absolute movement controlled by an external encoder.

2026-03-04
20 hours ago
  • poliautomacao - 2026-03-04

    Hello, is it possible to perform an MC_MoveAbsolute movement, and have the servo move using an external encoder (freeEncoder)? In my application, I have slippage on the main shaft of the servo motor, and I would like to add an encoder to measure the actual position of the material.

     
  • gseidel - 2026-03-04

    Hi polyautomacao,

    basically, there are two ways to approach this.

    1. My first choice would be to check whether your servo drives supports an external encoder, connect the encoder to the servo and configure the servo accordingly. In this case, you would not need to change anything in the CODESYS application.
    2. If that is not an option, you could use SM_DrivePosControl, a drive that closes the position loop in the PLC, and feed it with the external encoder positions. See (0). You can switch your servo drive to velocity control mode (SMC_SetControllerMode) and use SMC_FollowVelocity to apply the fSetVelocity of the SM_DrivePosControl to your servo. The MC_MoveAbsolute can then be performed on the SC_DrivePosControl

    Hope that helps.

    (0) https://content.helpme-codesys.com/en/CODESYS%20SoftMotion/_sm_example_poscontrol.html

    Best regards,

    Georg

     
    • poliautomacao - 20 hours ago

      Hello, I made this configuration, I'm moving the encoder value to SM_Driver_PosControl.in.wActPosition. When I make the absolute movement of my PosControl axis, my physical drive axis rotates perfectly, but I noticed that the movement is not followed by the encoder. That is, if I hold the encoder and keep it in position 0, the PosControl axis makes the absolute movement of 314 mm and stops, which is strange because the encoder is at 0. Theoretically, the PosControl axis should accelerate to try to compensate for the movement error. I haven't yet achieved perfect functionality.

       

Log in to post a comment.