CNC Lathe and 4th-axis milling...

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Russ4262
Posts: 598
Joined: Sat Jun 30, 2018 3:22 pm

Re: CNC Lathe and 4th-axis milling...

Postby Russ4262 » Thu Apr 11, 2019 4:06 pm

Good morning.
So, the FC addiction is pretty bad...
Wsk8 wrote:
Tue Apr 09, 2019 5:34 pm
Hope you find some time for this feature. That would be great!
I had an idea and ran with it. After the third revision, this is the trial run for adding 4th axis to the standard PathPocket tool in PathWB.
PathPocket-4th-axis_trial-C.png
4th axis path pocket, trial C
PathPocket-4th-axis_trial-C.png (119.62 KiB) Viewed 623 times

Wsk8 wrote:
Tue Apr 09, 2019 5:34 pm
If you make changes to your script, how do you reload it in FC for testing? Is there a console command?
I have been restarting FC, every time. This takes a lot of time. However, I ran across a search result for "reload module" in the FC forum, or a general web search related to python.

This is looking fantastic ! I still have to adjust depth calculations. Current version has rotation available on either X or Y axis, but not both.

Cheers!
Russ
Last edited by Russ4262 on Fri Apr 12, 2019 11:27 am, edited 1 time in total.
RatonLaveur
Posts: 825
Joined: Wed Mar 27, 2019 10:45 am

Re: CNC Lathe and 4th-axis milling...

Postby RatonLaveur » Thu Apr 11, 2019 4:47 pm

Russ you are a machine,

This looks so good I'm almost sad to be off my laser until tomorrow.
chrisb
Posts: 30758
Joined: Tue Mar 17, 2015 9:14 am

Re: CNC Lathe and 4th-axis milling...

Postby chrisb » Thu Apr 11, 2019 5:18 pm

Sorry, I had missed your question above. This is how I reload the module 'generic_post.py'

Code: Select all

import generic_post
from importlib import reload
reload(generic_post)
The last command can be executed repeatedly to reload again.
You need at least FreeCAD 0.19.23300 to edit my current sketches.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
jmr
Posts: 32
Joined: Fri Feb 09, 2018 3:32 pm

Re: CNC Lathe and 4th-axis milling...

Postby jmr » Thu Apr 11, 2019 7:30 pm

Hey Chris,
I ran into situations where it does not reload. Is there a limit to what can be reloaded? I believe that was mostly when I was modifying the InitGui.py, but it also happened with postprocessor or things inside PathScripts. It seemed to reload correctly, however the changes were not running (I checked by adding stuff to print 'xxx'). Is that for not using "from importlib import reload", or that is ok if it does not cause command not found? To restart the program did not fail me, but that is quite time consuming.

This escalated quickly. I seriously need to try this script. Too bad i'm busy now.
User avatar
sliptonic
Posts: 2081
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: CNC Lathe and 4th-axis milling...

Postby sliptonic » Thu Apr 11, 2019 7:51 pm

Russ4262 wrote:
Thu Apr 11, 2019 4:06 pm

So, the FC addiction is pretty bad...
It's not so bad. We'll start a twelve step program soon :lol:
I had an idea and ran with it. After the third revision, this is the trial run for adding 4th axis to the standard PathPocket too in PathWB.
This is very cool. It looks like you and mlampert are thinking along the same lines.
Take a look at his branch here:
https://github.com/mlampert/FreeCAD/tre ... e/4th-axis

I have been restarting FC, every time. This takes a lot of time. However, I ran across a search result for "reload module" in the FC forum, or a general web search related to python.
I do this in the python console:
>>> import PathScripts.PathSurface
>>> reload (PathScripts.PathSurface)
Russ4262
Posts: 598
Joined: Sat Jun 30, 2018 3:22 pm

Re: CNC Lathe and 4th-axis milling...

Postby Russ4262 » Sat Apr 13, 2019 5:29 pm

Good morning, 4th-axis enthusiasts!
Great news for you all. I think I have the depth calculations correctly set - for trial runs anyhow. My tests seem to have very good results. Currently, I have the standard Path Pocket(Pocket Shape) Op in the PathWB converted to 4th-axis integration with independent X and Y axis access.

Some details:
  • I have not tried any pockets that would combine X and Y (5th-axis).
  • I also have only tested on solids with pockets, not wire frames, outlines, or other random models.
  • I have only tested on pockets with bottoms perpendicular to cutter axis, not slanted bottoms such as the 3D Pocket might handle.
  • I still need to clean up the code for the purpose of integration into other PathWB operations, like the standard surfacing op.
  • I will send this code to my GitHub repo after I at least tidy up the code a bit. (remove excess feedback print statements, etc...)
  • I have not attempted pockets in all six faces of a cube, only what you see in the image below (3 faces tested)
  • I have not tested all the available pocket patterns available within the PathPocket(Pocket Shape) Op, to ensure none are negatively effected by modifications made.
  • Through holes as cylinders are available also, as were in the original.
  • Currently, two(2) files in the PathScripts directory have been modified for this 4th-axis feature: PathAreaOp and PathPocketShape
  • The FinalDepth input in the task window and properties list is not active now. Depths are calculated automatically based upon bottom of the pocket.
  • Axial rotation is currently fixed in the code. I will need to add a property/user-input for this.
INSTALLATION:
**NOTE: I used the pre_18.16085 release version as the basis for my modifications. There have been a few PR commits since. I will have to merge these into the new 4th-axis modified version. UPDATE: I merged with latest PR commits affecting the related script files. We should be good. I pushed the code to my GitHub repo, https://github.com/Russ4262/FreeCAD/tre ... c/Mod/Path:
  • Go to your FreeCAD root directory
  • Go to \Mod\Path\PathScripts directory
  • Rename the two files mentioned above(PathAreaOp and PathPocketShape).
  • Copy and paste the modified versions from the GH repo into same location.
  • Restart FreeCAD and have fun with the 4th-axis ready PathPocket((Pocket Shape) Op.
  • No new properties or inputs have been added; so, you do not need to delete and recreate existing PathPocket(Pocket Shape) ops in your jobs.
USAGE:
After installing the modified scripts:
  • Create your path job as normal.
  • Select a face(s) for a path pocket. Multiple faces may be selected at once, like the original version.
  • Run the operation.
  • Depths are automatically calculated based upon bottom of the pocket. We may need to add a DepthOffset input to refrain from pocketing to depth.
  • There may be bugs for some pocket attempts... Please let me know.
  • Pockets requiring both X and Y rotations are not available that I am aware of. So, faces need to be parallel to axis of rotation.
Fun, fun, fun...
Please make a list of "Have you considered..." for improving the implementation.
Russell

Update: I am attaching the two modified scripts to this message for simplicity, rather than needing to go to GH.

Update - 2019 May 15
Moving scripts to newer specific topics: 3D Surface: 4th-axis Integration and more... and to Path Pocket Shape: 4th-axis Integration. Script downloads are available there. Related discussions suggested to continue there as well.
Attachments
Model-3D-Surface-Block-3a.FCStd
Model-3D-Surface-Block-3a, file for trial-D
(51.16 KiB) Downloaded 25 times
PathPocket-4th-axis_trial-D-1.png
PathPocket-4th-axis_trial-D, model invisible
PathPocket-4th-axis_trial-D-1.png (158.05 KiB) Viewed 521 times
PathPocket-4th-axis_trial-D.png
PathPocket-4th-axis_trial-D
PathPocket-4th-axis_trial-D.png (144.95 KiB) Viewed 521 times
Last edited by Russ4262 on Thu May 16, 2019 4:36 am, edited 3 times in total.
Russ4262
Posts: 598
Joined: Sat Jun 30, 2018 3:22 pm

Re: CNC Lathe and 4th-axis milling...

Postby Russ4262 » Sat Apr 13, 2019 8:53 pm

FreeCAD rotational representation error? or error in the modified Pocket Shape script I just uploaded?
Russ4262 wrote:
Sat Apr 13, 2019 5:29 pm
Please make a list of "Have you considered..." for improving the implementation.
So, I pasted the gcode from the above file into https://ncviewer.com/ and received an unexpected result. The gcode orientation in FreeCAD appears correct per the geometry of the model. However, ncviewer.com results in a 180 degree offset in the front, right pocket within the FC screenshot.
PathPocket-4th-axis_trial-D-2.png
ncviewer.com result of 4th-axis trial-D gcode
PathPocket-4th-axis_trial-D-2.png (172.54 KiB) Viewed 476 times
Can anyone confirm this anomaly? I distinctly remember adjusting this particular rotation in the code, flipping it 180 degrees so it appeared correctly in the visual representation of the job and model. Is there an error deeper in FreeCAD? Anyone have similar issues with rotational results being different in FreeCAD vs exterior gcode renderer? Perhaps nobody does because we are breaking new ground? lol.

BE CAUTIOUS with this modified Pocket Shape operation if you are testing on a CNC machine !

Thoughts?
Thanks,

Russell
mlampert
Posts: 1568
Joined: Fri Sep 16, 2016 9:28 pm

Re: CNC Lathe and 4th-axis milling...

Postby mlampert » Sat Apr 13, 2019 9:11 pm

Russ4262 wrote:
Sat Apr 13, 2019 8:53 pm
Can anyone confirm this anomaly? I distinctly remember adjusting this particular rotation in the code, flipping it 180 degrees so it appeared correctly in the visual representation of the job and model. Is there an error deeper in FreeCAD? Anyone have similar issues with rotational results being different in FreeCAD vs exterior gcode renderer? Perhaps nobody does because we are breaking new ground? lol.
That is most likely the case. I wrote that code while my car got fixed and it hasn't gotten any real mileage since - there were more important things to be done for 0.18. This is one reason why I'm currently refitting my CNC with a new controller so I can actually attach a 4th axis and see what happens :mrgreen:
User avatar
Wsk8
Posts: 158
Joined: Fri Dec 07, 2018 6:24 pm

Re: CNC Lathe and 4th-axis milling...

Postby Wsk8 » Sat Apr 13, 2019 11:03 pm

I think the direction of the b-axis is wrong in FC.

Pocket2 and Pocket3 rotate both CW if you look from the arrow of the axis to its root. But A is negative 90 and B is positive 90 (in the G-Code).

mfg
Russ4262
Posts: 598
Joined: Sat Jun 30, 2018 3:22 pm

Re: CNC Lathe and 4th-axis milling...

Postby Russ4262 » Mon Apr 15, 2019 2:57 pm

Good morning,
In regard to the possible error in the FreeCAD rendering of tool paths:
mlampert wrote:
Sat Apr 13, 2019 9:11 pm
That is most likely the case. I wrote that code ... and it hasn't gotten any real mileage since...
So, should I revert the 4th-axis code back to the original (for that pocket orientation), which will then display 180 degrees off on the model, but would then likely be correct on actual CNC machines and exterior renderers?

mlampert wrote:
Sat Apr 13, 2019 9:11 pm
This is one reason why I'm currently refitting my CNC with a new controller so I can actually attach a 4th axis and see what happens :mrgreen:
God speed, Sir...
Wsk8 wrote:
Sat Apr 13, 2019 11:03 pm
I think the direction of the b-axis is wrong in FC. But A is negative 90 and B is positive 90 (in the G-Code).
This difference was purposeful in the code for pockets with that orientation, based upon visual test results in FC. However, if FC has a deeper error within the toolpath renderer code, I am asking if I should fix the new 4th-axis code and allow it to render incorrectly in FC, but be correct for real CNC application and other gcode renderers? Or, should I wait until the FC error, if that is the problem, is corrected before I edit the new 4th-axis code?

If the new script is corrected such that the FC rendering is off (but correct in real world), I am certain we will see some justified kickback, comments, and bug report.

Thoughts?

Thanks for the help, gentlemen. Enjoying every minute of this!
Russell