CNC Fusion 360 Postprocessor
-
I have looked for a Duet compatible CNC Postprocessor for a while now, and I am not happy with the ones I found. The grbl version was not good and the reprap version's gcode does not look very standard.
I have taken the reprap version and modified it to produce output that is more like I want it:
- Each line does exactly 1 thing. The reprap version sometimes combined a few commands into a single line (for example: "G28 G91 Z0" as a single line).
- Not using G28 so much. The reprap version sometimes produced 3x G28 commands in a few lines, which is simply not needed.
- Use ";" for Comment starts instead of brackets. I know brackets are acceptable, but in the other gcode I have read, a semi-colon is the start of a comment, so to make it easier on myself.
- Changed the Tool Change part. It started by using the tool number as defined in the tool library, for example it would have "T210" to change to tool number 210 in the library. I use a numbering scheme for my tools (allowing me to label each tool's storage location), but the machine does not need to know that. I force it to use T0, and instead adds a little bit more complicated script: It starts by stopping the spindle (at the current working coordinate origin), then using command M291, asks for the new tool to be inserted (press OK to continue), now it asks you to prepare for probing (again using M291, OK to continue), performs the probe (G30) and finally requests you to remove the probing gear (again M291, OK to continue) before continuing with the next section.
Currently it does not yet support arcs, though that is on my todo list. This is also not yet tested on my machine.
For some reason it does not always produce a G0 or G1 before the position. For example, the following is output from it:
G0 X131.51 Y-5.767 Z25.5 Z10.5 G1 Z2.54 F1000 X131.502 Z2.341 X131.479 Z2.143 X131.44 Z1.947
As you can see, the lines simply continue, specifying new X, Y or Z positions for the previous command (either G0 or G1). Does the RepRapFirmware understand this? I just want to know it is safe before trying it.
I was not yet able to post the cps file on a more permanent location (the cps file format is not supported here).
-
Lines that don't start with a G, M or T command won't be executed by RepRapFirmware.
-
@jacotheron said in CNC Fusion 360 Postprocessor:
I was not yet able to post the cps file on a more permanent location (the cps file format is not supported here).
I have added .cps as an acceptable file extension for uploads here on the forum.
-
I figured that it needs to start with G, M or T to be acceptable - seems there are controllers which does not need it, or maybe a gcode sender that can handle it.
I found that using
gMotionModal.format(N)
is the reason for this. If it is called with the same N, it simply don't output the GN. So I modified it to always output the G0 or G1 as needed.Regarding the Arcs, I tried by looking into other posts, and the ones I looked at support arcs in XY, XZ and YZ planes (Using G17-19 to define in which plane it is working). RepRapFirmware does not support the multiples planes, so for now in anyway, it uses the approximation linear technique (when setting up a new CAM Setup, you can specify the tolerances you need - good enough for my needs; this does produce a lot of segments, but compared to other controllers, the Duet is much more capable in handling these segments).
Other changes since Yesterday:
- WCS: if specified in Fusion 360 (or HSMExpress), it can change work coordinate offsets per section (allowing it to be set at the start, and simply run through without having to home).
- G28 calls: The original post I started with would regularly call G28 - much more than needed and if working with WCS, not something you might want; so I removed them.
- On Spindle Speed change, ask that the speed be changed and to what it should be changed (if you do not need this, you can comment out the relevant lines).
- Before ending the file, turn the spindle off.
Some possible feature request: Simply a way for M3 to turn it on, not speed related. In my setup, M3 switches a relay on, which in turn gives power to the externally speed controlled Makita spindle.
Since RepRapFirmwar does not yet support the coolant gcodes (M6 and further), these will not work, but support is included (original supported it). Note that this will be ignored. To control a vacuum and (later a coolant), I have simply made macros that turn the right output on and off in my setup (all controlled via relays). This is not a specific feature request for this - I believe there are more important things to focus on.
0_1539442267029_reprapduet.cps
I have uploaded my cps file here. This is not yet tested, but should work. I will test it early in the coming week and make changes as needed. This is Open Source for anyone to use as they see fit (modifications may be made and republished etc) - modified it to fit my needs. -
I have worked quite hard on getting my post-processor ready, but it works and is now tested in a multi-tool setup.
A few notes on my setup:
- The machine is based on the OC CNC design, with a footprint of 1.5x1.5m (actual working area of about 1.3x1.3m).
- The machine have 2 physical endstop switches (X and Y, located at the front right).
- Z have a motor load endstop for Z max (calibrated the StallGuard on the internal stepper drivers).
- 3 Relay Outputs, using E0, E1 and Heatbed connectors as the signal for relay modules (Spindle [10A relay], Vacuum [30A relay] and a not currently attached coolant fluid pump [10A Relay]). I have macros for all the relays, and the spindle is configured to be used with M3 and M5 (Start and Stop, respectively).
- Using M208, I allow movement of Z into the negative (I also made a Macro that will restrict Z to only be positive - reducing the chance of cutting into the wasteboard; though it should be noted that an out of bounds movement will terminate the job, firmware restriction).
- I make use of a simple CNC Z probe, similar to the ones at https://www.amazon.com/Setting-Engraving-Machine-Auto-Check-Instrument/dp/B074W58JHW/ - this is configured using
M558 P7 I1 F200;
andG31 Z19.25;
- the 19.25 is the height of my probe, you should change references to this and the 24.25 in my post to the values your probe have (after a G30 probe, the firmware raises the head by 5mm, 19.25 + 5 = 24.25 which exists in the post). - All heaters have been removed using the relevant config codes, so that they can be remapped to other outputs.
- Using
M453 P1 R17000
I setup my spindle to use the E0 output, with a maximum speed of 17000rpm (note that I send 17000rpm any time, since we control a relay that does not really like getting PWM signals). - I have a PanelDue attached to the machine, though using DWC will give you the same information and controls.
The Job setup process that I currently use is as follows:
- Home X Y and Z (finds the repeatable position as reference).
- Place the stock that we will be working with at a convenient location.
- Move the spindle to the stock origin (X and Y) and run the XY Origin Macro
- Move the spindle to a convenient location for probing - the gcode file will perform the probe. If you use Stock Top as your reference, this should be over the stock, if using the Stock Bottom, you will need to find a place where you can probe to your Stock Bottom (maybe that is on your wasteboard, so probe to the wasteboard).
- Start the job as a print. My post will Home Z (which goes to Zmax) and the display a message on the screen asking for the first tool to be inserted into the spindle (my code should prevent the spindle from turning on, but having a manual override, like the power switch on the spindle is a very good idea). Install the tool and press OK when done (if it is already installed, press OK to continue).
- Next a new message is displayed, asking you to attach the probe. The spindle should still be off and safe to touch. Attach the crocodile clips to the tool (please ensure your tools do conduct electricity, otherwise this will not work) and place the touch block below. Pressing OK will start the probe.
- After the probe completed, it will tell you to remove the probe - do so to avoid damage to the probe. The spindle should still be safe to touch.
- The next displayed message will give you the spindle speed which was set in Fusion or HSM, so that you can set your spindle to that speed (on the Makita RT0700C that I have, 17000 is around the nr 3 mark on its speed control). Before this message is displayed, the relay for the spindle is switched on. If the spindle is not turning, trouble shoot now (maybe the power switch is still off). After pressing the OK, the actual machining should start.
Any time there is a tool change, the above procedure will be repeated (switching the spindle off, asking for the new tool, preparing to probe, removing the probe and setting the speed). Could I have done it in less steps? Yes, but why. This ensures everything is safe and you don't forget something important (like attaching the probe's crocodile clip).
XY Origin Macro's contents:
G10 L20 P1 X0 Y0 ; Sets Current position as Origin with Z offset of the probe, for the 1st Work Offset.
I have used the post on a job now, with 4x mid-job tool changes (2x Drilling, Pocketing, V-Carving and Contour) and it worked beautifully and accurately. Since the X and Y remained the same, there were no need to home them between tool changes - only Z was homed and probed each time with a tool change (ensuring we know the position of the tip that does the work). This job came out with the only notable defect being that the wood was slightly bent and that caused the 2D Contour to not be through all around.
I will probably continue editing this post until I am completely happy, and as my needs change, but it works. For anyone interested, the latest is attached here 0_1539721340627_reprapduet.cps.
-
Great work! Thanks for sharing.
-
Latest update to my Post Processor:
0_1539947384124_reprapduet.cpsList of changes:
- Much more configurable without delving into its code - right in the Post Window of Fusion, you will get a list of options (my own are the default, but change them as you need and Fusion will remember them for you).
- Added more comments that can later be used when the firmware reads the file. I added: Generated By; Generated At (time); Settings Summary (selected material, stock size, number of sections/layers, Tool List); layer start comment before each section (currently this allows easier navigation and more details on the currently viewed file).
Configurable Options added:
- Probe Z Offset - this is the thickness of the probe + 5mm. G30 lifts the head by 5mm, which is where this 5mm comes from.
- Perform Probe - if this is true, a Probe will be performed after each tool change, using G30.
- Perform Manual Tool Change - if this is true, the machine will: go to a safe location, defined using other options; stop the spindle; Request you to change the tool to the defined tool; if set to probe, a probe will be performed; if set to manually set spindle speed, it will be allowed to be set, before continuing with the job.
- Manual Spindle Speed - if true, gives you time to set your spindle's speed to what was requested.
- Tool Change X Position - safe position where a tool change and probe can happen, relative to your job origin.
- Tool Change Y Position - same as for X.
- Spindle On Speed - used if manual spindle speed is true. When defining the spindle, one should define the speed at which it is fully on, not PWM - this is meant to be the same, useful for a relay.
- Makita Spindle - I use a Makita trimmer as my spindle, which have a dial of 1-6 speed settings; this adds the details of which setting to use for the requested speed (now I don't need the speeds table when figuring out what to use).
- Home Z Upwards - if true, it will Home Upwards for tool changes and other Safe retracts.
- Safe Z Height - if Home Z Upwards is false, this is used as a relative height (relative to your current origin).
-
Coincidentally I kind of did the same and also shared my post 5 days ago:
https://forum.duet3d.com/topic/7187/problem-with-setting-working-coordinate-systems/9
I run both of them on the same model and they produce very similar results. The only differences I found were the following (when the tool-probing is deactivated):
- Before the the first operation starts:
Jacotheron:
; layer 1
; (Slot1)
G28 Z
G0 X10 Y10
M291 P"Insert Tool #1 (Dia:10 )" R"Tool Change - Paused" S3 X1 Y1 Z1
M3 S17000
M291 P"28000 RPM (#5 ~26000-[27000]-29000)" R"Spindle Speed" S3 X1 Y1 Z1mine:
;SLOT1
M5 ;Makes sure the spindle is off before the tool change
T1 ;Call Tool 1
M3 S28000 ;Start Spindle at 28000RPM
G54 ;Set the working coordinate systemJacotheron homes the Z-aces first, not sure why. I think normally homing should not be part of a cnc-program. Further he added a tool-change position which can be defined in the fusion post parameters which makes a lot of sense. However I think it should be in absolute machine parameters i.e. something like G53 G0 X10 Y10. Further the max RPMs can be capped using a fusion post parameter which is also cool as well as the comments that are issued regarding the tool change. However I think adding M5 would not hurt as the spindle should be stopped before any tool-change. T1 is missing in my understanding as without calling it the tool-offsets are not set. This might be obsolete if you probe every during the tool change. However I prefer to measure all my tools in before starting machining using tool-offsets. And even when probing during the machining I think it would be more correct to set tool-offsets using M585. Finally I think the right WCS should be called as well.
- Before the second operation
Jacotheron:
; layer 2
; (2D Pocket1)
M3 S17000Mine:
;2D POCKET1The call of M3 S17000 is obsolete as the spindle is already running at the right speed from the first operation. However typically it also does not hurt.
-
Mine is rounding feeds to full numbers as Jacotheron is rounding to one decimal (F333 vs F333.3). Irrelevant...
-
At the end of the program:
Jacotheron :
;
G28 Z
G0 X0 Y0
M5
;%
Mine:
M5I don't understand why G28 Z and G0 X0 X0 should be called here. Adding a G0 X10 X10 (i.e. moving to the tool-change position) would make sense as the tool-change position typically moves the head to a safe place.
Looking at the post-code there are not too many differences as well. So merging the two posts together should not be to hard. I already have mine on github and would be open to do so...
Best regards,
Marc
- Before the the first operation starts:
-
Explaining a few of the differences found.
Homing Z:
For me this is to ensure that we are at a good location, should we need to change tools before the job starts.Using the tool change location as absolute parameters
This makes a lot of sense. I am very new to working coordinate systems and simply needed something that works. I figured using the position relative to where we probe, means it is close by for the manual tool change.Max RPMs being capped
Where do I find that setting in Fusion? In my setup, spindle speeds are simply meant as a guideline, and I have to manually set them. In the M453 command, parameter R is used to specify what speed should result in a full on spindle. I have set it at 17000, and to ensure that my relay does not get PWM when I need it to only be 10000, I have added that extra parameter, which will give the M3 command's S parameter as if it is at full speed, while letting me set it to what I really need.Wizard-style tool change
I might not always be the only person using my machine, so having the tool changes done as easy as possible and clear as to what needs to happen when was something I regarded as important.M5 before tool change
My code should have it in there. I believe it is only missing on the first section, since there is no need for the spindle to be on before that code is run. I like the spindle to only be on when it is actually about to do something.T1 being missing
I defined my tool as T0, which is called inside of the config.g setup file. It is always selected for me.Tool Offsets
Does your CNC have a tool pre-loader? It makes sense if it does. On mine, it is a simple Makita RT0700c trimmer everything is done manually and only a single tool at a time. For some of my jobs, I might have to ensure that the tool is sticking out longer than on other jobs (I know it is not optimal and one should try to get the tool as deep inside as possible, but sometimes I need that extra mm or 2).I still need to research the M585 and see how it changes how I do things now.
Right WCS being called as well
Before starting a job, I perform a full Home, then move the bit to the corner/edge that is used as reference point and set the WCS and XY origin using a macro. Then I start the job.M3 speed on each section
I decided it can't hurt. I have made it so that unless the requested speed is changed, or a new tool is installed, it won't pause the job and ask you to set the new speed.Roundings
This is simply code that was in the original post I started with. Should not really make any difference.Ending
That G0 should also have used the tool change position. For my machine, it homes Z upwards (Zmax), so homing it, ensures that we are safe and it should miss any and all fixtures that might otherwise be in its way.Merging the posts
You are welcome to merge my post into yours - as mentioned above, mine is simply open. Mine is simply my own attempt using my very limited knowledge and experience to get a post that I can use with good enough results. Before starting mine, I tried to find someone else's post to use, but did not find any, so I started learning how to do it. Now it works for me just fine, but if there is a better one, I will abandon mine for the better one. -
Thank you for working on this.
How has everything been working out, any issues with processor for fusion 360
-
@Adamfilip : The post is running very nicely for me for the last few month on various jobs (never had an unexpected behavior out of the post). I recently also put options in that can be selected from within the Fusion post menu for automatic or manual tool change, tool length measurement and re-homing between operations.
Just for completeness here again the link to the github repository:
https://github.com/mwinterm/fusion_post/tree/master/DuetCNC -
I have used this since posting it here, and it is working just fine for me. The issues I found were all user/operator error. If you get any issues, you are welcome to post about it and we can trouble shoot it.
To prevent unexpected behaviour, is the main reason why I explain exactly what I programmed it to do.
Just something to state again, this post does not do arcs (G2 and G3). While the latest firmware (at time of writing), allows one to configure the segments used for these arcs, I simply believe a computer is a lot faster and more precise in those calculations, and since the Duet can read extremely fast from the SD card, more G1 segments does not really affect its speed or quality negatively.
-
hi guys
I'm also develop Fusion 360 post processor. I had been designed for MPCNC and milling from SD card.
Initially it was for Marlin 2.0 only, later I had added Grbl 1.1.
So it's multi target now.
And now I have added RepRap Firrmware (based on Marlin target).
It supports:
manual spindle control or use M3/M5
manual tool changing + measuring the tool with G28 Z
laser mode with using M106/M107 or M3/M5 or M42
controlling of 2 channels of coolant
particular parts of gcode could be replaced by external files -
so if anyone interesting it is here
https://github.com/guffy1234/mpcnc_posts_processor -
@Guffy : nice work, thanks for sharing. Looks very clean, better than the Mach3 template I worked off from. I will eventually try to change to your PP....
-
hi guys
a step forward in the post processor.
i have decided to split the code of pp to 4 files
DIYCNC_Common.js – common code
DIYCNC_Grbl11.cps – code and properties specific to grbl
DIYCNC_Marlin20.cps – code and properties specific to marlin 20
DIYCNC_RepRapFW.cps – code and properties specific to reprap firmware
so now you will see 3 post processors in the Fusion drop down box instead of selecting target firmware in the properties.
as result there is much less messing of properties belong to different firmwares in the properties control -
I know this is an old thread, but just wanted to say THANKS!!! for the post processor. I just upgraded this machine from a mach3 controller and the first post processor I found scared the crap out of me. This ones behaves very nicely, thanks again.
Has anyone tried it with v-carve?
-
@Jacotheron if you save your macros to turn on and off the coolant and whatever as
/sys/M6.g
etc they will be executed as GCode commands. -
@oliof Awesome! Thanks again for the great work. I'm not a great coder so this saved me a ton of headache.
-
@dwak you may still want to peruse the documentation on metacommands so you get an idea how to enable your own codes with parameters
https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands