unexpected drive position (fActPosition) after SMC3_ReinitDrive

alejho
2020-01-16
2020-01-17
  • alejho

    alejho - 2020-01-16

    I have a slave drive attached to a master with MC_Phasing.
    When I call SMC3_ReinitDrive is fActPosition is set to the variation of the Master position while the drive is re-initializing.

    This is quite strange because it happens also if the drive's position coming from the fieldbus is constant (the axis is not moving).
    I expect fActPosition not changing before and after SMC3_ReinitDrive...since the axis is not moving!

    In attachment a picture of a trace what is happening...
    Does anyone know what can cause such a strange behaviour?

    Thank you for any kind of help!

    IMG: codesys_forum.png

     
  • alejho

    alejho - 2020-01-17

    We found something that I hope will be useful for someone else.

    The "wrong" fActPosition isn't calculated according to the encoder master's position, but it always has a variation of 216°.

    This value is not causal, but it's due to the fact that the increments per output turn of the axis (in our application 65536*10 is equal to 360°) is NOT a power of two.

    For our application 216°=393216 increments that is exactly the number of increments "missing" from 655360 to reach the first power of two (2^20).
    (It isn't easy to imagine...but try to draw a trivial example for a 4bit encoder where you get 360° every 3 increments and it will be clear)

    This is not a problem when the machine is running (it just count the increments managing the overflow I suppose)...but when you reinit the drive after a drive encoder's overflow (32bit) you get an error in fActPosition of 216° equal to 393216 increments (216°)

    Now the question is...what's the best pratice to manage this problem?

    I was thinking about counting the number of overflow and triggering an MC_Home after a reinit (to set fActPosition := fActPosition * 216 * numberOfOverflows)

     

Log in to post a comment.