Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Learning- How G-Code and Firmware Interact

    Scheduled Pinned Locked Moved
    Firmware developers
    learning firmware g-code custom
    6
    14
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JRCLundefined
      JRCL
      last edited by JRCL

      Hello all!

      I'm a MechE who has been working on printers for the last 7 years but have never touched the software/firmware side other than some basic post slice G-code modifications. I'm attempting to make firmware for a custom machine with Duet Boards that does more than just print and I know will require me to establish other axes and do a lot more than the standard Reprap Wizard does.

      So... obviously, a slicer turns models into g-code which is then interpreted by the microcontroller and turned into movements. However, I don't quite understand what these firmwares consist of. Is it a mix of G-Code and another language? No G-code at all? Is the G-code interpreter in the firmware or part of the hardware? I have no clue how all of the different levels of code work together for a cartesian movement-based machine.

      I want to use the Reprap wizard to get a basic setup and then establish and control additional axes. Is that done through G-code commands? The machine is primarily printer-based but has a fair bit of post-process actions that I want to "add-on", you could say, to the end of normal printer operations. Again I would prefer to do it in the firmware so I don't have to edit my g-code files after every use but maybe that is my best bet. W

      Hopefully, I made some sense and worded some questions well. I'm not very familiar with software nomenclature as I've only learned simple MATLAB and some arduino. Any help is greatly appreciated as I leave my comfort zone of mostly hardware.

      alankilianundefined fcwiltundefined dc42undefined 3 Replies Last reply Reply Quote 0
      • alankilianundefined
        alankilian @JRCL
        last edited by

        @jrcl

        It's complicated and pretty difficult to answer all those questions through a text interface rather than through a couple-hour long discussion.

        You can see the code here.
        Some documentation on how things work is here.

        Basically, the firmware is written in C++ and "consumes" GCODE and generates stepper motor control signals (as well and heater, fan, and lots of other control signals and reads inputs from temperature sensors, switches, pulse-generators, and other stuff.)

        You can configure other axes using Gcode and Mcodes.
        You can use the Reprap configurator for several different machine kinematics (organization of the mechanical joints and motors.)

        It'll be quite a ride getting to know enough to be able to modify the firmware to add additional functions, but you'll get there.

        SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

        JRCLundefined 1 Reply Last reply Reply Quote 2
        • fcwiltundefined
          fcwilt @JRCL
          last edited by

          @jrcl

          Hi,

          Here is the link to the site where you can find out the answers to most of your questions.

          https://www.reprapfirmware.org/

          The firmware that runs on the Duet hardware appears to be written in C++ but I have never delved into it. Others here have and have made their own modifications/additions to the firmware.

          I don't use the Reprap Wizard. I started with a sample set of configuration files and using the Gcode Dictionary learned how to create configuration files from scratch.

          You can establish additional axes using Gcode and control them with Gcode to a limited degree. But, as far as I know, to do anything during printing that is in sync with other axes is going to have to be done in firmware.

          Good luck with your project.

          Frederick

          Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

          JRCLundefined 1 Reply Last reply Reply Quote 1
          • JRCLundefined
            JRCL @fcwilt
            last edited by

            @fcwilt When you say "establish additional axes using Gcode and control them with Gcode to a limited degree" do you mean with just manual modification of gcode from a printer slicer or entirely making your own command set to operate only once.

            These additional axes shouldn't have to do anything during the actual printing, just after.

            fcwiltundefined 1 Reply Last reply Reply Quote 0
            • JRCLundefined
              JRCL @alankilian
              last edited by

              @alankilian Thank you so much I'll make sure to start looking into all of these!

              1 Reply Last reply Reply Quote 0
              • fcwiltundefined
                fcwilt @JRCL
                last edited by

                @jrcl said in Learning- How G-Code and Firmware Interact:

                When you say "establish additional axes using Gcode and control them with Gcode to a limited degree" do you mean with just manual modification of gcode from a printer slicer or entirely making your own command set to operate only once.

                These additional axes shouldn't have to do anything during the actual printing, just after.

                That sort of thing you can do. For example, I retro-fitted one of my printers with a removable Z probe just to try it out. Because of the limited space on the printer I had to install a small stepper controlled linear guide (50 mm travel) to move a needed part into place as needed and out of the way as needed. Since it had nothing to do with printing I was able to create a pair of files with the need gcode commands to control the stepper motor as needed.

                50mm mini guide.png

                Frederick

                Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                1 Reply Last reply Reply Quote 1
                • dc42undefined
                  dc42 administrators @JRCL
                  last edited by dc42

                  @jrcl can you tell us more about what else you want the machine to do? Adding additional axes is easy using the M584 command, as long as all axes are expected to move in sync when multiple axes are moving at the same time.

                  Duet WiFi hardware designer and firmware engineer
                  Please do not ask me for Duet support via PM or email, use the forum
                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                  JRCLundefined 1 Reply Last reply Reply Quote 1
                  • rjenkinsgbundefined
                    rjenkinsgb
                    last edited by rjenkinsgb

                    The firmware is a "G Code interpreter" that in principle reads a line at a time and performs whatever function or movement that line requires.

                    Re. other commands and axes;
                    You can have additional motors linked to extra "axis name" letters, that can be commanded to move when needed.

                    You can also have on/off switching outputs and access many other hardware functions on the Duet board, by commands in the G Code program.

                    If there you need complex combinations from a single instruction, you can define macros (G code subroutines) triggered by spare M codes or called by name.

                    For adding functions in during printing, look at the custom G Code sections available in such as Prusa Slicer.
                    You can have custom commands run at the start of the program, the end of the program, at any layer change, extruder change etc. etc.

                    And the Duet has a "Demon" facility, a file that can be auto executed at regular intervals to monitor or control additional hardware totally independently (within reason) while the printer is running.

                    If you give full details of what you are trying to achieve, there is a good chance it can be done just with the appropriate configuration of the machine and slicer.

                    Robert J.

                    Printers: Overlord pro, Kossel XL+ with Duet 6HC and "Frankentron", TronXY X5SA Pro converted to E3D toolchange with Duet 6HC and 1LC toolboards.

                    1 Reply Last reply Reply Quote 1
                    • JRCLundefined
                      JRCL @dc42
                      last edited by

                      @dc42 @rjenkinsgb

                      In short, I'm attempting to operate a thermoform "onto" the print bed once the print is done. So once a print is done the print head moves out of the way and a heater heats up a thermoplastic sheet held by a carriage that moves parallel to the Z-Axis, via belt connected steppers, so the sheet can be pulled over the bed. Then the vacuum turns on. So in summary:

                      1. I need an additional axis to rotate the print head out of the way
                      2. I need an additional axis for the steppers driving the carriage, but moves linearly from the belts
                      3. I need to setup a PID controller for the additional heating element via a relay as I'm using a an 120VAC load with a 3-32VDC control signal. Thinking PWM pins or GPIO pins for this?
                      4. I need to control the vacuum, which I would like to just do with the GPIO pins

                      Thank you so much for your time and willingness to dive further into it with me!

                      fcwiltundefined rjenkinsgbundefined 2 Replies Last reply Reply Quote 0
                      • fcwiltundefined
                        fcwilt @JRCL
                        last edited by

                        @jrcl said in Learning- How G-Code and Firmware Interact:

                        1. I need an additional axis to rotate the print head out of the way

                        Would it not be enough to simply lower the bed far enough down to provide the clearance need to move the carriage into place over the model?

                        1. I need an additional axis for the steppers driving the carriage, but moves linearly from the belts

                        That's easy.

                        1. I need to setup a PID controller for the additional heating element via a relay as I'm using a an 120VAC load with a 3-32VDC control signal. Thinking PWM pins or GPIO pins for this?

                        That's easy.

                        1. I need to control the vacuum, which I would like to just do with the GPIO pins

                        That's easy.

                        Frederick

                        Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                        JRCLundefined 1 Reply Last reply Reply Quote 1
                        • JRCLundefined
                          JRCL @fcwilt
                          last edited by

                          @fcwilt Unfortunately due to the dynamics of the machine and some other physical constraints I have to rotate it entirely away.

                          Happy to hear everything else is easy to do. I assume you mean routinely and not just adding a bunch of raw g-code to the end of the sliced model file.

                          engikeneerundefined fcwiltundefined 2 Replies Last reply Reply Quote 0
                          • engikeneerundefined
                            engikeneer @JRCL
                            last edited by engikeneer

                            @jrcl well you'll need gcode lines in your config to define your motors, axes, heaters etc (all standard but you'll just have more of them). You'll then need some extra gcode to run at the end of a print file do the motions you require (e.g. rotate axis A by 90deg, move axis B 100mm etc.) That could all be in a macro on the printer, then the print file just needs to call that macro e.g. M98 P"doSomeCleverStuff.g"

                            E3D TC with D3Mini and Toolboards.
                            Home-built CoreXY, Duet Wifi, Chimera direct drive, 2x BMG, 300x300x300 build volume
                            i3 clone with a bunch of mods

                            1 Reply Last reply Reply Quote 1
                            • fcwiltundefined
                              fcwilt @JRCL
                              last edited by

                              @jrcl said in Learning- How G-Code and Firmware Interact:

                              @fcwilt Unfortunately due to the dynamics of the machine and some other physical constraints I have to rotate it entirely away.

                              That is going to make it hard and likely expensive. How about a setup where the bed is moved to a different location out from under the print head? That's easy.

                              Happy to hear everything else is easy to do. I assume you mean routinely and not just adding a bunch of raw g-code to the end of the sliced model file.

                              Slicers have the ability to call custom gcode on the printer at the start of the print, at the end of the printer and during certain events during the print.

                              Frederick

                              Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                              1 Reply Last reply Reply Quote 0
                              • rjenkinsgbundefined
                                rjenkinsgb @JRCL
                                last edited by

                                @jrcl said in Learning- How G-Code and Firmware Interact:

                                In short, I'm attempting to operate a thermoform "onto" the print bed once the print is done. So once a print is done the print head moves out of the way and a heater heats up a thermoplastic sheet held by a carriage that moves parallel to the Z-Axis, via belt connected steppers, so the sheet can be pulled over the bed. Then the vacuum turns on. So in summary:

                                As far as the controller & firmware etc., everything you want to do can be done just with correct configuration and adding a macro to run the extra mechanics; or add the full code to the slicer end code, either way.

                                Rotating the head away while still maintaining full accuracy seems difficult though; using a larger frame so the axes can move clear of the required area is likely cheaper.

                                The only high-accuracy possibility I can think of could be to use an E3D toolchanger system, with a hinge and servo added above the tool attachment point so when the tool is unclamped it can be swivelled up over the carriage, rather than left in a static carrier.

                                Still complex and expensive, possibly more so than just longer axis rails to move a normal head clear.

                                All the other motions are straightforward and controllable, with pretty much off-the-shelf mechanical parts.

                                Robert J.

                                Printers: Overlord pro, Kossel XL+ with Duet 6HC and "Frankentron", TronXY X5SA Pro converted to E3D toolchange with Duet 6HC and 1LC toolboards.

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Unless otherwise noted, all forum content is licensed under CC-BY-SA