fbpx

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! 

 

Please or Register to create posts and topics.

Error message

What does the error message mean? It says that the error in line 75 is something wrong?

G91
Probing Z: Schnelltasten-Code = G31.1 Z-20.0 F300.0
Traceback (most recent call last):
File "C:\Program Files\simCNC\profiles\CNC\scripts\___INIT.py", line 34, in <module>
exec(open(fileName, encoding='utf-8').read())
File "<string>", line 115, in <module>
File "<string>", line 75, in Probing_Z
File "C:\Program Files\simCNC\profiles\CNC\scripts\___DEVICE.py", line 175, in getDigitalIO
return DIOPinVal[self.comm.sendAndWait( "getDigitalIO:" + direction.name + ':' + str(digitalPin) + ':' + self.type + ';' + self.id )]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\simCNC\profiles\CNC\scripts\___COMM.py", line 189, in sendAndWait
raise SimCncException(":".join(res[1:]))
___EXCEPTION.SimCncException: ' Wrong argument 2 type, expected int'
Script C:\Program Files\simCNC\screens\carbonkid_vertical_de_v016_Test_experimentell\scripts\m501_2.py execution error (Unknown error: 1).

This is the function from the script and I marked line 75 in red:

def Probing_Z():
# Z-probing fast
GCode="G31.1 Z-" + str(searchDistance) +" F" + str(touch_fast)
print("Probing Z: Schnelltasten-GCode = ", GCode)
move = d.executeGCode(GCode)

# Probing ok?
mod_IP = d.getModule(ModuleType.IP, 0)
if mod_IP.getDigitalIO( IOPortDir.InputPort, touchProbe) == DIOPinVal.PinSet:
sys.exit("Probing Z: Tasten: Fehler Z-Achse!!")
else:
print("Probing Z: Tasten ok")

# Saving the fast measurement
fast_measurement = d.getPosition(CoordMode.Machine)[2]

# Move Z on top
GCode="G01 Z" + str(goUpDistance) +" F" + str(vel_Zreturn)
time.sleep(0.5)
print("Probing Z: Fahre Z nach oben ", GCode)
move = d.executeGCode(GCode)

# Z-probing slow
GCode="G31.1 Z-" + str (searchDistance) +" F" + str(touch_slow)
print("Probing Z: Langsamtasten-GCode = ", GCode)
move = d.executeGCode(GCode)

# Probing ok?
mod_IP = d.getModule(ModuleType.IP, 0)
if mod_IP.getDigitalIO( IOPortDir.InputPort, touchProbe) == DIOPinVal.PinSet:
sys.exit("Probing Z: Tasten: Fehler Z-Achse!!")
else:
print("Probing Z: Tasten ok")

# Saving the slow measurement
slow_measurement = d.getPosition(CoordMode.Machine)[2]

# Comparison of measurements
difference = abs(fast_measurement - slow_measurement)
if difference > max_difference:
sys.exit(f"Probing Z: Fehler - Unterschied zwischen schneller und langsamer Messung ({difference:.3f} mm) überschreitet den Grenzwert ({max_difference:.3f} mm)")

d.setAxisProgPosition(Axis.Z, 0)
pos=d.getPosition(CoordMode.Program)
posz = pos[2]
print("Probing Z: Position Z = ", posz)

# Move Z on top
GCode="G01 Z" +str(zSafeHeight) +" F" +str(vel_Zreturn)
print("Probing Z: Fahre Z nach oben ", GCode)
move = d.executeGCode(GCode)

print("Z Nullpunkt erfolgreich gesetzt.")

 

Python told you exactly what it doesn't like :

___EXCEPTION.SimCncException: ' Wrong argument 2 type, expected int'

Probably the variable "touchProbe" is not an int (not an integer)

carbonkid has reacted to this post.
carbonkid

Oh yes, great, thank you. I already understood it but still didn't see the error. The line for touchProbe looked like this: touchProbe = (d.getMachineParam(321)). I forgot to write the "int" in front of it. touchProbe = int(d.getMachineParam(321)) the correct version 😉

Another question in this context. Would it somehow be possible to fully test the scripts without a machine in simCNC's simulation mode. This means that random values ​​are generated for the measurements. I hope you understand what I mean. It is quite annoying to always have to drive to the workshop to test whether the script is working properly. I can also work much faster on the PC at home with two screens.

The simulator does not provide this option. Use the random number generator as the measurement result.

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

×

Hello!

Click one of our contacts below to chat on WhatsApp

× How can I help you?