Welcome! Log In Create A New Profile

Advanced

How to print Gcode from Host

Posted by redskinsjbs 
How to print Gcode from Host
April 03, 2008 04:50PM
As most of you know, Chris Meagan has created another GUI to control the printers using Gcode. [forums.reprap.org] My question is: How to you get the host to print out Gcode so that you can import it into Chris's GUI?


J Sweezy Sincerely
Re: How to print Gcode from Host
April 03, 2008 07:17PM
I do not know how to get the host to print out Gcode, however, you can print out gcode with the Art of Illusion script Skeinforge, which used to be called Threadforge and was Export Slices before that. It is at:
[members.axion.net]

To use it, put the file into the Art of Illusion tools folder in the scripts folder. Then turn your shape into a triangle mesh, select it and choose Skeinforge from the Scripts menu in the Tools folder, then click OK.

Below is a gcode excerpt from Skeinforge. Below that is the excerpt after comments were added by Skeinforge, a related gcode viewer and analyzer, which is at:
[members.axion.net]

Unfortunately, I don't have documentation for these scripts yet, but they work well enough.

Cheers,
Enrique


( GCode generated by March 29,2007 Skeinforge )
( Extruder Initialization )
M100 P210
M103
M104 P145.0
M105
M106
M108 P0.8
G21
G90
G28
( Extruder Movement )
( Extruder paths for layer 0 of Hollow Square )
M101
G1 X-2.935 Y1.84 Z0.376 F600.0
..
many lines of gcode
..
G1 X-4.931 Y-2.349 Z1.124 F600.0
M103
( Extruder Shut Down )
M103
M104 P0
M107


Gcode after comments were added by Skeinforge, a related gcode viewer and analyzer, which is at:
[members.axion.net]

( GCode generated by March 29,2007 Skeinforge )
( Extruder Initialization )
( Set extruder speed to 210.0. )
M100 P210
( Turn extruder off. )
M103
( Set temperature to 145.0 C. )
M104 P145.0
( Custom code for temperature reading. )
M105
( Turn fan on. )
M106
( Set extrusion diameter to 0.8 mm. )
M108 P0.8
( Set units to mm. )
G21
( Set positioning to absolute. )
G90
( Start at home. )
G28
( Extruder Movement )
( Extruder paths for layer 0 of Hollow Square )
( Turn extruder on. )
M101
( Linear move to Vec3: -2.935, 1.84, 0.376. )
G1 X-2.935 Y1.84 Z0.376 F600.0
..
many lines of gcode
..
( Linear move to Vec3: -4.931, -2.349, 1.124. )
G1 X-4.931 Y-2.349 Z1.124 F600.0
( Turn extruder off. )
M103
( Extruder Shut Down )
( Turn extruder off. )
M103
( Set temperature to 0.0 C. )
M104 P0
( Turn fan off. )
M107
Re: How to print Gcode from Host
April 04, 2008 12:56PM
redskinsjbs Wrote:
-------------------------------------------------------
> As most of you know, Chris Meagan has created
> another GUI to control the printers using Gcode.
> [forums.reprap.org] My
> question is: How to you get the host to print out
> Gcode so that you can import it into Chris's GUI?

yo, currently i've done the gcode stuff in a branch of the host software. its located in my subversion directory:

[svn.reprap.org]

once you do that, there are a couple parameters you'll need to set in your reprap properties file:

GCodeUseSerial=true (false = writes to a file)

these control the speed of your print head
MaximumFeedratehot smileymm/minute)
MaximumFeedrateY(mm/minute)
MaximumFeedrateZ(mm/minute)
Extruder0_XYFeedrate(mm/minute)

finally, set the 'Geometry' parameter to 'gcodewriter'.

Geometry=gcodewriter

My goal this weekend is to get the changes put back into trunk. I'll make a post when I do that.
Re: How to print Gcode from Host
April 12, 2008 04:49PM
Hi Enrique,
I tried out your scripts but there seems to be a bug which leaves bits of slice missing. Here is the extruder screw holder sliced, the slices should be symmetrical :-



I have also attached the original file.

Regards, Chris


[www.hydraraptor.blogspot.com]
Attachments:
open | download - screw-holder.aoi (291.7 KB)
Re: How to print Gcode from Host
April 13, 2008 08:42AM
I made a script to convert gcode to animated gifs for previewing slice and dice algorithms:



It seems that you need to click on the image to see the animation for some reason.

Edit: added a colour change for each new filament segment

Edited 2 time(s). Last edit at 04/13/2008 10:55AM by nophead.

[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 13, 2008 04:28PM
That is so cool. Could you by any chance make some sort of very basic GUI and upload it here? That way I'd be able to preview what I am going to do using Chris Meigan's (Sorry if that is misspelled) Software. If not could you upload the script with some short directions or notes on how it works? What language is it? And one more question, why is the last slice incomplete?

BTW: That Gif is now my new screensaver.


J Sweezy Sincerely
Re: How to print Gcode from Host
April 14, 2008 12:35AM
Hi Nophead,

Thanks for trying out Skeinforge and posting the bug. I traced it to a new feature to connect paths to reduce the number of times the extruder turns on and off. So I disabled that feature and the script is now working well enough, again. The April 13 reverted version is at:
[members.axion.net]

Over the next few weeks, I plan to bring back that feature and add more stuff.

Cheers,
Enrique
Re: How to print Gcode from Host
April 14, 2008 02:47PM
Hi Enrique,
Thanks for writing it. It looks like you really know your 3D stuff.

I ran it again and it looks correct now. I should be able to get my machine to make something with it.



Unfortunately the time it takes to run goes up to nearly three hours when I set the filament to 0.5mm compared to 45 minutes for 0.8mm. I will have to get a faster PC!

BTW, why are the corners rounded when the model has square corners?

Here is the RepRap host version for comparison.



It is harder for me to use because it has some machine specific things in the gcode.


[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 14, 2008 02:57PM
Hey Nophead--

Could you upload that script you made?


J Sweezy Sincerely
Re: How to print Gcode from Host
April 14, 2008 03:17PM
Hi Jay,
I got the idea of using animated gifs from your avatar!

The script is written in Python, I just pinched some lines from Enrique's extrude.py and a file I found on the web called gifmaker.py. Most of the work is done by the Python Image Library. It would be very easy to add a GUI with Tkinter, which I may well do.

At the moment I have one script for Enrique's gcode and another for ReRrap's. This is mainly because with Enrique's I use an increase in z to start a new frame but RepRap lifts the head between segments. It has interlayer cooling so I use 'fan on' to trigger the new frame.

I have attached the scripts if you want to have a play. They are just a complete hack at the moment, hard coded image dimensions, etc, very ugly. They are a good example of how easy and productive Python is though.


[www.hydraraptor.blogspot.com]
Attachments:
open | download - Enrique.py (4.8 KB)
open | download - reprap.py (5.2 KB)
Re: How to print Gcode from Host
April 14, 2008 03:33PM
This stuff is Great!

I'll be goofing around with this for a while now.

Also, I am proud to see that another one of my extraneous goofs inspired some real, actually productive work!


J Sweezy Sincerely
Re: How to print Gcode from Host
April 14, 2008 09:11PM
Hi Nophead,

Yup it's real slow. There's no optimization and the beanshell script language is even slower than python. I might start optimizing in a few months after I finish the program, but my software wish list grows faster than I can codesmiling smiley

Skeinforge uses intersecting circles to slice the STL, and inset & outset the resulting polygons. The nice thing about intersecting circles is that they create smooth loops from anything. The downside is that when insetting, they make smooth loops, even if the original loop was sharp.

I added a fan off command when ending the layer and fan on (M106) when starting, so hopefully reprap.py script will be able to handle gcode from Skeinforge. There's already a reprap.py in Greenarrow's pyRepRap code. I'm trying to match current reprap gcode, but I haven't been able to run reprap host yet so I'm matching the old versions of reprap gcode which are online. I assume the command is fan off when ending a layer and fan on when starting a new layer, if it ain't or there are other differences, please post what it is and I'll switch my code.

By the way, thanks for mentioning that the infill has to stretch around the perimeter or the next hatch falls through. Skeinforge stretches the edges of sparse infill, which gives the path the wedge look on large sections.

E
Re: How to print Gcode from Host
April 14, 2008 11:22PM
Hi Enrique,
The RepRap code does not run the fan while it is extruding. It puts the fan over the workpiece and cools it for 40 seconds turns it off for 8 seconds. Between segments it homes, turns the extruder on for a second, then moves to the workpiece. Please don't emulate this stuff, I am trying to work out how to filter it out! I extrude with the fan running and don't have pauses between layers.

IMHO, Gcode is not really the right format for output from slice and dice because you have to put all the details of how the machine works, e.g. nozzle wiping, which varies from machine to machine, e.g. Darwin moving head, Seedling moving table. I think it would be much better to output xml from slice and dice and then have different python scripts which know about the machine to convert that to machine actions in gcode or whatever the machine eats.

In the short term I will make a script which imports gcode and reduces it to a list of layers having a list of filament paths. From that data I will be able to preview it on screen, make animated gifs or control my machine. All the details like lifting the head on moves, controlling the fan, wiping the nozzle, feed rates, temperatures and making rafts will be in my machine controller rather than adding it all to Skeinforge and having to re run it to change anything. All slice an dice needs to know is the filament size and aspect ratio, etc. Otherwise you would be forever having to change it to catch up with machine development.

Yes I noticed the wedge infill. It effectively makes the skin two filaments thick which is probably a good thing for strength. An option to set skin thickness would be a good idea. You can make objects with say 1 or 2mm skin and then very sparse infill. The results can be still be very strong.

It will be interesting to see what effect the rounded corners have. In practice the filament follows a curve anyway.

I think there is a slight bug in that you turn the extruder on one line too early, but does not really effect me. When I see extruder on I convert the next G1 to a red line as it is moving to the start of the filament run rather than being part of it.

Hopefully I should be making objects this evening, thanks to your script.

Regards, Chris

Edited 1 time(s). Last edit at 04/15/2008 12:49AM by nophead.

[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 15, 2008 01:13AM
Hi Nophead,

The fan code is now commented out.

I'm glad you don't want the slice and dice program to determine nozzle wiping and stuff, I wasn't looking forward to coding thatsmiling smiley

Fillet.py parses and writes gcode, so it would be a good model for your script to convert gcode to machine actions.

Yup, there was a bug where I turn on the extruder one line early. It's now fixed, I believe it was from yet another improvementsmiling smiley

Good luck on the evening build. You're the first person to use Skeinforge to build stuff, so you'll probably have to tweak the following parameters:

Extrusion density (ratio)
Which is how dense the overall extrusion is. It should be more than pi/4 and less than 1.0.

Extrusion Width over Thickness (ratio)
This is how wide the extruded filament is compared to the height.

Fill Perimeter Overlap (ratio)
This is how much the infill and perimeter overlap. Too little and the infill will not connect to the perimeter, too much and you'll get blobbing.

Cheers, E
Re: How to print Gcode from Host
April 15, 2008 01:36AM
Enrique,
Extrusion density is the only one I don't have an equivalent of. I just assume that the squashed filament is an elipse which works pretty well but I can convert that into density easily enough. Actually for slice and dice I think you only need height and width rather than diameter, density and aspect ratio.

Regards, Chris


[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 15, 2008 02:55AM
Yup, you only need height and width, and internally that is what skeinforge uses. However, I have height and width input as a ratio because they are both dependent on the diameter. For example, say with a nozzle diameter of 1 mm, you find the build is best with a height of 0.8 mm and width of 0.9 mm. Then you switch to a 2 mm nozzle, if you only had height and width inputs, you would have to change the height and width. With a diameter input, you only have to change the diameter, the ratios stay the same and you have one less number to changesmiling smiley

And ah yes, yet another bug fixed. This was a bug where it stopped and started extrusions for no good reason. The latest version, 16-Apr-2008, has that fixed and is uploaded.

I'm glad you're using my program and that you're handling the nozzle wipe, head lifting, rafts and who knows what else. I won't be adding that stuff because I've never even seen an extruder in action.

Enrique
cool smiley

Addendum:
Oops, yet another bug fixed. This was a bug where it sometimes printed the inside before the outside. The latest version, 16.13-Apr-2008, has that fixed, is uploaded and attached to this post. In future, I'll attach stable versions to postings in case the file at:
[members.axion.net]

has a bug.


Addadendum:
The last bug fix added the sometimes take the long way round bug. The latest version, 16.14-Apr-2008, has that fixed, is uploaded and attached.

Edited 2 time(s). Last edit at 04/15/2008 12:27PM by Enrique.
Attachments:
open | download - Skeinforge.bsh (107.3 KB)
Re: How to print Gcode from Host
April 16, 2008 10:45AM
Enrique,
I made an object from your script with PCL last night and it basically works :-





It's a bit hairy but not bad for a first attempt. There are a lot of things I can do to improve the turn on an off of the filament flow.

This is probably the first RepRap object made with sparse fill. Not really appropriate for this size object in this material but seems to work.

It is too tall but that is an error I made.


[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 16, 2008 11:43AM
smileys with beer

Wow, except for the hair, the build quality looks good. Over the next few weeks I'll try to keep the extruder within the shape to get rid of some of the hair.

If you had to change the "Extrusion Density" or "Extrusion Width over Thickness" ratios, please post or email em and I'll change the defaults, which were guessed.

I took out all the fan and temperature commands from the skeinforge generator. I added a new layer command (M109), just to tell viewers that a new layer is coming up, it is to be ignored by extruders. The new gcode with comments is pasted below.

Cheers,
Enrique


( GCode generated by April 16, 2007 Skeinforge )
( Extruder Initialization )
( Set extruder speed to 210.0. )
M100 P210
( Turn extruder off. )
M103
( Custom code for temperature reading. )
M105
( Set extrusion diameter to 0.8 mm. )
M108 P0.8
( Set units to mm. )
G21
( Set positioning to absolute. )
G90
( Start at home. )
G28
( Extruder Movement )
( Extruder paths for layer 0 of Hollow Square )
( New layer is starting. )
M109
( Linear move to Vec3: 1.687, -5.164, 0.376. )
G1 X1.687 Y-5.164 Z0.376 F600.0
( Turn extruder on. )
M101
( Linear move to Vec3: -4.677, -5.164, 0.376. )
..
many lines of gcode
..
( Extruder Shut Down )
( Turn extruder off. )
M103
Re: How to print Gcode from Host
April 16, 2008 02:22PM
Enrique,
Yes keeping the moves over the previous layer would be a big improvement but obviously not always possible. I think the RepRap host turns the extruder off before the end of a run and then returns to home before turning it on again. I can try those sorts of tricks, reversing the extruder, using the longer nozzle and the main blog has an idea for a valve which should make a dramatic improvement.

One thing I think is slightly wrong is that I think you need to switch from sparse to solid for at lease two layers at the surface, not just one. Otherwise you get small holes into the interior so objects are not watertight.

Yes I did change the settings but I will let you know when I have played around a bit more.

I actually only process G1 coordinates and M103 to tell me the end of a run. I use a change in Z to detect a new layer. I store the data as a list of layers which are lists of threads which are lists of vec3's. That is the only info I need from slice and dice I think, which I why I don't think G code is ideal. You have to put in feed rate for instance in the G1 but that is not relevant at that stage.

Still it works fine at the moment and is trivial to parse but I need a slighly different parser to process the RepRap gcode. The reason is the gcode loses the logical structure: layer, thread, point and I have to rebuild that using tricks.

Great script though, it has saved me a lot of work and I can now make objects with about 100 lines of Python.

Thanks, Chris


[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 16, 2008 04:54PM
Enrique,
I think it would be better to do internal outlines before infill. Otherwise the zig-zags have nothing to stick to so they like to shrink back.

Edited 1 time(s). Last edit at 04/16/2008 05:26PM by nophead.

[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 16, 2008 06:32PM
Nophead,

I disabled joining outlines to infill, and the outlines are now printed first. The only downside is that there will be more hair.

The number of "Solid Surface Layers" is now a preference, and the default is two. While changing that, I noticed a now squashed occasional overlap bug. Seeing as how the object printed anyway, it seems extrusion is really forgiving of overlap.

I don't know if a feedrate command on every G1 line is needed, I just include it to be on the safe side since that was in the reprap gcode example. Adding the new layer command (M109) helps logical structure. The viewers and extruders can guess when a new layer is coming because of height difference now, but if we go to true 3D printing they could get confused, so I want to reserve the command word nowsmiling smiley

I earlier incorrectly wrote that the viewer & analysis script was called Skeinforge, when actually it is Skeinview, and is at:
[members.axion.net]

I'm glad you're using the script, besides that it feels good to help reprap, because up to now I've been programming blindlygrinning smiley

Enrique
Attachments:
open | download - Skeinforge.bsh (107.8 KB)
Re: How to print Gcode from Host
April 17, 2008 11:22AM
Enrique,

I think there may be a bug in this one. It looks like it doesn't switch to 100% fill on the top surface of the base of this object.




[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 17, 2008 06:22PM
Hi Nophead,

Oops, sorry about the surface bugsad smiley and thanks for finding the now squished bugsmiling smiley The one less bug April 17.17 Skeinforge is uploaded and attached to this post.

In this update I also added the M109 command to set extrusion width and M110 for layer thickness. They are useful for analyzers and fillet, but are to be ignored by extruders. The new commented initialization code is at the bottom of this post.

For future reference, the way Skeinforge calculates extrusion width and thickness follows:

squareSectionWidth = extrusionDiameter * Math.sqrt( Math.PI / extrusionFillDensity ) / 2.0;
extrusionWidthOverThicknessSquareRoot = Math.sqrt( extrusionWidthOverThickness );
extrusionWidth = squareSectionWidth * extrusionWidthOverThicknessSquareRoot;
layerThickness = squareSectionWidth / extrusionWidthOverThicknessSquareRoot;

Because of the new command numbers and because I'm planning on adding a couple more commands, the M109 New Layer command has been changed to M113.

Enrique


( GCode generated by April 17,2007 Skeinforge )
( Extruder Initialization )
( Set extruder speed to 210.0. )
M100 P210
( Turn extruder off. )
M103
( Custom code for temperature reading. )
M105
( Set extrusion diameter to 0.7 mm. )
M108 P0.7
( Set extrusion width to 0.654 mm. )
M109 P0.654
( Set layer thickness to 0.654 mm. )
M110 P0.654
( Set units to mm. )
G21
( Set positioning to absolute. )
G90
( Start at home. )
G28
( Extruder Movement )
( Extruder paths for layer 0 of Hollow Square )
( New layer is starting. )
M113
Attachments:
open | download - Skeinforge.bsh (107.8 KB)
Re: How to print Gcode from Host
April 18, 2008 10:24AM
This is really impressive, I haven't been following reprap as closely lately because I've been away, I hadn't realised this much progress had been made with gcode / reprap. Is Chris's gcode generating program based on Adrian's algorithms?

This kind of software setup will work much better for me as I can process object on my desktop PC, then plug my reprap into an much less powerful tablet PC in the shed and leave it to print.
Re: How to print Gcode from Host
April 18, 2008 03:04PM
greenarrow,

Skeinforge, the gcode generating program is based on Adrian's description of reprap insetting, but the algorithm is actually based on intersecting circles, rather than polyhedrons. A few months ago, I wrote Adrian than an Art of Illusion script might be able to slice imported stl and if that'd be useful, and he said yes so I started writing Skeinforge.

Skeinforge is written in the Art of Illusion beanshell java based scripting language which is actually several times slower than python. The reason I wrote it in beanshell is because Art of Illusion has a good stl import plugin and because Art of Illusion itself can display the extruder paths. Over time, I'm hoping to break Skeinforge up into smaller pieces and port those to python.

Chris' python scripts handle the extruder itself, nozzle wiping, head lifting, building the raft, etc.. He also wrote code the Enrique.py and reprap.py gif animators to view gcode. All the animated extrusion images on this thread are from those programs. Also he's finding bugs in Skeinforge and explaining how the extrusion process actually works, so I no longer have to program blindly.

Cheers,
Enrique
Re: How to print Gcode from Host
April 18, 2008 03:39PM
Enrique,
Does running inside AOI have any advantage? It is actually very easy to parse STL with Python (I haven't found anything that is hard in Python yet). There is a Python script called cam.py that does it, both binary and text, in 73 lines.

BTW perhaps we should start a new thread, this has become how to print G code not from the host!

Chris


[www.hydraraptor.blogspot.com]
Re: How to print Gcode from Host
April 18, 2008 04:01PM
Re: How to print Gcode from Host
April 19, 2008 11:44AM
Enrique, Chris,
Thanks, I was a little confused as to who had done what before but I'm very clear on it now.
I've just tried out the script 'Skeinforge.bsh' but unfortunately its giving me errors, I tried it with a single cube converted to triangle mesh incase it was a problem with my object but it still came up with errors. Are there some settings I should be filling in before clicking ok?
Attachments:
open | download - scripterrors.txt (6.3 KB)
Re: How to print Gcode from Host
April 19, 2008 07:08PM
greenarrow,

Thanks for posting the printout, but unfortunately beanshell gives long but uninformative error messages, and often like in this case does not even give the line numbers, so I do not know what the problem is. I'll be happier when the whole shebang is ported to pythonsmiling smiley

In theory only the weirdest settings would even be able to crash the program, so it's probably a problem with the program itself. Attached is the Hollow Square test shape, and the version of Skeinforge that I'm now using and that I just tested with Hollow Square. If the latest version does not work, then you might just have to wait for the python version, which is at least a few weeks awaysad smiley

Nophead

By the way, could you please post your simulator script or a link to it?

Cheers,
Enrique

Edited 1 time(s). Last edit at 04/19/2008 07:31PM by Enrique.
Attachments:
open | download - Reprap Hollow Square.aoi (2.7 KB)
open | download - Skeinforge.bsh (112.8 KB)
Re: How to print Gcode from Host
April 20, 2008 11:58AM
Enrique,
I am in the middle of rewriting it so that it displays the same images as the gifs. I will publish it soon.


[www.hydraraptor.blogspot.com]
Sorry, only registered users may post in this forum.

Click here to login