21 Mar

Installing and configuring Pycupi

There has been some interest in Pycupi from the wider community so I figured an install/configuration guide might be handy.

IMG_7041 (2)

Tank Girl – v-plotter CMY (3 pass) Pycupi spiral arc render A2 Stabilo Point 88 Fineliner

First off this guide assumes you are using a configured Raspberry Pi that is running a recent version of Raspbian Jessie.

Prerequisites

Python should already be installed along with PySerial. However we still need the Pillow library for image processing.

From the command line run:

pip install Pillow

If that completes without error you can move on to the install.

Install

From the command line (and somewhere in your home directory) run

git clone https://github.com/brianinnes/pycupi.git

That will get Pycupi. Inside the Pycupi directory you will find an Arduino/Stepper directory which contains the firmware for the Eggbot/Spherebot/Polargraph controller. A Python directory which contains the core Pycupi program and test scripts. A testImages folder that contains a few images. And a wikiResources dir which contains stuff that lives on the wiki.

cd into the Pycupi/Python directory and run

python test1.py

which will probably throw an error complaining about the serial port. Thats ok, we needed to run this to have Pycupi create the default config. The default config lives in your users dir (/home/some_user/.polargraph/config.cfg). You will need to edit a few settings to match your machine before you can do any drawing.

Note: A semi-colon denotes a comment in the config file. Any line starting with a semi-colon will be ignored.

Under the [Polargraph] section, configure the following (any settings not mentioned here, which are present in the config should be left as default):

  • pensize – not currently implemented – will be ignored.
  • machinewidth – This should be set to the distance in mm between your pulleys.
  • machineheight – The physical height of you machine measured in mm from the centre of your pulleys.
  • mmperrev – The circumference of your pulleys (in mm) or how much chord or chain (in mm) is played out for each whole revolution of a pulley.
  • setsperrev – The number of steps your motors make in each whole revolution.
  • stepmultiplier – The step multiplier applied by your stepper drivers (Pycupi firmware defaults this to 8).
  • serialport – The serial port your stepper control board is attached to (/dev/ttyUSB0 on a RaspberryPi connected to the ‘Arduino Nano dual stepper board v2.1’).
  • motoraccel – A time value in seconds that determines how long it takes the motors to accelerate to their fastest speed.
  • motormaxspeed – The maximum speed the motors are allowed to move in mm/sec (needs confirmation).
  • penup & pendown – not currently implemented. Configuration angles for servo are set in the firmware.
  • homex – The home position in the (horizontal) x axis, measured in mm from the top left pulley. This position can be anywhere you like. Suggested value would be in the middle of your machine.
  • homey – The home position in the (vertical) y axis, measured in mm from the centre line of the pulleys (imaging a line drawn between the centre of the pulleys, homey will be some distance below this). This position can be anywhere you like. Suggested value would be 120mm down from the centre line, but will be dependant on your machine.

For a graphical representation of machine size measurements, see this post.

Under the [Paper] section you can define your paper size and its position.

An example A3 page would be as follows:

  • size = A3 – The name of the paper size.
  • width = 297 – Width in mm.
  • height = 420 – Height in mm.
  • posx = 175 – The position (in mm) from the left edge of your machine to the left edge of the paper.
  • posy = 240 – The position (in mm) from the top edge (centre line) of your machine to the top edge of the paper.
  • margin = 20 – A margin (in mm) around the edge of the paper where the machine will not draw (usually where you tape the paper to the machine). The specified margin will be applied on all sides of the page.
  • pixels = 3000 – The resolution for this paper in pixels.
  • rotate = false – If false the image is not rotated. If true the image will be rotated.

Under the screen section:

  • screenX = 5000 – The resolution the plot simulations will be. When generating simulations (bitmap images of a plot), you can specify a higher resolution that your final plot so you can see more detail to spot potential issues before running a plot.
  • showImage = false – not currently implemented.
  • saveImage = false – not currently implemented.

Now when you run

python test1.py

the machine should spring into life and draw a rectangle filled with smaller rectangles.