# pyRepRap v0.1 Documentation

## Introduction

pyRepRap requires pySerial installed for this module to work. If you are using Fedora it is available on yum (run "sudo yum install pyserial").
pyRepRap is a python module that provides full control over the RepRap hardware. It is not intened as a replacement for the Java host software and I do not intend on writing any FDM code for the library. It is instead intended for anyone wanting to experiment with the RepRap hardware and find other uses for it. e.g. Plotting, 3D scanning, botany, electronics manufacture etc.
The reprap.cartesian object should provide most of the commands required, however the lower level reprap.cartesian.[axis] commands have been made available individual control of the axies is required.

### WARNING : The extruder code is experimental and incomplete, it will not accurately control the temperature and it is not reconmented that you activate the heater using this module.

## Example

This example moves the RepRap to the home position, then to several locations, then back to the home position.

    import serial, reprap, time							# Import the reprap and pySerial modules.
    reprap.serial = serial.Serial(0, 19200, timeout = reprap.snap.messageTimeout)	# Initialise serial port, here the first port (0) is used.
    reprap.cartesian.x.active = True						# These devices are present in network, will automatically scan in the future.
    reprap.cartesian.y.active = True
    reprap.cartesian.z.active = True
    reprap.extruder.active = True
    # The module is now ready to recieve commands #
    moveSpeed = 200
    reprap.cartesian.homeReset( moveSpeed, True )					# Send all axies to home position. Wait until arrival.
    reprap.cartesian.seek( (1000, 1000, 0), moveSpeed, True )			# Seek to (1000, 1000, 0). Wait until arrival.
    time.sleep(2)									# Pause.
    reprap.cartesian.seek( (500, 1000, 0), moveSpeed, True )			# Seek to (500, 1000, 0). Wait until arrival.
    time.sleep(2)
    reprap.cartesian.seek( (1000, 500, 0), moveSpeed, True )			# Seek to (1000, 500, 0). Wait until arrival.
    time.sleep(2)
    reprap.cartesian.seek( (100, 100, 0), moveSpeed, True )				# Seek to (100, 100, 0). Wait until arrival.
    reprap.cartesian.homeReset( moveSpeed, True )					# Send all axies to home position. Wait until arrival.
    reprap.cartesian.free()								# Shut off power to all motors.

This example can be found in demo.py
Further use of the module is demonstrated in example.py

## Cartesian Commands

### Home Reset

Go to home position and set position counter to 0 (all axies)
reprap.cartesian.homeReset( speed, waitArrival )

- speed - Speed to seek at. (0 - 255)
- waitArrival - If true then function will not return until the axis has reached its destination, if false the function will return once the command has been sent. (True / False)

Returns: Nothing

### Seek

Seek to location (all axies)
reprap.cartesian.seek( pos, speed, waitArrival )

- pos - Position to seek to. Turple (x, y, z)
- speed - Speed to seek at. (0 - 255)
- waitArrival - If true then function will not return until the axis has reached its destination, if false the function will return once the command has been sent. (True / False)

Returns: Nothing

### Get Position

Get position counters for all axies
reprap.cartesian.getPos()
Returns: Turple (x, y, z)

### Stop

Stop all motors
reprap.cartesian.stop()
Returns: Nothing

### Free

Power off all motors
reprap.cartesian.free()
Returns: Nothing

## Axis Commands

Replace [axis] with x, y or z. e.g. reprap.x.forward(100)

### Forward 1

Move axis one step forward
reprap.axis.forward1()
Returns: Nothing

### Backward 1

Move axis one step backward
reprap.cartesian.[axis].backward1()
Returns: Nothing

### Forward

Rotate motor forwards at given speed
reprap.cartesian.[axis].forward( speed )

- speed - Speed to rotate at. (0 - 255)

Returns: Nothing

### Backward

Rotate motor backwards at given speed
reprap.cartesian.[axis].backward( speed )

- speed - Speed to rotate at. (0 - 255)

Returns: Nothing

### Get Sensors (Debug only)

Get port information
reprap.cartesian.[axis].getSensors()
Returns: PortA, PortB

### Get Position

Get position counter for axis
reprap.cartesian.[axis].getPos()
Returns: Position

### Set Position

Set position counter (set variable not robot position)
reprap.cartesian.[axis].setPos( pos )

- pos - Position (16bit max?)

Returns: Nothing

### Free

Power off motor
reprap.cartesian.[axis].free()
Returns: Nothing

### Seek

Seek to location
reprap.cartesian.[axis].seek( pos, speed, waitArrival )

- pos - Position to seek to
- speed - Speed to seek at. (0 - 255)
- waitArrival - If true then function will not return until the axis has reached its destination, if false the function will return once the command has been sent. (True / False)

Returns: Nothing

### Home Reset

Go to home position and set position counter to 0
reprap.cartesian.[axis].homeReset( speed, waitArrival )

- speed - Speed to seek at. (0 - 255)
- waitArrival - If true then function will not return until the axis has reached its destination, if false the function will return once the command has been sent. (True / False)

Returns: Nothing

## Extruder Commands (Incomplete)

### Get Module Type

Get module type from PIC. #do pics not support this yet? I can't see it in code and get no reply from pic
reprap.extruder.getModuleType()
Returns: Module Type. (0 - 255)

### Get Module Version

Get Firmware Version from PIC
reprap.extruder.getVersion()
Returns: Major Version, Minor Version.

### Set Motor

Set extruder motor rotating in given direction and speed
rreprap.extruder.setMotor( direction, speed )

- direction - Direction to rotate in. (reprap.CMD_FORWARD / reprap.CMD_REVERSE)
- speed - Speed to turn at. (0 - 255)

Returns: Nothing

### Get Temperature

Get
reprap.extruder.getTemp()
Returns:

reprap.extruder.setHeat(lowHeat, highHeat, tempTarget, tempMax): reprap.extruder.setCooler(speed): reprap.extruder.freeMotor():