Пример #1
0
def CloseProcess():
    di1 = request.form['di1']
    di2 = request.form['di2']
    mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)
    time.sleep(0.5)
        # Toggles the output pins on all connected IO Modules
    detectedIOModules = mm.detectIOModules()
    for IO_Name, IO_NetworkID in detectedIOModules.items():
        #writePins ={"Pin 1":0, "Pin 2":1}

        mm.digitalWrite(IO_NetworkID, 0, 0)
        time.sleep(1)
        mm.digitalWrite(IO_NetworkID, 1, 1)
        time.sleep(1)
Пример #2
0
def DropProcess():
    try:
        #di1 = request.form['di1']
        #di2 = request.form['di2']
        mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)
        time.sleep(0.5)
        # Toggles the output pins on all connected IO Modules
        detectedIOModules = mm.detectIOModules()
        for IO_Name, IO_NetworkID in detectedIOModules.items():
        #writePins ={"Pin 1":0, "Pin 2":1}
        
            mm.digitalWrite(IO_NetworkID, 1, 0)
            time.sleep(1)
            mm.digitalWrite(IO_NetworkID, 0, 1)
            time.sleep(1)
        #return jsonify({'error': 'Drop complete'})
    except Exception as e:
        return render_template('505.html')
Пример #3
0
import sys
sys.path.append("..")
from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

acceleration = 500  # The acceleration [mm/s^2] that all subsequent moves will move at
mm.emitAcceleration(acceleration)
print("Global acceleration set to " + str(acceleration))
Пример #4
0
from MachineMotion import *

#Declare parameters for combined absolute move
speed = 500
acceleration = 500
axesToMove = [1, 2, 3]
positions = [50, 100, 50]
mechGain = MECH_GAIN.timing_belt_150mm_turn


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

mm.emitSpeed(speed)
mm.emitAcceleration(acceleration)
for axis in axesToMove:
    mm.configAxis(axis, MICRO_STEPS.ustep_8, mechGain)
print("All Axes Moving Home Sequentially")
mm.emitHomeAll()
mm.waitForMotionCompletion()
print("All Axes homed.")
Пример #5
0
import sys

sys.path.append("..")
from MachineMotion import *

#### Machine Motion initialization ####

# Initialize the machine motion object
mm = MachineMotion(DEFAULT_IP)
print('mm initialized')

# Remove the software stop
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

# Configure the axis number 1, 8 uSteps and 10 mm / turn for a ball screw linear drive
axis = AXIS_NUMBER.DRIVE2
uStep = MICRO_STEPS.ustep_8
mechGain = MECH_GAIN.ballscrew_10mm_turn
mm.configAxis(axis, uStep, mechGain)
print("Axis " + str(axis) + " configured with " + str(uStep) +
      " microstepping and " + str(mechGain) + "mm/turn mechanical gain")

# Configure the axis direction
ax_direction = DIRECTION.POSITIVE
mm.configAxisDirection(axis, ax_direction)
print("Axis direction set to " + str(ax_direction))

# Relative Move Parameters
Пример #6
0
import sys
sys.path.append("..")
from MachineMotion import *

import time


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

#Define Relative Move Parameters
axis = 1
speed = 400
acceleration = 500
distance = 1000
direction = "positive"
mechGain = MECH_GAIN.rack_pinion_mm_turn

#Load Relative Move Parameters
mm.emitSpeed(speed)
Пример #7
0
import sys

sys.path.append("..")
from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

# Define the brake parameters
brake_aux_port_number = 1  # The AUX port number the brake is plugged in
safety_adapter_presence = False  # Is a yellow safety adapter plugged in between the brake cable and the AUX port

# Define Axis Parameters
axis = 1  # Drive number
mechGain = MECH_GAIN.rack_pinion_mm_turn

# Configure the axis
mm.configAxis(axis, MICRO_STEPS.ustep_8, mechGain)
Пример #8
0
import sys
import time

sys.path.append("..")
from MachineMotion import *

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

time.sleep(0.5)

# Toggles the output pins on all connected IO Modules
detectedIOModules = mm.detectIOModules()
for IO_Name, IO_NetworkID in detectedIOModules.items():
    writePins = {"Pin 1": 0, "Pin 2": 1, "Pin 3": 2, "Pin 4": 3}
    for writePin in writePins.keys():
        print(writePin + " on " + IO_Name + " is going to flash twice")

        mm.digitalWrite(IO_NetworkID, writePins[writePin], 1)
        time.sleep(1)
        mm.digitalWrite(IO_NetworkID, writePins[writePin], 0)
        time.sleep(1)
        mm.digitalWrite(IO_NetworkID, writePins[writePin], 1)
        time.sleep(1)
        mm.digitalWrite(IO_NetworkID, writePins[writePin], 0)
Пример #9
0
def btnUpProcess():
    btn_up = request.form['btn_up']

    mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

    print("--> Removing software stops")
    mm.releaseEstop()
    print("--> Resetting systems")
    mm.resetSystem()


    axis = 1                                       #The axis that you'd like to move
    speed = 700                                    #The max speed you'd like to move at
    acceleration = 500                             #The constant acceleration and decceleration value for the move
    position = btn_up                                 #The absolute position you'd like to move to
    mechGain = MECH_GAIN.timing_belt_150mm_turn    #The mechanical gain of the actuator on the axis
    mm.configAxis(axis, MICRO_STEPS.ustep_8, mechGain)

    # Configure movement speed, acceleration and then move
    mm.emitSpeed(speed)
    mm.emitAcceleration(acceleration)
    mm.emitAbsoluteMove(axis, position)
    print("Axis " + str(axis) + " is moving towards position " + str(position) + "mm")
    mm.waitForMotionCompletion()
    print("Axis " + str(axis) + " is at position " + str(position) + "mm")

    return jsonify({'error': 'Up btn complete'})
Пример #10
0
import sys
sys.path.append("..")
from MachineMotion import *

#Declare parameters for g-Code command
speed = 500
acceleration = 500
mechGain = MECH_GAIN.timing_belt_150mm_turn


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

mm.emitSpeed(speed)
mm.emitAcceleration(acceleration)
mm.emitHomeAll()
print("All Axes homed.")

# Use the G0 command to move both axis 1 and 2 by 50mm
gCodeCommand = "G0 X50 Y50"
mm.emitgCode(gCodeCommand)
Пример #11
0
import sys
sys.path.append("..")
from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

#Define Move Parameters
axes = [1, 2, 3]
speed = 400
acceleration = 500
direction = ["positive", "positive", "positive"]
Position500mm = [150, 150, 150]
mechGain = MECH_GAIN.timing_belt_150mm_turn

#Load Relative Move Parameters
mm.emitSpeed(speed)
mm.emitAcceleration(acceleration)
Пример #12
0
# System imports
import sys
# Custom imports
sys.path.append("..")

from MachineMotion import *

from random import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion("192.168.7.2", templateCallback)
time.sleep(1)

# Input device
# TODO: make class/struct
input_device = 1
input_pin = 0
input_state = 0

# Output device
# TODO: make class/struct
output_device = 2
output_pin = 0
output_state = 0

count = 0
Пример #13
0
from MachineMotion import *

#Declare parameters for combined absolute move
speed = 500
acceleration = 1000
axesToMove = [1,2,3]
positions = [-500, -500, -500]
direction = ["positive", "positive", "positive"]
mechGain = MECH_GAIN.timing_belt_150mm_turn
randTime = 0

# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
   print ( "Controller gCode responses " + data )

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows, gCodeCallback = templateCallback)

def eStop(mm):

    def goHomeCallback(mm):
        print("Recover from eStop: go Home All")
        mm.emitHomeAll()

    # mm.bindeStopEvent(goHomeCallback(mm))

    mm.triggerEstop()
    print("--> eStop triggered")

    mm.releaseEstop()
    print("--> eStop released")
Пример #14
0
import sys
sys.path.append("..")
from MachineMotion import *

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

axis = AXIS_NUMBER.DRIVE1
mm.configAxis(axis, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)

homesTowards = {
    DIRECTION.POSITIVE: "sensor " + str(axis) + "A",
    DIRECTION.NEGATIVE: "sensor " + str(axis) + "B"
}

direction = DIRECTION.POSITIVE
print("Axis " + str(axis) + " is set to " + direction +
      " mode. It will now home towards " + homesTowards[direction] + ".")
mm.configAxisDirection(axis, direction)
mm.emitHome(axis)

mm.waitForMotionCompletion()

direction = DIRECTION.NEGATIVE
print("Axis " + str(axis) + " is set to " + direction +
      " mode. It will now home towards " + homesTowards[direction] + ".")
Пример #15
0
#!/usr/bin/python

# System imports
import sys
# Custom imports
sys.path.append("..")

import time

from MachineMotion import *

# Create MachineMotion instance
mm = MachineMotion("192.168.7.2", None)

mm.triggerEstop()
print("--> eStop triggered")
time.sleep(3.0)

mm.releaseEstop()
print("--> eStop released")
time.sleep(3.0)

mm.resetSystem()
print("--> System resetted")

print("--> Example completed")
Пример #16
0
# System imports
import sys
import time
# Custom imports
sys.path.append("..")

from MachineMotion import *

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

time.sleep(0.5)

#Reads and Prints all input values on all connected digital IO Modules
detectedIOModules = mm.detectIOModules()
for IO_Name, IO_NetworkID in detectedIOModules.items():
    readPins = {"Pin 1": 0, "Pin 2": 1, "Pin 3": 2, "Pin 4": 3}
    for readPin in readPins:
        pinValue = mm.digitalRead(IO_NetworkID, readPins[readPin])
        print(readPin + " on " + IO_Name + " has value " + str(pinValue))
Пример #17
0
# Testing the speed functions on Marlin using gCode and thin client
# System imports
import sys
import random
import time

# Custom imports
sys.path.append("..")
from MachineMotion import *

m1 = MachineMotion("192.168.7.2", None)

m1.configAxisDirection(AXIS_NUMBER.DRIVE3, DIRECTION.NORMAL)
m1.configAxis(AXIS_NUMBER.DRIVE3, MICRO_STEPS.ustep_8,
              MECH_GAIN.roller_conveyor_mm_turn)

m1.releaseEstop()
m1.resetSystem()

time.sleep(2.0)

move = 100.0

m1.emitSpeed(500)
m1.emitAcceleration(500)
m1.emitRelativeMove(3, DIRECTION.NORMAL, move)

time.sleep(3.0)

previous_position = m1.readEncoder(2)
Пример #18
0
import sys
sys.path.append("..")
from MachineMotion import *

#Initialize MachineMotion with default IP address
mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)
print("Application Message: MachineMotion Controller Connected")

#Configure machine motion with a static IP address
mode = NETWORK_MODE.static
machineIp = "192.168.0.2"
machineNetmask = "255.255.255.0"
machineGateway = "192.168.0.1"
mm.configMachineMotionIp(mode, machineIp, machineNetmask, machineGateway)
print("MachineMotion configured in static mode with an ip of " +
      str(machineIp) + ".")

#Configure MachineMotion IP to use Dynamic Host Configuration Protocol (DHCP)
mm.configMachineMotionIp(NETWORK_MODE.dhcp)
print("MachineMotion configured in DHCP mode.")
Пример #19
0
#!/usr/bin/python

# System imports
import sys
# Custom imports
sys.path.append("..")

from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows, templateCallback)

mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
mm.configAxis(2, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
mm.configAxis(3, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)

# Configuring the travel speed to 10 000 mm / min
mm.emitSpeed(100000)

# Configuring the travel speed to 1000 mm / second^2
mm.emitAcceleration(10000)

# Homing axis one
mm.emitHomeAll()
mm.waitForMotionCompletion()
# System imports
import sys
# Custom imports
sys.path.append("../mm-python-api")

import random
from MachineMotion import *

cycle_counter = 0

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

#Trying to trigger many time release eStop after trigger event
print("--> Trying to release many times eStop after trigger event <--")
mm.triggerEstop()
print("--> eStop triggered")

for i in range(10):
    mm.releaseEstop()
    print("--> eStop released")

if mm.resetSystem():
    print("--> System resetted")
else:
    print("--> Failed to reset system")

# While system is alive, try releasing estop many times.
print("--> Trying to release many times eStop while system is alive <--")

for i in range(20):
    mm.releaseEstop()
Пример #21
0
import sys
sys.path.append("..")
from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

speed = 500  # The speed [mm/s] that all subsequent moves will move at
mm.emitSpeed(speed)
print("Global acceleration set to " + str(speed))
Пример #22
0
sys.path.append("..")
from MachineMotion import *

#Declare parameters for g-Code command
speed = 1000
acceleration = 2000
mechGain = MECH_GAIN.timing_belt_150mm_turn


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

axis = AXIS_NUMBER.DRIVE1

mm.configAxis(axis, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)

mm.emitSpeed(speed)
mm.emitAcceleration(acceleration)
mm.emitHome(axis)
mm.configAxis(AXIS_NUMBER.DRIVE1, MICRO_STEPS.ustep_8, mechGain)
Пример #23
0
import sys

sys.path.append("..")
from MachineMotion import *

#### Machine Motion initialization ####

# Initialize the machine motion object
mm = MachineMotion(DEFAULT_IP)
print('mm initialized')

# Remove the software stop
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

# Configure the axis number 1, 8 uSteps and 10 mm / turn for a ball screw linear drive
axis = AXIS_NUMBER.DRIVE2
uStep = MICRO_STEPS.ustep_8
mechGain = MECH_GAIN.ballscrew_10mm_turn
mm.configAxis(axis, uStep, mechGain)
print("Axis " + str(axis) + " configured with " + str(uStep) +
      " microstepping and " + str(mechGain) + "mm/turn mechanical gain")

# Configure the axis direction
ax_direction = DIRECTION.POSITIVE
mm.configAxisDirection(axis, ax_direction)
print("Axis direction set to " + str(ax_direction))

# Relative Move Parameters
Пример #24
0
import sys
sys.path.append("..")
from MachineMotion import *

# Initialize the key-value pair to save on the controller
dataKey = "example_key"
dataContent = "save_this_string_on_the_controller"

def templateCallback(data) :
	print("Data: '" + str(data) + "' retrieved from controller using key '" + dataKey + "'")

	return

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

# Saving a string on the controller
mm.saveData(dataKey, dataContent)
print("Data: '" + dataContent + "' saved on controller under key '" + dataKey + "'")

# Retreiving data from the controller
retrievedData = mm.getData(dataKey, templateCallback)
Пример #25
0
# This test spams the server with V0 commands and sees how it responds
import sys

sys.path.append("..")
from MachineMotion import *

# Create MachineMotion instance
mm = MachineMotion("192.168.7.2", None)

print("Start of test")

while (True):
    # Output V0 to Marlin
    mm.emitgCode("M119")

print("End of test")
Пример #26
0
import random
import threading
import time
import sys

sys.path.append("..")

from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def debug(data):
    pass


mm = MachineMotion("localhost", debug)
avg_perf_M119 = {"count": 0, "total": 0}
avg_perf_M115 = {"count": 0, "total": 0}
avg_perf_M114 = {"count": 0, "total": 0}


def move(mm):
    while True:
        pos = random.randint(10, 3000) - 1500
        print("moving to %s" % pos)
        mm.emitgCode("G0 X%s" % pos)
        mm.waitForMotionCompletion()
        time.sleep(random.random() * 2)


def getEndstops(mm):
Пример #27
0
import sys

sys.path.append("..")
from MachineMotion import *


# Define a callback to process controller gCode responses (if desired)
def templateCallback(data):
    print("Controller gCode responses " + data)


mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows,
                   gCodeCallback=templateCallback)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

mm.emitHome(1)

# Move the axis one to position 100 mm
mm.emitAbsoluteMove(1, 100)
print("This message gets printed immediately")
mm.waitForMotionCompletion()
print("This message gets printed once machine is finished moving")
Пример #28
0
import sys
sys.path.append("..")
from MachineMotion import *

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

axis = 1  #The axis that you'd like to move
speed = 400  #The max speed you'd like to move at
acceleration = 500  #The constant acceleration and decceleration value for the move
position = 100  #The absolute position you'd like to move to
mechGain = MECH_GAIN.rack_pinion_mm_turn  #The mechanical gain of the actuator on the axis

mm.emitSpeed(speed)
mm.emitAcceleration(acceleration)
mm.configAxis(axis, MICRO_STEPS.ustep_16, mechGain)

mm.emitHome(axis)
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " homed")

print("Absolute Moves are referenced from home")
mm.emitAbsoluteMove(axis, position)
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " is " + str(position) + "mm away from home")
Пример #29
0
import sys

sys.path.append("..")
from MachineMotion import *
import pyrealsense2 as rs
import time
from datetime import datetime
import numpy as np
import cv2
import threading

#### Machine Motion initialization ####

# Initialize the machine motion object
mm = MachineMotion(DEFAULT_IP)
print('mm initialized')

# Remove the software stop
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

# Configure the axis number 1, 8 uSteps and 10 mm / turn for a ball screw linear drive
axis = AXIS_NUMBER.DRIVE2
uStep = MICRO_STEPS.ustep_8
mechGain = MECH_GAIN.ballscrew_10mm_turn
mm.configAxis(axis, uStep, mechGain)
print("Axis " + str(axis) + " configured with " + str(uStep) +
      " microstepping and " + str(mechGain) + "mm/turn mechanical gain")
Пример #30
0
import sys
sys.path.append("..")
from MachineMotion import *

mm = MachineMotion(DEFAULT_IP_ADDRESS.usb_windows)

#When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
mm.resetSystem()

axes = [1, 2, 3]
axis = 3  #The axis that you'd like to move
homingSpeeds = [50, 50, 50]  #The homing speeds to set for each axis

mm.emitSpeed(100)
mm.emitAcceleration(50)
mm.configAxis(axis, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)

print("Moving to position = 100")
mm.emitAbsoluteMove(axis, 100)
mm.waitForMotionCompletion()

#Sets minimum and maximum allowable homing speeds for each axis
minHomingSpeeds = [20, 20, 20]
maxHomingSpeeds = [250, 250, 250]
mm.configMinMaxHomingSpeed(axes, minHomingSpeeds, maxHomingSpeeds,
                           UNITS_SPEED.mm_per_sec)

#Sets homing speeds for all three axes. The selected homing speed must be within the range set by configMinMaxHomingSpeeds