Issue with G2 and G3 in XZ plan

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Issue with G2 and G3 in XZ plan

Post by remcat »

Hello,
I request your HELP!
I am working on simple script for my CNC Lathe. I use Path WB to draw and edit the GCODE. I am working in the XZ plan.
I edited the GCODE below:
G90
G0 X35.000000 Z10.000000
G0 X25.000000 Z2.000000
G1 X25.000000 Z-38.735720
G0 X27.000000
G0 Z4.000000
G0 X21.000000 Z2.000000
G1 X21.000000 Z-34.580215
G0 X23.000000
G0 Z4.000000
G0 X17.000000 Z2.000000
G1 X17.000000 Z-25.463167
G0 X19.000000
G0 Z4.000000
G0 X13.000000 Z2.000000
G1 X13.000000 Z-12.755888
G0 X15.000000
G0 Z4.000000
G0 X9.000000 Z2.000000
G1 X9.000000 Z-9.664654
G0 X11.000000
G0 Z4.000000
G0 X7.657710 Z0.000000
G1 X7.657709 Z-4.940313
G1 X7.657710 Z-9.056990
G2 I-5.127900 J0.000000 K-13.113551 X16.605724 Y0.000000 Z-21.811083
G3 I22.412965 J0.000000 K0.572361 X25.000000 Y0.000000 Z-38.735720

Here is the corresponding result (notice that the visualisation cube is in between front/bottom):
lathPath issue.png
lathPath issue.png (13.67 KiB) Viewed 1527 times
G2 and G3 are drawn in XY plan and not XZ.
I am stuck on this pb. I would be very gratefull if you could help me here!

My system:
OS: Ubuntu 16.04.6 LTS (XFCE/xubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19056 (Git) AppImage
Build type: Release
Branch: master
Hash: 7dbc309015606fca1aa1f1561ae166ef719b2234
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)

The freecad file is here:
PathLatheNewV2.FCStd
(41.98 KiB) Downloaded 27 times
User avatar
Wsk8
Posts: 182
Joined: Fri Dec 07, 2018 6:24 pm

Re: Issue with G2 and G3 in XZ plan

Post by Wsk8 »

Add G18 after G90

How did you create this Path?
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: Issue with G2 and G3 in XZ plan

Post by remcat »

Thank you very much for your help! I did not find the information in the path scripting page that g18 was suported :roll: . I will try tomorow morning and reply the result.
I coded 1 class, 5 functions from scratch (based on freecad routines):
a profile extraction and discretisation
a profile correction taking into account back and front tool angles
a profile reduction that reduces the number of segments and arcs
an offset routine using makeOffset2d
a path function to define the final gcode path

Around 1000 lines of code, only profile (no face op -> but shouldn’t be so complicated, no boring-> more complexe) result is the path above. If i finish the code (if i find the time) and tested on my lathe (home motorised using arduino, serial and grbl), i will share the code. ;)
++Remcat
l2s
Posts: 14
Joined: Mon Mar 16, 2020 10:01 am
Location: Tirol/Austria

Re: Issue with G2 and G3 in XZ plan

Post by l2s »

Hi remcat
I made myself a post processor based on linuxcnc_post and philips_post to use may spindle also horizontal not only vertical. I attached it, maybe it helps you.
Attachments
CNC_waagrechte_Spindel_post.py
(16.13 KiB) Downloaded 31 times
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: Issue with G2 and G3 in XZ plan

Post by remcat »

Thank you, i will check your code.
Here is the result with G18. I also improved the final cut with a last profil. I also implemented front (5°) and back (30°) tool angles in orange. Here, the discretisation is done with 20 segments only for debug, but quite already good compared to the original profile in white. Reduction of segments leads to compression in 9 segments.
lathimage.png
lathimage.png (11.05 KiB) Viewed 1434 times
There are still a lot of bugs (clockwise/counter clock wise procedure, etc..). In particular, i fighted a lot with makeOffset2D which raises a lot pbs, like singularities when two circles are tangent in one point. If somebody has developed something like makeoffset in py, i am interested, because i still doesn't understand what the embeeded function is doing (quite strange behaviors :roll: ).
There is also a huge work to do on the path strategy when many "holes" in the profile must be machined, using a dendrinite-like algorythm. Here, depending on my time, i will implement it next, but my first objective is already attained, which was: machining round surfaces using the lathe.
++R
User avatar
dubstar-04
Posts: 698
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Issue with G2 and G3 in XZ plan

Post by dubstar-04 »

remcat wrote: Mon Apr 27, 2020 1:51 pm Thank you, i will check your code.
Here is the result with G18. I also improved the final cut with a last profil. I also implemented front (5°) and back (30°) tool angles in orange. Here, the discretisation is done with 20 segments only for debug, but quite already good compared to the original profile in white. Reduction of segments leads to compression in 9 segments.
lathimage.png
There are still a lot of bugs (clockwise/counter clock wise procedure, etc..). In particular, i fighted a lot with makeOffset2D which raises a lot pbs, like singularities when two circles are tangent in one point. If somebody has developed something like makeoffset in py, i am interested, because i still doesn't understand what the embeeded function is doing (quite strange behaviors :roll: ).
There is also a huge work to do on the path strategy when many "holes" in the profile must be machined, using a dendrinite-like algorythm. Here, depending on my time, i will implement it next, but my first objective is already attained, which was: machining round surfaces using the lathe.
++R
I have been working on lathe intergration with FreeCAD:

Lathe Library: https://github.com/dubstar-04/LibLathe

Integration Branch: https://github.com/dubstar-04/FreeCAD/t ... ntegration

There are some offsetting methods in liblathe that might be useful or you could always help bring the library to a useable state :D

Thanks,

Dan
User avatar
dubstar-04
Posts: 698
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Issue with G2 and G3 in XZ plan

Post by dubstar-04 »

remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: Issue with G2 and G3 in XZ plan

Post by remcat »

Hello Dan,
Thanks. I am going to see your offseting solutions.
Finally, i understood more or less how makeoffset is working, and managed corrections. In particular, i found that wire.Edges.Curve.Axis gives the orientation of an Arc/Circle clock or counter-clockwise (no info in the net about this method). Before, i coded a std vectorial solution to find the orientation, but this solution is clearly better.
Here is another example with 4 profiles (two arcs are fully tangently constrained).Discretisation is 20. No tool angles segments here (orange curve), since the slopes are less than the front and back angle. Also for debug, the tool tip radius is 1 mm,. A std "plaquette de coupe" radius is around 0.2nm (or even 0.1mm if precision is required). "5 profiles case is bugging". I have to check why in makeoffset...
pathimg1.jpg
pathimg1.jpg (36.68 KiB) Viewed 1368 times
++R
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: Issue with G2 and G3 in XZ plan

Post by remcat »

Hello,

Finally, i corrected the makeoffset issues. Here is the results with 8 profiles, discretisation = 60, front tool angle 5°, back tool angle 30°, tool tip 1mm, Xstep 4mm. White: the original profile, Orange: the corrected profiles with tool angles
Compression from 60 segments to 6 lines or arcs, leading to 101 lines of Gcode. Computing elapsed in: 0.931 s.
pathimg2.jpg
pathimg2.jpg (33.54 KiB) Viewed 1343 times
There are still some uncertainties at sharp edges due to the low discretisation.
++Remy
remcat
Posts: 23
Joined: Wed May 01, 2019 8:30 am

Re: Issue with G2 and G3 in XZ plan

Post by remcat »

Hello,

One last image: dendritic cutting mode implemented. Front tool angle 5°, back angle 15°, tip raidus 1mm, steps 1mm, discretisation 50, 1 profile.
Computing elapsed in: 0.294 s
pathimg5.jpg
pathimg5.jpg (37.29 KiB) Viewed 1226 times
With the freecad file:
PathLatheNewV4.FCStd
(40.95 KiB) Downloaded 31 times
++R
Post Reply