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

    Electrically trigger DSLR in G-code

    Scheduled Pinned Locked Moved
    Third-party add-ons
    2
    4
    217
    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.
    • KnyteTechundefined
      KnyteTech
      last edited by

      Hey everybody - bit of a weird one, but not entirely a new problem...

      I have a Duet2 controlled i3-style 3Dprinter that's huge, and has dual-extruders. I've been using my Nikon D7100 with a remote-trigger for shooting timelapses on it.

      Currently, the trigger is mounted on the X-axis, and physically pressed by the hot-end carriage - the problem is that the long move to trigger it causes a visible reduction in print quality that I have not been able to fully eliminate - so I want to trigger it electrically, using g-code.

      Most of the solutions I've seen for this before say to use the Extruder 2 header to actuate the relay, but that's not an option for me, as that head is already in use, as are all of the fan headers (the other solution I've seen).

      The trigger for my camera is just a momentary switch, so I was thinking I could replace the button with a relay, then trigger the relay using some of the IO pins and g-code. The relay closing would act as a momentary switch, triggering the shutter on my camera.

      ... unfortunately, I'm terrible at EE stuff, so I'm too dumb to figure this out on my own, or to know if what I want is more-complicated than I think it is, so my questions are:

      • What pins on the I/O header could I control via G-code, to supply voltage to trigger a relay?
      • What voltage would it be?
      • What Gcode would I need to turn the pin(s) on/off?

      I have not bought a relay or anything yet, because I didn't know what I would need, so I'm open to suggestions.

      Thanks in advance for any help you can provide.

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

        @KnyteTech on Duet 2 you can use the following pins to drive a relay:

        • Fan pins, if you are not already using both fan outputs. These have flyback diodes built-in, so they can drive a relay coil directly. The relay coil should be choses to operate at VIN voltage.
        • Heater pins. Same as fan pins, except that they do not have built-in flyback diodes on Duet 2; so you need to connect a flyback diode in parallel with the relay coil (be sure to get it the right way round!)
        • The PS_ON pin. This has no flyback diode (so you need to provide one externally) and can switch a load (relay coil) between +5V or +VIN.
        • Expansion board outputs. These can only provide 3.3V signals at low current, so they can't switch a relay directly; however you can drive a relay board (a relay with a driver transistor on the board) from them.

        My personal choice if you are not using the PS_ON output already would be to use a reed relay with a 5V coil. Some 5V reed relays have the flyback diode built-in (in which case, make sure you connect the coil with the correct polarity!), or you can use a reed relay without a built-in flyback diode and add a 1N4148 or similar external diode yourself.

        Depending on your camera, you might be able to use an opto isolator instead of a relay.

        In all cases you would use the M42 commands to command the relay contacts to close or open.

        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

        KnyteTechundefined 1 Reply Last reply Reply Quote 1
        • KnyteTechundefined
          KnyteTech @dc42
          last edited by

          @dc42

          PS_ON sounds cool, but I'd rather save that for something else down the road if possible - using the expansion pins sounds even better, so let's see if I can figure this out...

          I found this relay that appears to be what I need - 3.3VDC, low amperage (data sheet for reference)

          • EXP42 (GND) on the duet <--->GND on the relay

          • EXP43 (3.3v) on the duet <--->VCC on the relay

          • EXP45 (TWD0) on the duet <--->CTRL on the relay
            Is EXP.TWD0 a valid pin to use for this purpose? Or should I use something else?

          • Wire the camera trigger to the terminal block on the relay

          • Gcode to define the relay pin:

          M950 S1 C"exp.TWD0" ; create servo_1 for timelapse usage
          
          • Gcode to trigger relay:
          *retract + position printer for photo*
          M400 ; wait for moves to complete
          G4 P100 ; let vibration die down
          M42 P1 S1 ; activate relay
          G4 P100 ; hold relay closed for 100ms
          M42 P1 S0 ; deactivate relay
          G4 P300 ; wait 300ms for camera to take picture
          *de-retract and resume the print*
          

          Does that all seem correct? I did my best to google the crap out of all of this, but this is definitely not my specialty, so hopefully I'm not too wrong.

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

            @KnyteTech looks good, but I suggest you use P1 instead of S1 in the M950 command.

            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

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