A Polar Pre-Processor for the Pen Bot Written in Python

I got a little push back on the Cartesian to Polar gcode processor because it was a Windows, Visual Studio C# program. I rewrote it in Python, to make it more accessible to other operating systems.

I don’t do much Python programming, so I probably did some thing in a very non Python style, but here is is.

Usage: The program will accept 1 or two command line arguments. The first is the file you want to convert. The second the the output file name.  If you skip the second, it will just append “_polar” to the input file name.  For example box.gcode will be converted and output as box_polar.gcode.

PolarPreProcessor.zip (python file)

Before and After Example GCode

Here is the gcode for the logo if you want to test.

Visual Examples

To get a feel for what the translation looks like, here is what a simple square looks like in gcode before translation.

And here is is after translation

Here is what that python logo in the first image looks like in gcode after translation.

Video

Here is a video of it drawing the Python logo.

 

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

8 Responses to “A Polar Pre-Processor for the Pen Bot Written in Python”


  1. Faizal Shaikh

    Brother thanks alot for this blog.
    can i get the GCODE which you have converted to polar via python?
    thanks again.

  2. bdring

    I added a link at the end of the post with some before and after gcode. The gcode draws a simple 40mm square centered on the coaster.

  3. Faizal Shaikh

    you mean to say “square_polar.gcode” is in form of GCODES but it works for polar printer.
    ???

  4. bdring

    The firmware is Grbl so it wants to see GCodes. It normally works in inches or mm, but ultimately that is just steps on the motor. This machine is designed to work in mm and degrees. The gcode starts out as normal cartesian mm coordinates. That needs to be converted to mm and degrees. As far as Grbl is concerned it is running normal gcode, but it has been processed to produce images on a polar machine.

    If this machine were to use unprocessed gcode, it would produce a distorted image. We therefore modify the gcode for an “anti” distorted image so it looks ok when printed on the machine.

  5. Faizal Shaikh

    i have taken a screenshot of your “square polar.gcode” file, where i can post that image?

  6. bdring

    The gcode in a viewer should look like four vertically linked arcs.

    You can email me at bdring@ this domain

  7. bdring

    Faizal,

    I have added some screen shots.

  8. Faizal

    Awesome!
    Thanks alot.
    And yeah for sure I will seek out for help from you.
    I am making 3d polar printer, so I have to look out for z axis increment too.
    Thanks alot for polar processor code.

*