diff --git a/README.md b/README.md index 6ff4697..f76642f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ To set up the MachineMotion Python Library on your computer, follow the steps be - Download the version of the library that you require on [GitHub](https://github.com/VentionCo/mm-python-api/releases) + + - Controllers with software v1.2.11 and earlier are compatible with the Python API v1.6.8 and earlier + - Controllers with software v1.12.0+ are compatible with the Python API v2.0+ + - Install Python on your computer. The MachineMotion library supports both Python 2.7 and Python 3.6. - If installing on Windows, make sure to add Python.exe to the PATH environment variable as shown in *Figure 2* and *Figure 3*. diff --git a/__documentation/api/machine_motion_python_api--v1.6.8.md b/__documentation/api/machine_motion_python_api--v1.6.8.md index 8ee9b2e..c9f721a 100644 --- a/__documentation/api/machine_motion_python_api--v1.6.8.md +++ b/__documentation/api/machine_motion_python_api--v1.6.8.md @@ -600,7 +600,7 @@ sys.exit(0) ``` --- -### emitCombinedAbsoluteMove(axes, positions) +### emitCombinedAxesAbsoluteMove(axes, positions) > Send an absolute move command to the MachineMotion controller. Moves multiple axis simultaneously. @@ -614,7 +614,7 @@ sys.exit(0) > none #### Reference Example -> example--emitCombinedAbsoluteMove.py +> example--emitCombinedAxesAbsoluteMove.py ```python from _MachineMotion_1_6_8 import * @@ -641,11 +641,11 @@ mm.emitAcceleration(1000) print ("Application Message: Acceleration configured \n") # Homing axis 1 -mm.emitHome(1) -print ("Application Message: Axis 1 is at home \n") +mm.emitHomeAll() +print ("Application Message: Axes at home \n") # Move the axis 1 to position 100 mm -mm.emitCombinedAbsoluteMove([1, 2, 3], [100, 200, 100]) +mm.emitCombinedAxesAbsoluteMove([1, 2, 3], [50, 100, 50]) print ("Application Message: Motion on-going ... \n") mm.waitForMotionCompletion() @@ -699,13 +699,13 @@ print ("Application Message: Speed configured \n") mm.emitAcceleration(1000) print ("Application Message: Acceleration configured \n") -# Homing axis 1 -mm.emitHome(1) -print ("Application Message: Axis 1 at home \n") +# Homing all axes +mm.emitHomeAll() +print ("Application Message: Axes at home \n") # Move the axis one to position 100 mm -mm.emitRelativeMove(1, "positive", 100) -print ("Application Message: Move on-going ... \n") +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") @@ -716,7 +716,7 @@ sys.exit(0) ``` --- -### emitCombinedAxisRelativeMove(axes, directions, distances) +### emitCombinedAxesRelativeMove(axes, directions, distances) > Send a relative move command to the MachineMotion controller. Moves multiple axis simultaneously. @@ -733,7 +733,7 @@ sys.exit(0) > none #### Reference Example -> example--emitCombinedRelativeMove.py +> example--emitCombinedAxesRelativeMove.py ```python from _MachineMotion_1_6_8 import * diff --git a/examples/_MachineMotion_1_6_8.py b/examples/_MachineMotion_1_6_8.py index 5dce4fd..874517a 100644 --- a/examples/_MachineMotion_1_6_8.py +++ b/examples/_MachineMotion_1_6_8.py @@ -532,7 +532,7 @@ def emitAbsoluteMove(self, axis, position): # def emitCombinedAxesAbsoluteMove(self, axes, positions): if (not isinstance(axes, list) or not isinstance(positions, list)): - raise TypeError("Axes and Postions must be lists") + raise TypeError("All parameters must be lists") global motion_completed @@ -580,8 +580,8 @@ def emitRelativeMove(self, axis, direction, distance): # @status # def emitCombinedAxisRelativeMove(self, axes, directions, distances): - if (not isinstance(axes, list) or not isinstance(directions, list) or isinstance(distances, list)): - raise TypeError("Axes and Postions must be lists") + 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 @@ -691,6 +691,38 @@ def configAxis(self, axis, _u_step, _mech_gain): else: pass # print "Argument error, {configAxis(self, axis, u_step, mech_gain)}, {u_step} argument is invalid" + + # + # Function to reverse the positive direction of an axis, also reverse the home and end-of-travel sensor port + # @param axis --- Description: Axis on which the setting applies --- Type: string or number. + # @param data --- Description: normal or reverse axis direction --- Type: dictionary. + # @status + # + 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)) + # # Function to save/persist data in the MachineMotion Controller (key - data pair) # @param key --- Description: key is a string that identifies the data to save for future retrieval. --- Type: string or number. diff --git a/examples/_MachineMotion_1_6_8.pyc b/examples/_MachineMotion_1_6_8.pyc new file mode 100644 index 0000000..466d8fd Binary files /dev/null and b/examples/_MachineMotion_1_6_8.pyc differ diff --git a/examples/example--emitAbsoluteMove.py b/examples/example--emitAbsoluteMove.py index 2483993..0d6c5e0 100644 --- a/examples/example--emitAbsoluteMove.py +++ b/examples/example--emitAbsoluteMove.py @@ -41,6 +41,18 @@ def debug(data): mm.waitForMotionCompletion() print ("Application Message: Motion completed \n") +mm.setAxisDirection(1, "reverse") +print ("Application Message: Axis 1 direction reverse \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") + + print ("Application Message: Program terminating ... \n") time.sleep(1) sys.exit(0) diff --git a/examples/example--emitCombinedAbsoluteMove.py b/examples/example--emitCombinedAxesAbsoluteMove.py similarity index 90% rename from examples/example--emitCombinedAbsoluteMove.py rename to examples/example--emitCombinedAxesAbsoluteMove.py index e9cc740..15aa72f 100644 --- a/examples/example--emitCombinedAbsoluteMove.py +++ b/examples/example--emitCombinedAxesAbsoluteMove.py @@ -4,7 +4,7 @@ ## Author: Francois Giguere ## Version: 1.6.8 ## Email: info@vention.cc -## Status: ready to test +## Status: tested ################################################## from _MachineMotion_1_6_8 import * @@ -31,11 +31,11 @@ def debug(data): print ("Application Message: Acceleration configured \n") # Homing axis 1 -mm.emitHome(1) -print ("Application Message: Axis 1 is at home \n") +mm.emitHomeAll() +print ("Application Message: Axes at home \n") # Move the axis 1 to position 100 mm -mm.emitCombinedAbsoluteMove([1, 2, 3], [100, 200, 100]) +mm.emitCombinedAxesAbsoluteMove([1, 2, 3], [50, 100, 50]) print ("Application Message: Motion on-going ... \n") mm.waitForMotionCompletion() diff --git a/examples/example--emitCombinedRelativeMove.py b/examples/example--emitCombinedAxesRelativeMove.py similarity index 86% rename from examples/example--emitCombinedRelativeMove.py rename to examples/example--emitCombinedAxesRelativeMove.py index 5613c4e..e0afa8e 100644 --- a/examples/example--emitCombinedRelativeMove.py +++ b/examples/example--emitCombinedAxesRelativeMove.py @@ -4,7 +4,7 @@ ## Author: Francois Giguere ## Version: 1.6.8 ## Email: info@vention.cc -## Status: ready to test +## Status: tested ################################################## from _MachineMotion_1_6_8 import * @@ -30,12 +30,12 @@ def debug(data): mm.emitAcceleration(1000) print ("Application Message: Acceleration configured \n") -# Homing axis 1 -mm.emitHome(1) -print ("Application Message: Axis 1 at home \n") +# Homing all axes +mm.emitHomeAll() +print ("Application Message: Axes at home \n") # Move the axis one to position 100 mm -mm.emitCombinedRelativeMove([1,2,3], ["positive","positive","positive"], [100, 200, 300]) +mm.emitCombinedAxisRelativeMove([1, 2, 3], ["positive", "positive", "positive"], [100, 200, 300]) print ("Application Message: Multi-axis move on-going ... \n") mm.waitForMotionCompletion() diff --git a/examples/example--emitSetAxisDirection.py b/examples/example--emitSetAxisDirection.py new file mode 100644 index 0000000..246bed7 --- /dev/null +++ b/examples/example--emitSetAxisDirection.py @@ -0,0 +1,63 @@ +################################################## +## Axis Direction +################################################## +## Author: Francois Giguere +## Version: 1.6.8 +## Email: info@vention.cc +## Status: tested +################################################## + +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): + pass + +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 1000 mm / second^2 +mm.emitAcceleration(1000) +print ("Application Message: Acceleration configured \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") + + +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) + + diff --git a/examples/example--saveData_getData.py b/examples/example--saveData_getData.py index 3bb404d..bc02c3b 100644 --- a/examples/example--saveData_getData.py +++ b/examples/example--saveData_getData.py @@ -4,7 +4,7 @@ ## Author: Francois Giguere ## Version: 1.6.8 ## Email: info@vention.cc -## Status: released +## Status: tested ################################################## from _MachineMotion_1_6_8 import * diff --git a/examples/example--setPosition.py b/examples/example--setPosition.py index af52175..68ff2b7 100644 --- a/examples/example--setPosition.py +++ b/examples/example--setPosition.py @@ -4,7 +4,7 @@ ## Author: Francois Giguere ## Version: 1.6.8 ## Email: info@vention.cc -## Status: rdy for test +## Status: tested ################################################## from _MachineMotion_1_6_8 import * @@ -26,7 +26,7 @@ def debug(data): mm.setPosition(1, 100) print ("Application Message: Position set to 100 mm on axis 1\n") -mm.moveRelative(1, "negative", 50) +mm.emitRelativeMove(1, "negative", 50) print ("Application Message: Moving in the negative direction ... \n") mm.waitForMotionCompletion() diff --git a/release-notes.md b/release-notes.md index 144ee83..38b48fb 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,17 +1,18 @@ # Version 1.6.8 -Date: September 24th, 2019 +- Date: September 27th, 2019 +- Released by: Francois Giguere ## Compatibility ### Interface Changes -- No Interface changes in this release #### Obsoleted Interfaces - none #### New Interfaces - setPosition +- setAxisDirection - emitCombinedAxisRelativeMove - emitCombinedAxesAbsoluteMove