RepRap and LinuxCNC

26 Oct 2016 12:08 #82081 by BigJohnT
Many of you have 3D printers and I have recently acquired one. It's pretty cool but I'd rather use LinuxCNC to control my 3d printer. Slic3r has an option to output LinuxCNC G code but it is not perfect. Some of the M codes have a S option but LinuxCNC only has a P and Q option for M1xx commands. So I wrote a filter program to change the S to P when you load a file that ends with .gcode.

#! /usr/bin/env python
import sys
def main(argv):
	openfile = open(argv[0], 'r')
	file_in = openfile.readlines()
	file_out = []
	for line in file_in:
		if line.find('M104') != -1:
			if line.find('S') != -1:
				line = line.replace('S', 'P')
		line = line.rstrip('\n')
	for line in file_out:
		print "%s" % line

if __name__ == "__main__":

my .ini file changes
PROGRAM_EXTENSION = .gcode Reprap Filter
gcode = /home/john/linuxcnc/subroutines/reprap_filter

Of course you need to create the M104 and M107 files...

The following user(s) said Thank You: Rick G, Jbecerra, tommylight
17 Mar 2017 18:45 #89832 by yeltrow
I am attempting to configure LinuxCNC as a 3d printer. Anyone done this with success? If so, please share what you think the shortest path to getting there is. My biggest problem right at this moment is:

interp_error: P word with no G2 G3 ... or blah....blah... or user M code to use it.
This occurs right around:

M104 P200 ; set temperature
G28 ; home all axes
G1 Z5 F5000 ; lift nozzle

I have intentionally munged the REMAP= statements to verify that the m107 call is indeed getting remapped, but I get an error when I try an M107 from the MDI interface. This could be completely normal, but this is new territory for me. Should I be able to run a whole GCODE file one line at a time from the MDI interface?

I configured Slic3r to feed linuxcnc flavor gcode. I have borrowed a bunch of files from machinekit that perform the gcode and mcode remapping.
I had to comment out the [RS274NGC] block from the top to keep it from being a duplicate.
I commented out block for the file filters and FEATURES=4 line
I commented out the G22->G30 remapping lines until I figure out what they are doing.
20 Mar 2017 12:57 #89938 by andypugh
Is M104 perhaps being remapped so that the system no-longer recognised it as an old-style user-defined M-code?
20 Mar 2017 14:25 #89944 by yeltrow
I think I may have discovered a documentation bug. I have been going through the documentation for remapping M-codes. In the example it has:

REMAP=M400 modalgroup=10 argspec=Pq ngc=m400

In a file named myprocedure.ngc, the example has this:
o<m400> sub
(P is required since it's uppercase in the argspec)
(debug, P word=#<P>)
(the q argspec is optional since its lowercase in the argspec. Use as follows:)
o100 if [EXISTS[#<q>]]
(debug, Q word set: #<q>)
o100 endif
o<m400> endsub

I get an error "EOF in file:/home/myusername/linuxcnc/nc_files/myprocedure.ngc seeking o-word: o<myprocedure> from line: 0"
Should the example instead read like below where I swapped "m400" for "myprocedure"?

o<myprocedure> sub
(P is required since it's uppercase in the argspec)
(debug, P word=#<P>)
(the q argspec is optional since its lowercase in the argspec. Use as follows:)
o100 if [EXISTS[#<q>]]
(debug, Q word set: #<q>)
o100 endif
o<myprocedure> endsub

That worked for me -- Thank goodness LinuxCNC threw a reasonable error message out!
20 Mar 2017 19:31 #89963 by yeltrow
Why is it that if I remap M404 to use m104.ngc, I can call it as expected, but if I try to remap M104, it acts as if it doesn't exist? In my ini file I had this and it didn't work:
REMAP=M104 modalgroup=10 argspec=iPt ngc=m104

but this DID work:
REMAP=M404 modalgroup=10 argspec=iPt ngc=m104

I typed M104 P100 and M404 P100 respectively to test it.
20 Mar 2017 19:38 - 20 Mar 2017 19:38 #89964 by skunkworks
Last Edit: 20 Mar 2017 19:38 by skunkworks.
Moderators: Rick G
Time to create page: 0.139 seconds
Powered by Kunena Forum