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
Go to home position and set position counter to 0 (all axies)
reprap.cartesian.homeReset( speed, waitArrival )
Seek to location (all axies)
reprap.cartesian.seek( pos, speed, waitArrival )
Get position counters for all axies
reprap.cartesian.getPos()
Returns: Turple (x, y, z)
Stop all motors
reprap.cartesian.stop()
Returns: Nothing
Power off all motors
reprap.cartesian.free()
Returns: Nothing
Move axis one step forward
reprap.axis.forward1()
Returns: Nothing
Move axis one step backward
reprap.cartesian.[axis].backward1()
Returns: Nothing
Rotate motor forwards at given speed
reprap.cartesian.[axis].forward( speed )
Rotate motor backwards at given speed
reprap.cartesian.[axis].backward( speed )
Get port information
reprap.cartesian.[axis].getSensors()
Returns: PortA, PortB
Get position counter for axis
reprap.cartesian.[axis].getPos()
Returns: Position
Set position counter (set variable not robot position)
reprap.cartesian.[axis].setPos( pos )
Power off motor
reprap.cartesian.[axis].free()
Returns: Nothing
Seek to location
reprap.cartesian.[axis].seek( pos, speed, waitArrival )
Go to home position and set position counter to 0
reprap.cartesian.[axis].homeReset( speed, waitArrival )
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 Firmware Version from PIC
reprap.extruder.getVersion()
Returns: Major Version, Minor Version.
Set extruder motor rotating in given direction and speed
rreprap.extruder.setMotor( direction, speed )
Get
reprap.extruder.getTemp()
Returns: