Welcome! Log In Create A New Profile

Advanced

End-gcode to take a picture with webcam?

Posted by BSBMX 
End-gcode to take a picture with webcam?
December 20, 2013 01:39PM
I think I remember seeing somewhere online of a line of gcode that would instruct a webcam to take a picture. I'd like to place this code in my .end gcode file so that I'd have an image of the print when it's finished. Does anyone know this line of code, or could link me to it, or have any other idea for doing this? I primarily print from an SD card.

Also, there's a new feature in MatterControl that can text or email the user when a print is finished. Is there a way I can do this with gcode? I don't always use the MatterControl program, but I like that it can text me when a print is finished, and I'd like to have that capability with a gcode format.
Re: End-gcode to take a picture with webcam?
December 20, 2013 02:35PM
From the Marlin source code:
M240 - Trigger a camera to take a photograph
and:
    case 240: // M240  Triggers a camera by emulating a Canon RC-1 : [www.doc-diy.net]
     {
      #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
        const uint8_t NUM_PULSES=16;
        const float PULSE_LENGTH=0.01524;
        for(int i=0; i < NUM_PULSES; i++) {
          WRITE(PHOTOGRAPH_PIN, HIGH);
          _delay_ms(PULSE_LENGTH);
          WRITE(PHOTOGRAPH_PIN, LOW);
          _delay_ms(PULSE_LENGTH);
        }
        delay(7.33);
        for(int i=0; i < NUM_PULSES; i++) {
          WRITE(PHOTOGRAPH_PIN, HIGH);
          _delay_ms(PULSE_LENGTH);
          WRITE(PHOTOGRAPH_PIN, LOW);
          _delay_ms(PULSE_LENGTH);
        }
      #endif
     }
    break;

So if you have appropriate hardware connected to emulate a Canon RC-1 then it can be done.

Regards,
Neil Darlow


I try to write with consideration for all nationalities. Please let me know if something is unclear.
Printing with Mendel90 from fedora 25 using Cura, FreeCAD, MeshLab, OpenSCAD, Skeinforge and Slic3r tools.
Re: End-gcode to take a picture with webcam?
December 20, 2013 05:10PM
I think later versions of Pronterface might be able to run scripts on events. If not I am sure OptoPrint will be able to.

Edited 1 time(s). Last edit at 12/20/2013 05:11PM by nophead.


[www.hydraraptor.blogspot.com]
Re: End-gcode to take a picture with webcam?
December 22, 2013 08:33PM
OctoPrint has an event hook mechanism, where you can execute commands when certain events occur. The list of events (along with some examples) is at:

[github.com]

And there are more examples in the cookbook:

[github.com]

(I haven't yet tried them, but plan on hooking into the PrintStarted / PrintDone to create a log of prints I've done, and have the Waiting one send me an android notification to change filament colours etc).
Sorry, only registered users may post in this forum.

Click here to login