Example #1
0
def doPath(X_offset=0, Y_offset=0):
    global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest
    for path in etch_moves:
        toolRefresh = 0
        toolPos_draw(toolPos_X, toolPos_Y, etching=0)
        cy.moveZ(Z_origin_offset + getZoffset(X_dest, Y_dest) +
                 Z_global_offset + Zlift_milling,
                 F_fastMove)  # Raise and move to next point
        X_dest = path[0][0] + X_offset
        Y_dest = path[0][1] + Y_offset
        F_dest = F_fastMove
        print("  Traveling to: " + str([X_dest, Y_dest]) + " at Z:" +
              str(Z_global_offset + Zlift_milling))
        cy.moveXY(X_dest, Y_dest, F_dest)
        toolPos_draw(X_dest, Y_dest, etching=0)
        Z_dest = path[0][2]
        if Z_dest > 0:
            F_dest = F_slowMove
        else:
            F_dest = path[0][
                3]  # We set the original speed if it is etching/drill
        cy.moveZ(
            Z_dest + Z_origin_offset + getZoffset(X_dest, Y_dest) +
            Z_global_offset, F_dest)
        #	print("Speed:",F_dest)
        print("  Etching at Z: " + str(Z_dest + Z_global_offset))
        toolPos_X = X_dest
        toolPos_Y = Y_dest
        toolPos_Z = Z_dest  # Not sure..
        toolPos_F = F_dest

        #	print(path)

        for coord in path[1:]:
            X_dest = coord[0] + X_offset
            Y_dest = coord[1] + Y_offset
            Z_dest = coord[2]
            F_dest = coord[3]

            distance = (X_dest - toolPos_X)**2 + (Y_dest - toolPos_Y)**2
            if distance >= maxDistance:
                splitLongEtchMove(distance)
            if distance < minDistance and (
                    Z_dest - toolPos_Z
            )**2 < 0.001**2:  # Make sure it is not a Z movement
                print("Ignoring " + str(distance**0.5) + "mm segment!")
                continue
            Z_real = Z_dest + Z_origin_offset + getZoffset(
                X_dest, Y_dest) + Z_global_offset
            cy.moveXYZ(X_dest, Y_dest, Z_real, F_dest)
            #		print("Coords: Speed: " + str(F_dest))
            toolPos_refresh(X_dest, Y_dest, etching=1)

            toolPos_X = X_dest
            toolPos_Y = Y_dest
            toolPos_Z = Z_dest
            toolPos_F = F_dest
def doPath(X_offset=0, Y_offset=0):
	global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest
	for path in etch_moves :
		toolRefresh = 0
		#toolPos_draw(toolPos_X, toolPos_Y, etching=0)
		cy.moveZ(Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset+Zlift_milling,F_fastMove) # Raise and move to next point
		X_dest = path[0][0]+X_offset
		Y_dest = path[0][1]+Y_offset
		F_dest = F_fastMove
		print("  Traveling to: " + str([X_dest, Y_dest]) + " at Z:" + str(Z_global_offset+Zlift_milling) )
		sys.stdout.flush()
		cy.moveXY(X_dest, Y_dest, F_dest)
		toolPos_draw(X_dest, Y_dest, etching=0)
		Z_dest = path[0][2]
		if Z_dest > 0:
			F_dest = F_slowMove
		else:
			F_dest = path[0][3] # We set the original speed if it is etching/drill
		cy.moveZ(Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset,F_dest)
	#	print("Speed:",F_dest)
		print("  Etching at Z: " + str(Z_dest+Z_global_offset) )
		sys.stdout.flush()
		toolPos_X = X_dest
		toolPos_Y = Y_dest
		toolPos_Z = Z_dest # Not sure..
		toolPos_F = F_dest
	
	#	print(path)
	
		for coord in path[1:] :
			X_dest = coord[0]+X_offset
			Y_dest = coord[1]+Y_offset
			Z_dest = coord[2]
			F_dest = coord[3]
		
			distance = (X_dest-toolPos_X)**2+(Y_dest-toolPos_Y)**2
			if distance >= maxDistance :
				splitLongEtchMove(distance)
			if distance < minDistance and (Z_dest-toolPos_Z)**2 < 0.001**2 : # Make sure it is not a Z movement
				print("Ignoring " + str(distance**0.5) + "mm segment!")				
				continue
			Z_real = Z_dest+Z_origin_offset+getZoffset(X_dest, Y_dest)+Z_global_offset
			cy.moveXYZ(X_dest, Y_dest, Z_real, F_dest)
	#		print("Coords: Speed: " + str(F_dest))
			toolPos_refresh(X_dest, Y_dest, etching=1)
		
			toolPos_X = X_dest
			toolPos_Y = Y_dest
			toolPos_Z = Z_dest
			toolPos_F = F_dest
			sys.stdout.flush()
Example #3
0
def splitLongEtchMove(distance):
    global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest

    X_dest_tmp = toolPos_X
    Y_dest_tmp = toolPos_Y
    Z_dest_tmp = toolPos_Z
    F_dest_tmp = toolPos_Z

    #distance = distance**0.5 # [mm]
    N_steps = int((distance / maxDistance)**0.5)  # **must be** >= 1

    print("Splitting " + str(distance**0.5) + "mm segment into " +
          str(N_steps) + " steps")

    #	print("Orig: " + (toolPos_X,toolPos_Y,toolPos_Z) + " Dest: " + (X_dest, Y_dest, Z_dest))

    X_step = (X_dest - toolPos_X) / float(N_steps)
    Y_step = (Y_dest - toolPos_Y) / float(N_steps)
    Z_step = (Z_dest - toolPos_Z) / float(N_steps)
    F_step = (F_dest - toolPos_F) / float(N_steps)

    for i in range(N_steps):
        X_dest_tmp = toolPos_X + X_step
        Y_dest_tmp = toolPos_Y + Y_step
        Z_dest_tmp = toolPos_Z + Z_step
        F_dest_tmp = toolPos_F + F_step

        Z_real = Z_dest_tmp + Z_origin_offset + getZoffset(
            X_dest_tmp, Y_dest_tmp) + Z_global_offset
        cy.moveXYZ(X_dest_tmp, Y_dest_tmp, Z_real, F_dest_tmp)
        toolPos_refresh(X_dest_tmp, Y_dest_tmp, etching=1)

        #		print("Move: " + (X_dest_tmp, Y_dest_tmp, Z_dest_tmp) )

        toolPos_X = X_dest_tmp
        toolPos_Y = Y_dest_tmp
        toolPos_Z = Z_dest_tmp
        toolPos_F = F_dest_tmp
def splitLongEtchMove(distance):
	global toolPos_X, toolPos_Y, toolPos_Z, toolPos_F, X_dest, Y_dest, Z_dest, F_dest
	
	X_dest_tmp = toolPos_X
	Y_dest_tmp = toolPos_Y
	Z_dest_tmp = toolPos_Z
	F_dest_tmp = toolPos_Z
	
	#distance = distance**0.5 # [mm]
	N_steps = int((distance/maxDistance)**0.5) # **must be** >= 1
	
	print("Splitting " + str(distance**0.5) + "mm segment into " + str(N_steps) + " steps")
	
#	print("Orig: " + (toolPos_X,toolPos_Y,toolPos_Z) + " Dest: " + (X_dest, Y_dest, Z_dest))
	
	X_step = (X_dest-toolPos_X)/float(N_steps)
	Y_step = (Y_dest-toolPos_Y)/float(N_steps)
	Z_step = (Z_dest-toolPos_Z)/float(N_steps)
	F_step = (F_dest-toolPos_F)/float(N_steps)
	
	for i in range(N_steps) :
		X_dest_tmp = toolPos_X + X_step
		Y_dest_tmp = toolPos_Y + Y_step
		Z_dest_tmp = toolPos_Z + Z_step
		F_dest_tmp = toolPos_F + F_step
		
		Z_real = Z_dest_tmp+Z_origin_offset+getZoffset(X_dest_tmp, Y_dest_tmp)+Z_global_offset
		cy.moveXYZ(X_dest_tmp, Y_dest_tmp, Z_real, F_dest_tmp)
		toolPos_refresh(X_dest_tmp, Y_dest_tmp, etching=1)
		
#		print("Move: " + (X_dest_tmp, Y_dest_tmp, Z_dest_tmp) )
		
		toolPos_X = X_dest_tmp
		toolPos_Y = Y_dest_tmp
		toolPos_Z = Z_dest_tmp
		toolPos_F = F_dest_tmp