# Python: package reprap

reprap (version 2.0) | index /usr/lib/python2.5/site-packages/reprap/__init__.py

`This is the main pyRepRap module for controlling a serial
SNAP RepRap machine.
Import this module and use the internally created objects
reprap.cartesian and reprap.extruder to control the machine.
Example:
# Import the reprap modules
import reprap, time
# Initialise serial port, here the first port (0) is used.
reprap.openSerial( 0, 19200, 60 )
# These devices are present in network, will automatically scan in the future.
reprap.cartesian.x.active = True
reprap.cartesian.y.active = True
reprap.cartesian.z.active = True
reprap.extruder.active = True
# Set axies to notify arrivals
reprap.cartesian.x.setNotify()
reprap.cartesian.y.setNotify()
reprap.cartesian.z.setNotify()
# Set stepper speed to 220 (out of 255)
reprap.cartesian.setSpeed(220)
# Set power to 83%
reprap.cartesian.setPower(83)
# The module is now ready to recieve commands #
# Send all axies to home position. Wait until arrival.
reprap.cartesian.homeReset()
# When using seek with no waitArrival = True/False argument, it defaults to true
# Seek to X1000, Y1000
reprap.cartesian.seek( (1000, 1000, None) )
# Pause
time.sleep(2)
# Seek to X500, Y1000
reprap.cartesian.seek( (500, 1000, None) )
time.sleep(2)
# Seek to X1000, Y500
reprap.cartesian.seek( (1000, 500, None) )
time.sleep(2)
# Seek to X100, Y100
reprap.cartesian.seek( (100, 100, None) )
# Send all axies to home position. Wait until arrival.
reprap.cartesian.homeReset()
# Shut off power to all motors.
reprap.cartesian.free()`

Package Contents

``

baseplotters ffm gopython | hershey plugins preferences | reprap shapeplotter snap | toolpath wxpygame

Classes

``

axisClass
cartesianClass
extruderClass

class axisClass
`` | `Used to control a RepRap axis. X, Y & Z instances are automatically created in the reprap module, so for basic use just use reprap.cartesian.x, reprap.cartesian.y & reprap.cartesian.z rather than defining new ones. Most of the time the functions in reprap.cartesian will be sufficient. E.g. to move just one axis you can use: reprap.cartesian.seek((200, None, None))`

Methods defined here:

__init__(self, address)
  `Create an axis instance with address (1-255). Instances for the three axies are automatically created and can be accessed via reprap.cartesian.x, reprap.cartesian.y & reprap.cartesian.z
  These instances are pre-configured with the correct addresses and alow the use of whole machine reprap.cartesian commands.`

backward(self, speed=None)
  `Spin axis backward at given speed (0-255)
  If no speed is specified then a value must have been previously set with axisClass.setSpeed()`

backward1(self)
  `Move axis one step backward`

forward(self, speed=None)
  `Spin axis forward at given speed (0-255)
  If no speed is specified then a value must have been previously set with axisClass.setSpeed()`

forward1(self)
  `Move axis one step forward
  Return the completed state as a bool.`

free(self)
  `Power off coils on stepper`

getPos(self)
  `Return the axis postition as an integer.`

getSensors(self)
  `Debug only. Returns raw PIC port bytes)`

homeReset(self, speed=None, waitArrival=True)
  `Go to 0 position. If waitArrival is True, funtion waits until reset is compete to return`

seek(self, pos, speed=None, waitArrival=True)
  `Seek to axis location pos. If waitArrival is True, funtion waits until seek is compete to return`

setNotify(self)
  `Set axis to notify on arrivals`

setPos(self, pos)
  `set current position (integer) (set variable, not physical position)`

setPower(self, power)
  `Set stepper motor power (0-100%)`

setSpeed(self, speed)
  `Set axis move speed (0-255)`

class cartesianClass
`` | `Main cartesian robot class`

Methods defined here:

__init__(self)
  `Create a cartesian instance. An instances is automatically created and can be accessed via reprap.cartesian
  You will only need to create another one in you want to control more than one machine at the same time.`

free(self)
  `Free all motors (no current on coils)`

getPos(self)
  `Return the current positions of all three axies as a tuple (x, y, z)`

homeReset(self, speed=None, waitArrival=True)
  `Reset all axies to the home position with speed (0-255) and wait until arrival (boolean)
  WARNING : Reseting all axies at the same time is unstable. suggest using waitArrival = True option.`

seek(self, pos, speed=False, waitArrival=True)
  `Seek to a position ( tuple (x, y, z) ) with speed (0-255) and and wait until arrival (boolean)
  Seek will automatically select between a standard seek and a syncronised seek when it is required
  When waitArrival is True, funtion does not return until all seeks are compete`

setPower(self, power)
  `Set stepper power (0-100)`

setSpeed(self, speed)
  `Set axies move speed (0-255)`

stop(self)
  `Stop all motors (but retain current)`

class extruderClass
`` | `Used to control a RepRap thermoplast extruder. An instance is automatically created in the reprap module, so for basic use just use reprap.extruder rather than defining a new one`

Methods defined here:

__init__(self)
  `Create an extruder instance. An instance is automatically create at reprap.extruder.`

freeMotor(self)
  `Power off the extruder motor`

getTemp(self)
  `Returns current extruder temperature in degrees Celsius as an integer`

getVersion(self)
  `Returns (major, minor) firmware version as a two integer tuple.`

setCooler(self, speed)
  `Set the speed (0-255) of the cooling fan`

setMotor(self, direction, speed)
  `Set motor direction (reprap.MOTOR_BACKWARD or reprap.MOTOR_FORWARD) and speed (0-255)`

setTemp(self, temperature, lock=False)
  `Set the extruder target temperature (degrees Celsius). Lock is unused`

Functions

``

closeSerial()
  `Close serial port for SNAP RepRap communications`

openSerial(port=0, rate=19200, timeout=60)
  `Open serial port for SNAP RepRap communications`

scanNetwork()
  `Scan reprap network for devices (incomplete) - this will be used by autoconfig functions when complete`

testComms()
  `Test that serial communications are working properly with simple loopback (incomplete)`

Data

``

CMD_BACKWARD1 = 13
CMD_CALIBRATE = 9
CMD_DDA = 11
CMD_FORWARD = 1
CMD_FORWARD1 = 12
CMD_FREE = 6
CMD_GETDEBUGINFO = 54
CMD_GETMODULETYPE = 255
CMD_GETPOS = 4
CMD_GETRANGE = 10
CMD_GETSENSOR = 15
CMD_GETTEMP = 10
CMD_GETTEMPINFO = 55
CMD_HOMERESET = 16
CMD_ISEMPTY = 8
CMD_NOTIFY = 7
CMD_PRESCALER = 51
CMD_PWMPERIOD = 50
CMD_REVERSE = 2
CMD_SEEK = 5
CMD_SETCOOLER = 11
CMD_SETHEAT = 9
CMD_SETPOS = 3
CMD_SETPOWER = 14
CMD_SETVREF = 52
CMD_SYNC = 8
CMD_VERSION = 0
CMD__setTempScaler = 53
MOTOR_BACKWARD = 2
MOTOR_FORWARD = 1
SYNC_DEC = 3
SYNC_INC = 2
SYNC_NONE = 0
SYNC_SEEK = 1
UNITS_INCHES = 3
UNITS_MM = 1
UNITS_STEPS = 2
__author__ = 'Stefan Blanke (greenarrow) (greenarrow@users.sourceforge.net)'
__credits__ = ''
__licence__ = '\npyRepRap is free software: you can redistribute...ap. If not, see <http://www.gnu.org/licenses/>.\n'
__license__ = 'GPL 3.0'
__version__ = '2.0'
cartesian = <reprap.cartesianClass instance at 0x7f61b5917cb0>
extruder = <reprap.extruderClass instance at 0x7f61b5917c68>
printDebug = False

Author
`` |  | Stefan Blanke (greenarrow) (greenarrow@users.sourceforge.net)

Credits
`` |  |