sivicncdriver.gcode package

Submodules

sivicncdriver.gcode.arc_calculator module

The arc_calculator module

It creates small segments from an arc given with G-codes parameters : origin, end, path to center and sense of rotation.

Example:
>>> from arc_calculator import arc_to_segments
>>> a = arc_to_segments((0,0),(5,0),(10,0))
>>> for x,y in a:
...     print((x,y))
...
(0.0, 6.12323e-16)
(0.09966, -0.993334)
(0.39469, -1.94708)
(0.87331, -2.8232)
(1.51646, -3.58677)
(2.29848, -4.20735)
(3.1882, -4.66019)
(4.15015, -4.92725)
(5.14598, -4.99787)
(6.136, -4.86924)
(7.08072, -4.54649)
(7.94249, -4.04249)
(8.68696, -3.37733)
(9.28444, -2.57752)
(9.71111, -1.67495)
(10, 0)
sivicncdriver.gcode.arc_calculator.arc_to_segments(start, vect_to_center, end, clockwise=False, length=1)[source]

Creates small segments from an arc.

Uses Decimal for better precision. It yields the vertices.

Parameters:
  • start (A float tuple) – The starting position
  • vect_to_center (A float tuple) – A vector to go to the center of the arc from the starting position
  • end (A float tuple) – The ending position
  • clockwise (bool) – Should it go clockwise ?
  • length (float) – length of the segments
Returns:

None, it yields vertices.

sivicncdriver.gcode.gcode module

A module to parse G-codes.

sivicncdriver.gcode.gcode.parse(gcode)[source]

Parse gcode.

It yields a dict for each line with :

name
name of the code (G, M)
value
an integer
args
a dict with the code arguments, ex : {‘Y’:3.0}
Parameters:gcode (str) – The gcode which is to be parsed.

sivicncdriver.gcode.gcode_maker module

A bunch of command to easily create G-Codes.

sivicncdriver.gcode.gcode_maker.config_as_gcode(**kwargs)[source]

Make a set of commands to save the configuration.

Parameters:
  • x_ratio (float) – The X axis ratio (mm/step)
  • y_ratio (float) – The Y axis ratio (mm/step)
  • z_ratio (float) – The Z axis ratio (mm/step)
  • x_drive (int) – X axis drive mode (0:normal, 1:full torque, 2:half step)
  • y_drive (int) – Y axis drive mode (0:normal, 1:full torque, 2:half step)
  • z_drive (int) – Z axis drive mode (0:normal, 1:full torque, 2:half step)
  • x_play (float) – X axis play
  • y_play (float) – Y axis play
  • z_play (float) – Z axis play
  • x_reverse (bool) – Should the X axis be reversed ?
  • y_reverse (bool) – Should the Y axis be reversed ?
  • z_reverse (bool) – Should the Z axis be reversed ?
  • x_min_time (int) – The minimal duration between 2 pulse for the x axis in milliseconds.
  • y_min_time (int) – The minimal duration between 2 pulse for the y axis in milliseconds.
  • z_min_time (int) – The minimal duration between 2 pulse for the z axis in milliseconds.
sivicncdriver.gcode.gcode_maker.emergency_stop()[source]

Stop every axis.

sivicncdriver.gcode.gcode_maker.goto_origin()[source]

Go to the origin.

sivicncdriver.gcode.gcode_maker.set_origin()[source]

Register the current position as the origin.

sivicncdriver.gcode.gcode_maker.start_continuous(axis, direction='forward')[source]

Start a continuous movement in the given direction. :param axis: The axis which is to move. :param direction: The direction. :type axis: str :type direction: str

sivicncdriver.gcode.gcode_maker.start_continuous_x_backward()[source]

Start a continuous movement on X axis backward

sivicncdriver.gcode.gcode_maker.start_continuous_x_forward()[source]

Start a continuous movement on X axis forward.

sivicncdriver.gcode.gcode_maker.start_continuous_y_backward()[source]

Start a continuous movement on Y axis backward

sivicncdriver.gcode.gcode_maker.start_continuous_y_forward()[source]

Start a continuous movement on Y axis forward.

sivicncdriver.gcode.gcode_maker.start_continuous_z_backward()[source]

Start a continuous movement on Z axis backward

sivicncdriver.gcode.gcode_maker.start_continuous_z_forward()[source]

Start a continuous movement on Z axis forward.

sivicncdriver.gcode.gcode_maker.step(axis, n)[source]

Moves the given axis of n steps.

Parameters:
  • axis (str) – The axis
  • n (int) – number of steps
sivicncdriver.gcode.gcode_maker.step_x(n)[source]

Moves the X axis oh n steps. :param n: The number of steps :type n: int

sivicncdriver.gcode.gcode_maker.step_y(n)[source]

Moves the Y axis oh n steps. :param n: The number of steps :type n: int

sivicncdriver.gcode.gcode_maker.step_z(n)[source]

Moves the Z axis oh n steps. :param n: The number of steps :type n: int

sivicncdriver.gcode.gcode_maker.stop(axis)[source]

Stop any movement on the given axis.

sivicncdriver.gcode.gcode_maker.stop_x()[source]

Stop any movement on the X axis.

sivicncdriver.gcode.gcode_maker.stop_y()[source]

Stop any movement on the Y axis.

sivicncdriver.gcode.gcode_maker.stop_z()[source]

Stop any movement on the Z axis.

Module contents