RepRap and LinuxCNC

More
26 Oct 2016 12:08 #82081 by BigJohnT
RepRap and LinuxCNC was created 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.

reprap_filter
#! /usr/bin/env python
import sys
def main(argv):
	openfile = open(argv[0], 'r')
	file_in = openfile.readlines()
	openfile.close()
	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')
		file_out.append(line)
	for line in file_out:
		print "%s" % line

if __name__ == "__main__":
	main(sys.argv[1:])

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

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

JT
Attachments:
The following user(s) said Thank You: Rick G, Jbecerra, tommylight

Please Log in or Create an account to join the conversation.

More
17 Mar 2017 18:45 #89832 by yeltrow
Replied by yeltrow on topic RepRap and LinuxCNC
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:

M107
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. github.com/machinekit/machinekit/tree/ma...emap-subroutines/fdm
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.

Please Log in or Create an account to join the conversation.

More
20 Mar 2017 12:57 #89938 by andypugh
Replied by andypugh on topic RepRap and LinuxCNC
Is M104 perhaps being remapped so that the system no-longer recognised it as an old-style user-defined M-code?

Please Log in or Create an account to join the conversation.

More
20 Mar 2017 14:25 #89944 by yeltrow
Replied by yeltrow on topic RepRap and LinuxCNC
I think I may have discovered a documentation bug. linuxcnc.org/docs/html/remap/remap.html#...ration_for_remapping 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
M2

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
M2

That worked for me -- Thank goodness LinuxCNC threw a reasonable error message out!

Please Log in or Create an account to join the conversation.

More
20 Mar 2017 19:31 #89963 by yeltrow
Replied by yeltrow on topic RepRap and LinuxCNC
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.

Please Log in or Create an account to join the conversation.

More
20 Mar 2017 19:38 - 20 Mar 2017 19:38 #89964 by skunkworks
Last edit: 20 Mar 2017 19:38 by skunkworks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum