Welcome to Our Community

Some features disabled for guests. Register Today.

Loops M98 and While

Discussion in 'CAM' started by dbdb, Aug 20, 2021.

Thread Status:
Not open for further replies.
  1. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    I hope this is the right place to post a GCode question. Actually I don't know if I have a setup problem or a GCode problem. I'm trying different software to simulate the GCode and exploring looping alternatives. When I review my code in OpenBuilds Control - simulator, I see the 1st loop and then an exit from the grid. Using GWizard Editor I see all the loops as expected. I then wrote a While loop and got the same results, 1 loop with OB Control - Simulator and multiple loops with GWizard Editor.

    Do I have a coding problem? setup problem? something else?

    Thanks
    dbdb

    *********************************************************************************************************
    ; Operation 0: CNC: Vector (no offset)
    ; Endmill Diameter: 3.175

    G21; mm-mode
    G54; Work Coordinates
    G21; mm-mode
    G90; Absolute Positioning
    M3 S1000; Spindle On

    G0 Z20; Move to z-safe height

    M98 P2000 L5; CALL SUB 2000

    G0 Z20; retracting back to z-safe
    G0 F1000 X0.00 Y0.00
    M5 S0; Spindle Off
    M30; END PROGRAM


    O2000; SUBPROGRAM
    M3 S1000; Spindle On
    G1 F500 X010.00 Y010.00 Z-0.50 S1000
    G1 F500 X010.00 Y110.00 Z-0.50 S1000
    G1 F500 X110.00 Y110.00 Z-0.50 S1000
    G1 F500 X110.00 Y010.00 Z-0.50 S1000
    G1 F500 X010.00 Y010.00 Z-0.50 S1000
    M99
     
  2. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,288
    Likes Received:
    1,837
    You have a 'didnt read the manual' problem (-:
    OBControl is designed to work with the Blackbox and similar controllers, like a bare Arduino Uno with external drivers.
    The Blackbox runs GRBL firmware.
    GRBL runs (in this case) on an 8bit microprocessor that does not have enough memory to do everything, so GRBL supports a small subset of Gcode commands, which excludes looping.
    The GRBL wiki will tell you exactly which ones.

    As a programmer I too wish for looping, math, variables, subroutines and so on within the Gcode, but GRBL on the Atmega328p cannot do it.
    The next generation of GRBL on 32bit processors will be able to move in this direction, hang in there, it is coming (-:
    grblHAL seems most of the hardware variations have been figured out so the Gcode extensions will follow soon, if not already done, I have not been following the project closely

    In the meantime you may want to try the bCNC GUI for GRBL. It allows for variables in the Gcode, which it preprocesses before sending it to the controller.
    So for example
    G0 X[maxx/2] Y[maxy/2]
    will rapid to the center of the currently loaded Gcode file, I use this in a macro button, and then probe Z at that point.
     
    JustinTime and Rob Taylor like this.
  3. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
    David the swarfer likes this.
  4. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Peter, I saw the thread you posted as I was researching loops and the ability to do a manual tool change. I conclusion was, I may be able to write to "pause" into code and JavaScript a resume into a macro button. Just maybe. A challenge for another day. another year. another machine beyond the capabilities of an 8bit microprocessor. I just want to cut a profile that requires 10 passes that without reviewing 1200 lines of code?

    Your level of knowledge is amazing!!! We are just to stupid to understand your written solutions.
     
  5. Christian James

    Christian James Journeyman
    Builder

    Joined:
    Jun 8, 2018
    Messages:
    439
    Likes Received:
    213
    If you want to construct a homebuilt type machine, then knowledge and in particular, the acquisition of knowledge cannot be overstated. The more one learns during a build and in service is invaluable to the owner. Although I have an electro /engineering background, I knew nothing of CNC, grbl, cad/cam etc but learning these new disciplines is what made it so much fun.
     
  6. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
    Grbl does not support loops no.

    Are you hand writing GCODE or using a CAM - most modern CAMs have Grbl support and outputs multiple passes as multiple lines of code as expected
    If you are hand coding, you'd have to copy/paste the "loop" multiple times - Grbl just executes top to bottom (and only GCODEs it supports, as listed in the Grbl Wiki)

    For example, in OpenBuilds CAM - you'd setup your depth per pass and final depth - it will do the passes for you.

    upload_2021-8-21_8-37-40.png
     
    Alex Chambers likes this.
  7. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,700
    Likes Received:
    1,327
    Perhaps you should have started by describing what you wanted to achieve, rather than how you were trying to achieve it? 1200 lines of code is a fairly short g-code file and cutting a profile in 10 passes is easily achieved by any cad/cam software.
    Is there a particular reason if you are writing code by hand?
    If you need/want advice on how to achieve the end result using freely available software there are lots of people here willing to help.
    Alex.
     
  8. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Thanks Peter,
    My 1st cut was a 100mm square and 100mm circle, 6mm deep in a 1by6 board, with GCode from OB Cam. OB CAM was quick, easy and intuitive. For me, just as important, provides a first look at needed start code, end code and sequencing. I also have some working knowledge of Fusion 360 and generated some GCode using their CAM and had no problem moving it to OB Controller.

    Where I ran into trouble was... Fusion can save the GCode used directly used in Control, but can not save to a DXF/SVG for OB CAM. And, OB CAM does not accept Fusion f3d or Inventor ipt or Sketchup skp file formats. I have no huge desire to do a lot of hand coding with GCode. I was looking for software to bridge the gap between drawings and GCode. Thus, I found GWizard Editor and others that created code that would not run on OB Control. My original post was an honest question.... bad code or missing setting or something else.

    I have yet to discover how most hobbyist, using the Blackbox, are getting from drawings to GCode. I have found, Fusion CAM and today Sketchup's export to DXF. Are these two the work flow used by most?

    Javascript: Peter I have written a gazillion line of code. Almost all were VBA/VB6. Based on a huge desire, I wrote a Texas Hold'em Bot in MS Access. I understand the fundamentals of coding. I have looked a Javascript twice as an alternative language and passed both times. My desire was not enough to stop and learn a new language. MAYBE, a CNC Machine will be that case.
     
  9. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,700
    Likes Received:
    1,327
    Fusion 360 has cam capability and there is a post processor for it written especially for Openbuilds - docs:software:fusion360 [OpenBuilds Documentation].
    You don't have to go via Openbuilds CAM with a dxf, although if that is your preferred way of working Fusion can export a dxf. If you are using the hobby licence with Fusion you can only (I believe) export a dxf from a sketch in Fusion design.
    Alex.
     
  10. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Alex:
    "Perhaps you should have"... I can ponder that suggestion. honestly. I had done the work to narrow my question to something very specific. I don't post on forums much and don't yet understand the culture. I do see post that ask broad sweeping questions and replies that make the poster feel stupid for even asking. Maybe, I took the opposite approach to avoid the embarrassment and received it anyway.

    I still have an outstanding question, honest and narrow. Will the "CNC xPro V5" box run the code that I listed in original post? My guess is, that it will run the full set of GCode, including M98 loops. I already have a xPro. I choose to build my machine with the Blackbox. I have no idea what Controller would be necessary for the xPro, thus I used the Blackbox. Better support I thought.

    Why hand write GCode? If it is necessary to write 1000 lines to cut a circle, I understand you 100%. If it accomplished in 40 line and one cut-n-paste, I'm not so sure. My actual challenge is getting from a drawing to Control. Fusion 360 CAM is an alternative, but not as user friendly as OB CAM. But, OB CAM does not accept Fusion drawings or Inventor or Sketchup. What is a normal work flow to cut a profile?

    I honestly thought the error was mine! GCode error or a Setting in Control.
     
  11. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,700
    Likes Received:
    1,327
    No embarrassment intended, and the vast majority of people here will try their best to help anyone no matter what their experience and knowledge level - was just trying to find out what you were trying to do. I don't have any personal experience with the Xpro v5 but I'll find the link to Spark Concepts wiki if you haven't already found it?
    I'll also check that Fusion 360 can export a dxf (from the personal use license version which I have - I know the paid version can) - if so you could use Fusion to design and OB cam to create your g-code for the blackbox.
    Alex.
     
  12. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,700
    Likes Received:
    1,327
    Yes - you can save a sketch as a dxf file from Fusion (even in the personal use licence version)

    Fusion dxf.jpg
    Spark Concepts wiki, in case that is of use ;- Home · Spark-Concepts/xPro-V5 Wiki


    Alex.
     
  13. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
  14. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    I think your screen shot is out dated... I would hope that I am wrong.
    If you attempt a "save" they force you to the standard file format and the cloud.
    If you use the "export" you can save to your desktop, but no DXF without paying. see image below

    Hence my question... what is a normal workflow to cut a profile? several pieces from one piece of plywood?
     

    Attached Files:

  15. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
     
  16. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
    Exactly, Fusion's CAM is built in and far superior to the free OpenBuilds CAM :)

    No it is Grbl as well.

    See docs.openbuilds.com > software section

    No, the use case was dependant. For multipass cutting, CAM it up right. No need for macros, loops and other ideas. Modern CAMs have it all working for you already, no need to reinvent the wheel

    Yeah, but OpenBuilds CAM likes DXF R14 polylines, which that is not.
    If you draw in fusion, rather use Fusion CAM too. Openbuilds CAM is the the free, ugly, beginner CAM. We dont want to compete with Fusion. Learn, grow your skill, switch to Fusion CAM its a heck of a lot more powerful
     
    Alex Chambers likes this.
  17. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Alex.... I now think I am wrong!
    I showed in the image that I could not export the DXF.

    I then tried to duplicate your screen-shot at the Sketch Folder level and still nothing.
    BUT, at the individual Sketch level, below folder, Save as DXF is available!

    I saved a test and opened it in OB Cam with no problems!

    Thank YOU!
     
    Peter Van Der Walt likes this.
  18. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
    I am surprised it worked. They used to export as a fancier DXF version than OpenBuilds CAM would support.
     
  19. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
     
  20. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Posts are bouncing quicker than experiments....
    I can get the DXF to load to OB Cam, but it stalls when trying to calc a tool path.

    I see the recommendation to start with OB CAM, learn and them step to Fusion or something.
    That is reasonable. Begs the question of getting drawings into OB Cam? I will follow your recommendation
    to study up at "See docs.openbuilds.com > software section". I assume I will find my answer there.

    thank you
     
  21. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
  22. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,700
    Likes Received:
    1,327
    Hmm, I gave that advice because Autodesk say Fusion exports dxf's as R14 - don't use it myself because, as @Peter Van Der Walt says, Fusion cam is good.


    PS - just had a look at a dxf file exported from Fusion - it is R14, don't know how to check if it is using polylines.
     

    Attached Files:

  23. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,288
    Likes Received:
    1,837
    OBCam is used by many to go from DXF to Gcode (and can draw some primitives too), Fusion360 is also used by many (with the OB postprocessor taylored for GRBL) to go from 3D drawing to Gcode.
    These generate GRBL friendly Gcode, and OBcam will transmit it directly into OBControl if they are running on the same computer.

    Sketchup is a different beasty, and current incarnations want to be online cloudy things, but the offline version (Sketchup Make 2017 is the one I use) can accept plugins, and one such plugin is SketchUcam, which generates Gcode directly from Sketchup (invented by the owners of Openbuilds btw). It even has a 'send it to OBcontrol' button (-: Taylored for 2.5D drawings to cut flat things from flat sheet, if you want smooth rounded things, stick to Fusion360.


    There are many other options of course, OB offers various versions of Vcarve, or download Estlcam, or whatever, so long as it can generate GRBL flavoured Gcode the Blackbox will be exactly that, a blackbox that 'just works' to simply and inexpensively run your CNC machine reliably.
     
    Peter Van Der Walt likes this.
  24. dbdb

    dbdb New
    Builder

    Joined:
    Apr 3, 2021
    Messages:
    16
    Likes Received:
    1
    Thanks David,
    thanks alex,
    Could you give a brief description of different types of dxf files and where/how to see the type?
    With that info, I think I could test each type I see, against OBCam and Control.

    thanks
     
  25. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,042
    Likes Received:
    4,123
    CONTROL is a Host, it takes GCode and streams it, it doesnt have anything to do with DXFs


    OpenbuildsCAM takes DXF R14 Polylines. R14 is the revision (older = more compatible) and polylines is a CAD term. Convert arcs/splines and seperate line segments to proper polylines. See link given earlier to understand polylines and filetypes better, quite simple actually.


    Rather than test, just see docs:software:overview [OpenBuilds Documentation] as also mentioned above in a different comment (Software section of our docs) and work through the software section using menu on the left.

    Then pick a CAM you like and run with it. OpenBuildsCAM for beginner basic 2.5D cut work. Vectric for Signage or 3D carvings, Fusion for engineering type work. If you come from a Sketchup background, SketchucCAM will be your favourite.

    Our official documentation has enough info to get you going, the additional research with irrelevant tools like GWizard (not Grbl related) added to your confusion. Best to get the advice from us, so it relates to our products. I am going to close this thread. Please checkout the links in this post, and for tech support, jump onto Support at any time you need help - you will get a much better experience with direct support than trying to figure it out via Google :)
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice