Showing results for 
Search instead for 
Did you mean: 

CODESYS SoftMotion: Command position rollover for modulo axes

CODESYS SoftMotion: Command position rollover for modulo axes

Occasional Contributor

With a SoftMotion axis configured as "modulo",  it had been observed in a variety of cases that the position command value is failing to rollover at the defined modulo.  


For example, with MC_CamIn (see attached for cam definition):


The consequence of this is that for sufficiently large commanded position, the axis stops:


MC_GearInPos and MC_MoveRelative behave similarly.  

Am I missing something in the setup?

Test axis: IndraDrive, MPB-20 firmware.  CODESYS SoftMotion  ctrlX CODESYS Softmotion Adapter



Established Member

for me it looks like modulo is configured in the drive too, but the SoftMotion driver expects that the drive does not do modulo handling. This will be done by the SoftMotion.

So I would recommend to check/change the position data format from “Modulo” to “Absolute” in the drive.

Occasional Contributor

Thanks, eschwellinger. 

It appears that it is not enough to simply switch the position data format to Absolute.  The issue is that in this case the drive's actual position is rolling over at the Maximum travel range value (S-0-0278):


and I still see the physical axis come to rest once the commanded position becomes sufficiently large:


I did verify that by setting S-0-0278 to its maximum value, namely 214748.3647 = (2^31 - 1) / 10000, I could force the commanded and actual positions to rollover simultaneously:


In this case it looked like I was able to run in "endless" mode without error. 

Setting the max. travel range this high has implications on our absolute encoder evaluation - we'll review internally how best to handle this.

If you edit your post to include a reference to my comments here, I'll accept yours as the answer.  


Occasional Contributor

As an alternative to the workaround described above, I've found that SoftMotion parameter dwBusModuloMask may be used to force rollover of the position command at a value compatible with the internal drive modulo.  This approach will (in typical cases) allow us to retain the drive's absolute position reference  while maximizing the internal position resolution.  For example, setting dwBusModuloMask = 2^18 - 1 = 262143, we may configure the axis as follows:


Running the cam described in the original post now yields the following.  Note that the position command value rollover now corresponds with the actual drive position. 


I've tested this configuration for 4+ hours and see no problems and no position drift.  Moreover, the position is retained on program restart or power cycle.  Both forward and backward operation has been verified.

@eschwellinger:  Am I missing anything?  Was there a specific reason you did not suggest adjusting dwBusModuloMask?

Also, following the documentation I've assigned dwBusBandWidth a value of 262144 = 2^18.  What does this parameter do?   


First of all, my preference would be to set the max. travel range to 2^31-1. This is how SoftMotion expect drives to behave.

dwBusModuloMask is an internal variable, so I would not recommend to set it.

The thing with the max. travel-range and the absolute mode of the drive would be an important info for the commissioning guide.

Instead of using the internal variable dwBusModuloMask  I would recommend to use:


But as I said... usually this should not be needed.