• Tags
  • Documentation
  • Order
  • Register
  • Login
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
175
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.
  • undefined
    madeinta1wan
    last edited by 23 Jan 2024, 18:36

    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

    undefined 1 Reply Last reply 23 Jan 2024, 19:41 Reply Quote 0
    • undefined
      OwenD @madeinta1wan
      last edited by OwenD 23 Jan 2024, 19:41

      @madeinta1wan

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

      undefined 1 Reply Last reply 23 Jan 2024, 20:13 Reply Quote 0
      • undefined
        madeinta1wan @OwenD
        last edited by 23 Jan 2024, 20:13

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

        undefined 1 Reply Last reply 24 Jan 2024, 02:36 Reply Quote 0
        • undefined
          OwenD @madeinta1wan
          last edited by 24 Jan 2024, 02:36

          @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
          undefined 1 Reply Last reply 24 Jan 2024, 11:41 Reply Quote 0
          • undefined
            madeinta1wan @OwenD
            last edited by 24 Jan 2024, 11:41

            @OwenD Amazing thanks very much 🤘

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