Vention's Tech Docs

User Manual

Application Programming Interface: Python v1.6.8

Build a deeper understanding of the MachineMotion Python API by consulting this developers reference manual. This manual refers to version 1.6.8 of the API, which is compatible with controller software version 1.2.11 and earlier

The MachineMotion python API can be used to quickly build custom applications to control your Vention fixture. If this is your first time using the machine motion controller, please follow the Python programming manual here.

mm. configAxis ( _u_step, _mech_gain, axis )

Initializes parameters for proper axis control.
_u_step Number - The number of microsteps taken by the stepper motor. Must be either 1, 2, 5, 8 or 16.
_mech_gain Number - The distance moved by the actuator for every full rotation of the stepper motor, in mm/revolution.
axis Number - The axis to configure.
NOTE:
The uStep setting is hardcoded into the machinemotion controller through a DIP switch and is by default set to 8. The value here must match the value on the DIP Switch.
    def configAxis(self, axis, _u_step, _mech_gain):

        u_step    = float(_u_step)
        mech_gain = float(_mech_gain)

        # validate that the uStep setting is valid
        if (self.valid_u_step.index(u_step) != -1):
            if(axis == 1):
                self.myAxis1_steps_mm = 200 * u_step / mech_gain
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis1_steps_mm))
            elif(axis == 2):
                self.myAxis1_steps_mm = 200 * u_step / mech_gain
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis1_steps_mm))
            elif(axis == 3):
                self.myAxis1_steps_mm = 200 * u_step / mech_gain
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis1_steps_mm))
            else:
                pass
                # print "Argument error, {configAxis(self, axis, u_step, mech_gain)}, {axis} argument is invalid"

        else:
            pass
##################################################
## Axis Configuration
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion axis 1 configured \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. configMachineMotionIp ( gatewayIp, machineIp, machineNetmask, machineGateway )

Set up the required network information for the Machine Motion controller.
gatewayIp String - The gateway IP Address given to the controller.
machineIp String - The static IP Address given to the controller.
machineNetmask String - The netmask IP Address given to the controller.
machineGateway String - The gateway IP Address given to the controller.
    def configMachineMotionIp(self, mode, machineIp, machineNetmask, machineGateway):

        # Create a new object and augment it with the key value.
        self.myConfiguration["mode"] = mode
        self.myConfiguration["machineIp"] = machineIp
        self.myConfiguration["machineNetmask"] = machineNetmask
        self.myConfiguration["machineGateway"] = machineGateway


        self.mySocket.emit('configIp', json.dumps(self.myConfiguration))

        time.sleep(1)
##################################################
## Ethernet Port Static Configuration
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

# TODO: ip_address can be set to another value if desired by the user. For example if the controller is connected to a LAN
ip_address = DEFAULT_IP_ADDRESS.usb_windows 

mm = MachineMotion(debug, ip_address)
print ("Application Message: MachineMotion Controller Connected \n")

# Setting the ETHERNET port of the controller in static mode
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 ("Application Message: Ethernet Port Configured \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitAbsoluteMove ( position, axis )

Moves the specified axis to a desired end location.
position Number - The desired end position of the axis movement.
axis Number - The axis which will perform the absolute move command.
    def emitAbsoluteMove(self, axis, position):
        global motion_completed

        motion_completed = "false"

        # Set to absolute motion mode
        self.myGCode.__emit__("G90")
        while self.isReady() != "true": pass

        # Transmit move command
        self.myGCode.__emit__("G0 " + self.myGCode.__getTrueAxis__(axis) + str(position))
        while self.isReady() != "true": pass
##################################################
## Absolute Move
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")
    
print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 1000 mm / min
mm.emitSpeed(1000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

# Homing axis 1
mm.emitHome(1)
print ("Application Message: Axis 1 going home \n")
mm.waitForMotionCompletion()
print ("Application Message: Axis 1 is at home \n")

# Move the axis 1 to position 100 mm
mm.emitAbsoluteMove(1, 100)
print ("Application Message: Motion on-going ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")



print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitAcceleration ( mm_per_sec_sqr )

Sets the global acceleration for all movement commands on all axes.
mm_per_sec_sqr Number - The global acceleration in mm/s^2.
    def emitAcceleration(self, mm_per_sec_sqr):

        self.myGCode.__emit__("M204 T" + str(mm_per_sec_sqr))
        while self.isReady() != "true": pass
##################################################
## Acceleration Configuration
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = True

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel acceleration to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitCombinedAxesAbsoluteMove ( positions, axes )

Moves multiple specified axes to their desired end locations.
positions List - The desired end position of all axess movement. Ex - [50, 10]
axes List - The axes which will perform the move commands. Ex - [1 ,3]
    def emitCombinedAxesAbsoluteMove(self, axes, positions):
        if (not isinstance(axes, list) or not isinstance(positions, list)):
            raise TypeError("All parameters must be lists")

        global motion_completed

        motion_completed = "false"

        # Set to absolute motion mode
        self.myGCode.__emit__("G90")
        while self.isReady() != "true": pass

        # Transmit move command
        command = "G0 "
        for axis, position in zip(axes, positions):
            command += self.myGCode.__getTrueAxis__(axis) + str(position) + " "
        self.myGCode.__emit__(command)
        while self.isReady() != "true": pass
##################################################
## Combined Absolute Move
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 10000 mm / min
mm.emitSpeed(10000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

# Homing axis 1
mm.emitHomeAll()
print ("Application Message: Axes at home \n")

# Simultaneously moves three axis:
#   Moves axis 1 to absolute position 50
#   Moves axis 2 to absolute position 100
#   Moves axis 3 to absolute position 50
mm.emitCombinedAxesAbsoluteMove([1, 2, 3], [50, 100, 50])
print ("Application Message: Motion on-going ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitCombinedAxisRelativeMove ( distance, direction, axes )

Moves the multiple specified axes the specified distances in the specified directions.
distance List - The travel distances in mm. Ex - [10, 40]
direction String - The direction of travel of each specified axis. Ex - ["positive", "negative"]
axes List - The axes to move. Ex-[1,3]
    def emitCombinedAxisRelativeMove(self, axes, directions, distances):

        if (not isinstance(axes, list) or not isinstance(directions, list) or not isinstance(distances, list)):
            raise TypeError("All parameters must be lists")
        
        global motion_completed

        motion_completed = "false"

        # Set to relative motion mode
        self.myGCode.__emit__("G91")
        while self.isReady() != "true": pass

        # Transmit move command
        command = "G0 "
        for axis, direction, distance in zip(axes, directions, distances):
            if direction == "positive": distance = "" + str(distance)
            elif direction  == "negative": distance = "-" + str(distance)
            command += self.myGCode.__getTrueAxis__(axis) + str(distance) + " "
        self.myGCode.__emit__(command)
        while self.isReady() != "true": pass
##################################################
## Combined Relative Move
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 10000 mm / min
mm.emitSpeed(10000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

# Homing all axes
mm.emitHomeAll()
print ("Application Message: Axes at home \n")

# Simultaneously moves three axis:
#   Moves axis 1 in the positive direction by 100 mm
#   Moves axis 2 in the positive direction by 200 mm
#   Moves axis 3 in the positive direction by 300 mm
mm.emitCombinedAxisRelativeMove([1, 2, 3], ["positive", "positive", "positive"], [100, 200, 300])
print ("Application Message: Multi-axis move on-going ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitHome ( axis )

Initiates the homing sequence for the specified axis.
axis Number - The number of the axis that you would like to home.
NOTE:
If setAxisDirection is set to "normal" on axis 1, axis 1 will home itself towards sensor 1A. If setAxisDirection is set to "reverse" on axis 1, axis 1 will home itself towards sensor 1B.
    def emitHome(self, axis):
        global motion_completed

        motion_completed = "false"

        self.myGCode.__emit__("G28 " + self.myGCode.__getTrueAxis__(axis))
        while self.isReady() != "true": pass
##################################################
## Home Individual Axis
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: Axis 1 configured \n")

# Homing axis 1
mm.emitHome(1)
print ("Application Message: Axis 1 is going home\n")
mm.waitForMotionCompletion()
print("Application Message: Axis 1 is at home \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitHomeAll ()

Initiates the homing sequence of all axes. All axes will home sequentially (Axis 1, 2 then 3).
    def emitHomeAll(self):

        global motion_completed

        motion_completed = "false"

        self.myGCode.__emit__("G28")
        while self.isReady() != "true": pass
##################################################
## Home All Axes
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: Axis 1 configured \n")

# Configure the axis number 2, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(2, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: Axis 2 configured \n")

# Configure the axis number 3, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(3, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: Axis 3 configured \n")

# Homing all the axes of the controller sequentially
mm.emitHomeAll()
print ("Application Message: Axes are going home\n")
mm.waitForMotionCompletion()
print("Application Message: Axes are home\n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitRelativeMove ( distance, direction, axis )

Moves the specified axis the specified distance in the specified direction.
distance Number - The travel distance in mm.
direction String - The direction of travel. Ex - "positive" or "negative"
axis Integer - The axis to move.
    def emitRelativeMove(self, axis, direction, distance):
        global motion_completed

        motion_completed = "false"

        # Set to relative motion mode
        self.myGCode.__emit__("G91")
        while self.isReady() != "true": pass

        if direction == "positive":distance = "" + str(distance)
        elif direction  == "negative": distance = "-" + str(distance)

        # Transmit move command
        self.myGCode.__emit__("G0 " + self.myGCode.__getTrueAxis__(axis) + str(distance))
        while self.isReady() != "true": pass
##################################################
## Relative Move
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 10000 mm / min
mm.emitSpeed(10000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

# Homing axis 1
mm.emitHome(1)
print ("Application Message: Axis 1 is going home \n")
mm.waitForMotionCompletion()
print ("Application Message: Axis 1 at home \n")

# Move the axis one to position 100 mm
mm.emitRelativeMove(1, "positive", 100)
print ("Application Message: Move on-going ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitSetAxisDirection ( direction, axis )

Reversing the axis direction reverses the location of the home sensor and reverses the positive motion direction. In Normal direction, the Home sensor is xA, in Reverse the Home sensor is xB.
direction String - A string of value either either 'Normal' or 'Reverse'. 'Normal' direction means the axis will home towards end stop sensor A and reverse will make the axis home towards end stop B. Ex - "Reverse"
axis Number - The specified axis.
NOTE:
For more details on how to properly set the axis direction, please see here
    def emitSetAxisDirection(self, axis, direction):

    
        # Checking input parameters
        if (direction != "normal" and direction != "reverse"):
            raise ValueError('direction parameter must be either "normal" or "reversed"')
            
        if (axis != 1 and axis != 2 and axis !=3):
            raise ValueError('axis must either be 1, 2 or 3')
            
        if(axis == 1):
            if(direction == "normal"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis1_steps_mm))
            elif (direction == "reverse"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + "-" + str(self.myAxis1_steps_mm))
        elif(axis == 2):
            if(direction == "normal"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis2_steps_mm))
            elif (direction == "reverse"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + "-" + str(self.myAxis2_steps_mm))
        elif(axis == 3):
            if(direction == "normal"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + str(self.myAxis3_steps_mm))
            elif (direction == "reverse"):
                self.myGCode.__emit__("M92 " + self.myGCode.__getTrueAxis__(axis) + "-" + str(self.myAxis3_steps_mm))
##################################################
## Set Axis Direction
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *
import configWizard

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

cw = configWizard.configWizard()
# Opens a command line UI where users confirm which end stops are implemented in their system
end_stop_sensors = check_both_end_stops(1)
   
    
print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 10000 mm / min
mm.emitSpeed(10000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

mm.emitSetAxisDirection(1, "normal")
print ("Application Message: Axis direction set for axis 1 \n")

if end_stop_sensors["1A"]: 
    # Homing axis 1
    mm.emitHome(1)
    print ("Application Message: Axis 1 is going home \n")
    mm.waitForMotionCompletion()
    print ("Application Message: Axis 1 at home \n")


    # Move the axis 1 to position 100 mm
    mm.emitAbsoluteMove(1, 100)
    print ("Application Message: Motion on-going ... \n")

    mm.waitForMotionCompletion()
    print ("Application Message: Motion completed \n")

if end_stop_sensors["1B"]:
    mm.emitSetAxisDirection(1, "reverse")
    print ("Application Message: Axis direction set for axis 1 \n")

    # Homing axis 1
    mm.emitHome(1)
    print ("Application Message: Axis 1 is at home \n")

    # Move the axis 1 to position 100 mm
    mm.emitAbsoluteMove(1, 100)
    print ("Application Message: Motion on-going ... \n")

    mm.waitForMotionCompletion()
    print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitSpeed ( mm_per_min )

Sets the global speed for all movement commands on all axes.
mm_per_min Number - The global max speed in mm/min.
    def emitSpeed(self, mm_per_min):

        self.myGCode.__emit__("G0 F" +str(mm_per_min))
        while self.isReady() != "true": pass
##################################################
## Speed Configuration
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configuring the travel speed to 1000 mm / minute
mm.emitSpeed(1000)
print ("Application Message: Speed configured \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitStop ()

Immediately stops all motion of all axes
NOTE:
This function is a hard stop. It is not a controlled stop and consequently does not decelerate smoothly to a stop. Additionally, this function is not intended to serve as an emergency stop since this stop mechanism does not have safety ratings.
    def emitStop(self):
        global motion_completed

        motion_completed = "false"

        self.myGCode.__emit__("M410")

        # Wait and send a dummy packet to insure that other commands after the emit stop are not flushed.
        time.sleep(0.500)
        self.myGCode.__emit__("G0 X0")
        while self.isReady() != "true": pass
##################################################
## Immediate Stop
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion Axis 1 Configured \n")

# Configuring the travel speed to 1000 mm / min
mm.emitSpeed(1000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration configured \n")

# Homing axis 1
mm.emitHome(1)
print ("Application Message: Axis 1 is going home\n")
mm.waitForMotionCompletion()
print ("Application Message: Axis 1 at home \n")

# Move the axis one to position 100 mm
mm.emitRelativeMove(1, "positive", 100)
print ("Application Message: Move on-going ... \n")

time.sleep(2)
print ("Application Message: Waiting for 2 seconds ... \n")

# Instruct the controller to stop all motion immediately
mm.emitStop()
print ("Application Message: Motion stopped! \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. emitgCode ( gCode )

Executes raw gCode on the controller.
gCode string - The g-code that will be passed directly to the controller.
NOTE:
All movement commands sent to the controller are by default in mm.
    def emitgCode(self, gCode):

        global motion_completed

        motion_completed = "false"

        self.myGCode.__emit__(gCode)
##################################################
## Emit G Code
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion axis 1 configured \n")

# Configure the axis number 2, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(2, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion axis 2 configured \n")

# Configuring the travel speed to 10000 mm / min
mm.emitSpeed(10000)
print ("Application Message: Speed configured \n")

# Configuring the travel speed to 250 mm / second^2
mm.emitAcceleration(250)
print ("Application Message: Acceleration Configured \n")

# Homing axis 1
mm.emitHome(1)
print ("Application Message: Axis 1 at home \n")

# Homing axis 2
mm.emitHome(2)
print ("Application Message: Axis 2 at home \n")

# Use the G0 command to move both axis 1 and 2 by 50mm at a travel speed of 10000 mm / minute
mm.emitgCode("G0 X50 Y50 F10000")
print ("Application Message: Motion on-going ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. getData ( callback, key )

retreives saved/persisted data from the MachineMotion controller (in key-data pairs)
callback Function - A function that is invoked when the asynchronous data is received. The function must take a single input parameter.
key String - Uniquely identifies the data to be retreived
    def getData(self, key, callback):

        #Send the request to MachineMotion

        self.mySocket.emit('getData', key)

        # On reception of the data invoke the callback function.
        self.mySocket.on('getDataResponse', callback)
##################################################
## Save Data, Get Data Example
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")
    
print ("Application Message: MachineMotion Program Starting \n")
    
# Define a callback to print the data retrieved using the getData function
def printGetDataResult(data):

    dictionary = json.loads(data)

    print ( "Application Message: Retrieved file name = " + dictionary["fileName"] + "\n" )
    
    print ( "Application Message: Retrieved data = " + dictionary["data"]  + "\n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Saving a string on the controller
mm.saveData("data_1", "save_this_string_on_the_controller")

print ("Application Message: Data saved \n")

# Reading a string from the controller
mm.getData("data_1", printGetDataResult)

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. isMotionCompleted ()

Returns true if all axes have completed their movement.
    def isMotionCompleted(self):
        global motion_completed
        return motion_completed

mm. isReady ()

Returns true if the motion controller is ready to receive another command.
    def isReady(self):
        return self.myGCode.__isReady__()

mm. saveData ( data, key )

Saves/persists data within the MachineMotion Controller in key - data pairs.
data Dictionary - A dictionary containing the data to save
key String - A string the uniquely identifies the data to save for future retreival
NOTE:
The Data continues to exist even when the controller is shut off. However, writing to a previously used key will override the previous value.
    def saveData(self, key, data):

        # Create a new object and augment it with the key value.
        dataPack = {}
        dataPack["fileName"] = key
        dataPack["data"] = data

        # Send the request to MachineMotion
        self.mySocket.emit('saveData', json.dumps(dataPack))
        time.sleep(0.05)
##################################################
## Save Data, Get Data Example
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")
    
print ("Application Message: MachineMotion Program Starting \n")
    
# Define a callback to print the data retrieved using the getData function
def printGetDataResult(data):

    dictionary = json.loads(data)

    print ( "Application Message: Retrieved file name = " + dictionary["fileName"] + "\n" )
    
    print ( "Application Message: Retrieved data = " + dictionary["data"]  + "\n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Saving a string on the controller
mm.saveData("data_1", "save_this_string_on_the_controller")

print ("Application Message: Data saved \n")

# Reading a string from the controller
mm.getData("data_1", printGetDataResult)

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. setPosition ( position, axis )

Override the current position of the specified axis to a new value.
position Number - The new position value in mm.
axis Number - Overrides the position on this axis.
    def setPosition(self, axis, position):

        # Transmit move command
        self.myGCode.__emit__("G92 " + self.myGCode.__getTrueAxis__(axis) + str(position))
        while self.isReady() != "true": pass
##################################################
## Set Position
##################################################
## Version: 1.6.8
## Email: info@vention.cc
## Status: tested
##################################################

enableDebug = False

from _MachineMotion_1_6_8 import *

# Define a callback to process controller gCode responses if desired. This is mostly used for debugging purposes.
def debug(data):
    if(enableDebug): print("Debug Message: " + data + "\n")

print ("Application Message: MachineMotion Program Starting \n")

mm = MachineMotion(debug, DEFAULT_IP_ADDRESS.usb_windows)
print ("Application Message: MachineMotion Controller Connected \n")

# Configure the axis number 1, 8 uSteps and 150 mm / turn for a timing belt
mm.configAxis(1, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)
print ("Application Message: MachineMotion axis 1 configured \n")

# Override the current position of the machine motion controller with a new value - without moving the axis.
mm.setPosition(1, 100)
print ("Application Message: Position set to 100 mm on axis 1\n")

mm.emitRelativeMove(1, "negative", 50)
print ("Application Message: Moving in the negative direction ... \n")

mm.waitForMotionCompletion()
print ("Application Message: Motion completed \n")

print ("Application Message: Program terminating ... \n")
time.sleep(1)
sys.exit(0)

mm. waitForMotionCompletion ()

Pauses script execution while axes are still moving, continues once all axes have stopped.
    def waitForMotionCompletion(self):
        self.emitgCode("V0")
        while  self.isMotionCompleted() != "true": pass

Comments (0)