How to use the Gcode preprocessor (for complete newbies!)

How to use the Gcode preprocessor (for complete newbies!)

Postby Guizmo » Fri Feb 07, 2014 10:33 pm

Ok, like me, you just finished the assembly of your GUS machine, loaded the firmware to the Azteeg, generated some Gcode, installed Repetier and when you think you are ready to go, you realize GUS cannot work directly with cartesian coordinates. There is where Segmentize enters the work flow.

This is what you need to do in order to have the Gcode ready for GUS.
(There are multiple choices for software, but I'll list what I used)

1.- Download Segmentize. Go here: https://github.com/NicholasSeward/ConceptFORGE/blob/master/GUS%20Simpson/GCODE%20PREPROCESSOR/simpson%20segmentize.py, You will see this:
SegmentizeScreen.png
SegmentizeScreen.png (31.17 KiB) Viewed 19169 times


2.- Copy all the code (the image shows a partial selection) and paste it in a txt file. Then save it as Segmentize.py. Don't forget to change the file type to "all files". Save it to an easy to write directory, like C:\GUS\segmentize.py (I'll use this as an example, but you can choose any directory you want).

PS: You can increase the quality of the segmentation by reducing the segmentl length. Just find SEGMENT_SIZE=1 in the code and change the 1 default for the distance you need. Smaller size increases quality, file size and processing time and bigger size does the opposite. I tried .5 and the file size increased 8 times!. Experiment and have fun. Don't forget to save the file.

3.- Download Anaconda. This is a Scientific Python Distribution that has the modules needed for Segmentize to run. Probably there are lighter capable distributions but this is the one I found and worked well. Get it here: http://continuum.io/downloads. Select the version according to your OS.

4.- Install Anaconda. This is pretty straightforward.

5.- While Anaconda is installing, get the Gcode files you will convert and put them in the same directory as Segmentize.py.

6.- Once Anaconda is installed, run the Anaconda Command Prompt, selected in the image:

Anaconda.png
Anaconda.png (27.85 KiB) Viewed 19169 times


You will see this:

Anacondacmd.png
Anacondacmd.png (31.6 KiB) Viewed 19169 times


7.- To run Segmentize, write "python C:\GUS\segmentize.py" and press enter. The first time it will take some seconds to start. Then, it will ask for an input file. It has to include the directory, so write the route and name of your previously created Gcode file, like "C:\GUS\My_Code.gcode" and press enter. Don't forget the Gcode extension. Obviously, the file has to be already there.

Of course, instead of C:\GUS, you can have anything.

...
Last edited by Guizmo on Fri Feb 07, 2014 10:51 pm, edited 6 times in total.
Guizmo
 
Posts: 102
Joined: Tue Dec 03, 2013 3:10 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Guizmo » Fri Feb 07, 2014 10:34 pm

8.- Segmentize will ask an output file. Do the same as step 7, and don't forget the Gcode extension. This time, the file doesn't have to exist. If it does exist, it'll overwrite it.

9.- Wait some seconds and voila! Now you got your ready-for-GUS gcode file! You will see something like this:

Anacondacmdfinal.png
Anacondacmdfinal.png (47.25 KiB) Viewed 19168 times


10.- Now just use Repetier host to send the file to your GUS machine.

Happy printing! ;)
Guizmo
 
Posts: 102
Joined: Tue Dec 03, 2013 3:10 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby imrahil » Tue Feb 11, 2014 11:21 am

I have an error during conversion (Win7, Python 2.7.6)

Code: Select all
Traceback (most recent call last):
  File "simpson_segmentize.py", line 196, in <module>
    f2.write("G92 X0 Y0 Z0 E0\nG1 X-1000 Y-1000 Z-1000\nG28\n")
IOError: File not open for writing

IMHO it's because there is missing parameter "w" for line 54 - it should be:
Code: Select all
f2=file(sys.argv[2], "w")
imrahil
 
Posts: 68
Joined: Thu Dec 12, 2013 10:19 am

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Guizmo » Tue Feb 11, 2014 2:11 pm

Thanks for commenting Imrahil. I thought nobody was to, hehe. I'm no python expert, but I can tell you that I have no problem using the program as is, so this is strange. Perhaps Nicholas can comment on the issue.
Guizmo
 
Posts: 102
Joined: Tue Dec 03, 2013 3:10 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Nicholas Seward » Tue Feb 11, 2014 2:39 pm

That seems like the right fix. However, that should only happen if you are feeding it commandline args. How did you run the program?
Nicholas Seward
 
Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Niggle » Fri May 23, 2014 9:43 pm

Line 4 says
#EXPERIMENTAL. THIS CODE NEEDS IMPROVEMENT

Did you have any particular improvements in mind? I've been adding comments as I work out what the code is supposed to do, but I was wondering if you had functional changes in mind.
Niggle
 
Posts: 84
Joined: Tue Feb 11, 2014 7:27 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Nicholas Seward » Tue May 27, 2014 4:58 pm

Sure.

* The code doesn't give many hints to the user if something goes wrong.
* There is no tables yet for individual arm calibration to deal with bad spools.
* I use numeric methods that aren't guaranteed to produce anything much less the right result.
* Time needs to be spent to allow a slicer to automatically use this or to integrate this as a invisible preprocessor for the host. (I think Slic3r and Repetier already have provisions to make that easy to do.)
* This is slow even for Python because I had it do some dumb things just to make my life easier.
* Be smarter about what it does. This will crash with hand written Gcode. It already does some dumb stuff when it comes to G28s. (Basically, only segmentize G1's)
*This can't handle changes from absolute to relative positioning.

Blah, blah, blah. As you can see there are lots of problems. It is a wonder it works as well as it does.
Nicholas Seward
 
Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Niggle » Tue May 27, 2014 9:42 pm

I was thinking of working on
1. Separating calibration from segmentation - The calibration calculations only need to be done if the POINTS array changes. So, keep the array in a data file and store the results, with a time stamp, in another file. If the results file is newer than the points file, skip the calculations.

2. Change the gcode handling to
- write the output as it is generated, rather than caching it. I worry that gcode files can be huge and that program[] could grow too large for python to handle.
- pass comment lines through from the original gcode file
- convert the unsegmented gcode into a comment and insert it either before or after the segmented gcodes.
- if the original gcode has E0 skip the distance calculation for the step
- this implies a redesign of your gcode parser, so the result should be smarter :-)

3. Adding appropriate error and info messages (The coordinates currently output are not generally useful).

My copy is printing the shoulder heights and arm lengths on completion of the calibration step.

Repetier Host/Slic3r can already launch the script automatically, but I haven't found out how to pass the model name through to name the output file. I use a batch file instead but it is not a general solution.
Niggle
 
Posts: 84
Joined: Tue Feb 11, 2014 7:27 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby Nicholas Seward » Tue May 27, 2014 10:06 pm

All of that is great!

1) We can have a calibration file that only has user input values. We can have the calculated values output to a nice human readable file complete with the hash value of the the input file so it can skip the calculation routine if the stored hash value matches. (It would also be nice to allow users the choice to put in their own values for arm lengths, etc.)

2) Agreed. This would also allow for segmentize to be used in streaming mode. (For instance every command you give the host could be piped through a continually running Segmentize and the results could then be piped to the printer.

3) Agreed

Since, I use Segmentize for everything I do, it could stand to be thoroughly cleaned up and given the attention it needs. (I always get into making the machine and I have only worked hard enough on the software to get it running.)

I really love CURA for everything expect bridging. I am going to get familiar with the backend to see if I can piece what segmentize does right into it. I also want to play with nonplanar printing so I need to look at the backend for that already.
Nicholas Seward
 
Posts: 738
Joined: Mon Nov 25, 2013 10:41 pm

Re: How to use the Gcode preprocessor (for complete newbies!

Postby NeoTheFox » Wed May 28, 2014 8:26 am

own values for arm lengths


Yes, yes, yes! I've just pushed this feature, it would be so helpful to me, since I glued my eccentrics in order to stop them from rotating.
NeoTheFox
 
Posts: 92
Joined: Tue Jan 28, 2014 5:54 pm
Location: Moscow

Next

Return to GUS Simpson

Who is online

Users browsing this forum: No registered users and 1 guest

cron