Here’s the example of a spindle positioning macro. The macro is activated with “Q” parameter. For example, M20 Q100 sets a spindle to 100 degrees.
M20 Macro for spindle positioning
Requirements:
- CSMIO/IP-S or CSMIO/IP-A controller
- CSMIO-ENC module
- a servo driver for spindle driving (step/dir for CSMIO/IP-S or +/-10V for CSMIO/IP-A )
- an encoder installed on a spindle or with ratio 1:1
- Construction:
- M20 macro for spindle positioning can only be used if the spindle is driven by a servo drive that works in position mode (never in opened position loop).
- If there’s gear between a servo motor and a spindle, then it has to be non-slip gear, e.g. toothed belt used.
- The encoder for revs and spindle angle reading must be installed directly on a spindle or through the non-slip gear (e.g. the tootled belt) , with ratio 1:1.
- The encoder for revs and spindle angle reading can only be connected to CSMIO-ENC module.
The encode signals can’t be used for any other purposes as it will be overloaded this way (it’s a common issue).
- Settings:
- Using M20 macro for spindle positioning, you can’t use „Align at stop” function at the same time (plugin „Spindle” tab) and reversely.
- If there is gear between a servo motor and a spindle, then the gear ration should be set in Mach3 in the „Spindle Pulleys” tab (1:1 by default).
- Set the „Spindle Pulses / Revolution” value in the plugin „Spindle” tab:
The „Spindle Pulses / Revolution” value is encoder pulses number incl. all four edges and the electronic gear in a servo drive (if used).
3. The M20 macro verifies the set and real position after spindle positioning.
If the difference between those two values is higher than „Const Offset = 1” parameter value, the „M20 ERROR Offset !!!„ error will appear.
The „Const Offset” value can be reasonably adjusted to our needs (the value of 1 is usually optimal).