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.

Start program, and Pause program from inputs

Hello.
I have a question, how is it possible to turn on the program with the input from CSMIO/IP-A and with the second input I change the work offset and turn on the program with the third input I turn on the program pause?
Is this possible to do?

Here is a starting approach, but I don't know how to code the offset.

I also don't know how to make this code run in a loop on SimCNC.

I have always executed Python code based on a G-code command.

For example, if M6 is called in the G-code, then the Python script M6.py is executed.

# Define physical inputs on the CSMIO/IP-S
input_start = 10 # Input number for start
input_pause = 11 # Input number for pause
input_offset = 12 # Input number for X+20 offset

# Function to read inputs and take action accordingly
def check_buttons():
mod_IP = d.getModule(ModuleType.IP, 0) # Connect to CSMIO/IP-S

if mod_IP.getDigitalIO(IOPortDir.InputPort, input_start) == DIOPinVal.PinSet:
print("Button 1 pressed: Machine started")
d.enableMachine(True) # Enable the machine

if mod_IP.getDigitalIO(IOPortDir.InputPort, input_pause) == DIOPinVal.PinSet:
print("Button 2 pressed: Machine paused")
d.enableMachine(False) # Disable the machine

if mod_IP.getDigitalIO(IOPortDir.InputPort, input_offset) == DIOPinVal.PinSet:
print("Button 3 pressed: Offset X+20")
d.execCode("G92 X+20") # Send G92 X+20 to the controller

# Main loop (if needed, adjust based on your setup)
while True:
check_buttons()
time.sleep(0.1) # Small delay to prevent spamming

Quote from Gregor_IKA on 19 February 2025, 17:02

Hello.
I have a question, how is it possible to turn on the program with the input from CSMIO/IP-A and with the second input I change the work offset and turn on the program with the third input I turn on the program pause?
Is this possible to do?

Take a look at the attachment.

https://en.cs-lab.eu/wp-content/uploads/2024/11/buttons.zip

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