CS-Lab Support Forum for CNC Community

Help to run this brand-new forum and stay with us.
Ask your questions, we are here to help! 

 

Forum Navigation
You need to log in to create posts and topics.

Encoder module, get Position in Phyton script

Hi, I am switching from mach4 to simcnc. For a tool changer macro I need to get the exakt spindle position. I have an IP-A with enc. module. How can I get the encoder position in the m6 phyton script?

Thanks

Johannes

# Axis index mapping for d.getPosition(CoordMode.Machine)
X = 0
Y = 1
Z = 2
A = 3
B = 4
C = 5

# Read current machine position of all axes
position = d.getPosition(CoordMode.Machine)

spindle_X = position[X]
spindle_Y = position[Y]
spindle_Z = position[Z]

print("Spindle position (machine coords): X={:.3f} Y={:.3f} Z={:.3f}".format(
spindle_X, spindle_Y, spindle_Z
))

chould print the position of your spindel in the chat

here my code for tool change
https://github.com/erwan56450/SimCnC/tree/main/ATC_X_Rack

 

 

carbonkid has reacted to this post.
carbonkid

Hi Erwan, thanks for for the link to your scripts.

Johannes

enc_module = d.getModule( ModuleType.ENC, 0 )
ch0_position = enc_module.getEncoderIOPosition( 0 )

PARTNERS:

 

USA

Germany

Slovenia / Bosnia

Spain

South Africa

UNI-CAM

The Netherlands

Portugal

Greece

  Distrib milionis logo

Hungary

Distrib logot

Bulgaria

Master

Kenya

Proteq Automation

Egypt

Germanelectronix

China

Jun Ma

Serbia

ALCO

Italy

LVL tech r

Denmark

Varntoft Dania

Finland