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

    Creating a GPIO Macro to run a DC Motor

    Scheduled Pinned Locked Moved
    Gcode meta commands
    2
    5
    176
    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.
    • madeinta1wanundefined
      madeinta1wan
      last edited by

      Re: Creating a timed fan Marco and Meta

      Hi,

      Following on this topic, I've got a similar large format Cartesian printer with a 6HC main board and 3HC expansion boards which I've equipped with a small (M5Stack) dc motor to periodically vibrate for a second to make sure pellets are not binding in the feed passage.

      CloudTable.jpg

      M5stackmotor.jpg

      I've got the DC motor connected to the IO_1 of my 3rd 3HC and it runs (constantly, I know this is on 100%, this is just for testing) with this in my config.g -

      ; Pellet Shaker
      M950 P1 C"3.io1.out"  Q450       ; create output/servo 
      M42 P1 S1 ; set 100% PWM on GPIO port 1
      
      

      What I thought I could do is modify the code that @infiniteloop and @OwenD helped @kmoore for his pellet feed-

      ; filamentmonitor.g
      ; Check filament progress, feed pellets if needed
      if job.file.fileName == null 
          M99 
      if {{global.filamentProgress + 11500.0} <= move.extruders[0].position} ;
          set global.filamentProgress =   {move.extruders[0].position + 11500.0} 
          M106 P0 S255 
          G4 S3 
          M106 P0 S0
      

      But in my case, I'd like to switch on a fan connection on the 6HC using the M106 command and pulse the pellets a bit.

      Is there a way of adding control over the DC motor connected to the IO_1 pins within that macro?

      Thanks very much, Nate

      OwenDundefined 1 Reply Last reply Reply Quote 0
      • OwenDundefined
        OwenD @madeinta1wan
        last edited by OwenD

        @madeinta1wan

        You need to use M42
        https://docs.duet3d.com/User_manual/Reference/Gcodes#m42-switch-io-pin

        madeinta1wanundefined 1 Reply Last reply Reply Quote 0
        • madeinta1wanundefined
          madeinta1wan @OwenD
          last edited by

          @OwenD Thanks, that can be run like the M106 command in the macro?

          OwenDundefined 1 Reply Last reply Reply Quote 0
          • OwenDundefined
            OwenD @madeinta1wan
            last edited by

            @madeinta1wan said in Creating a GPIO Macro to run a DC Motor:

            @OwenD Thanks, that can be run like the M106 command in the macro?

            Yes

            if {{global.filamentProgress + 11500.0} <= move.extruders[0].position} ;
                set global.filamentProgress =   {move.extruders[0].position + 11500.0} 
                M106 P0 S255 
                M42 P1 S1
                G4 S3 
                M106 P0 S0
                M42 P1 S0
            
            madeinta1wanundefined 1 Reply Last reply Reply Quote 0
            • madeinta1wanundefined
              madeinta1wan @OwenD
              last edited by

              @OwenD Amazing thanks very much 🤘

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