Thursday, April 23, 2020

Fancy, No-Hack, Layer-Synchronized Time Lapse Videos of 3D Prints

A while back I wrote up the method I use to monitor 3D prints and even make time lapse videos. I use an old cell phone with a cracked screen and an Android app called Open Camera to snap pictures at specified intervals. Google Photos backs up the images as they are snapped so they can be viewed on any web browser. When the print is done I batch scale and crop the pictures in Irfanview, and finally turn them into a timelapse movie using ImageJ.

Since the Open Camera app is snapping pictures based on time interval, the extruder carriage appears to bounce around all over the place while the movie plays. I use lift-on-retract, so the bed bounces up and down in the video, too, like this:




If you want to snap a picture without the extruder somewhere over the print, you need to do two things- move the extruder carriage away from the print and then trigger the camera. Moving the extruder away from the print is easy- use some custom layer-change gcode in the slicer. If you trigger the camera immediately before or immediately after a layer change, the bed will not bounce in the video. The trick is in triggering the camera once the extruder gets to wherever you send it.


If you're using a phone (or some SLR cameras) to take the pictures, the semi obvious answer to triggering the camera is bluetooth. A couple years ago I got a free selfie-stick (remember those?) with a little Mooni handheld bluetooth button to trigger a cell phone camera. I didn't think much of it at the time and it ended up sitting in a drawer for the last couple years. But now I have a use for it! If you do a search for "bluetooth camera shutter button" you'll find dozens of similar things available from $5-20.


I continue to use Open Camera, even though layer synchronized time lapse doesn't need its intervalometer function, because it has both exposure and focus lock capability, not found in the native Android camera app in my Droid Turbo. In the video above, I did not set the focus lock and you can see the focus changing throughout the video, mostly depending on where the extruder carriage was in the frame when each picture was captured.



Three Steps to Success


Step 1:  Make sure your bluetooth button works with Open Camera on your phone/camera. I paired the button with the phone, started Open Camera, and pushed the button.  It worked!  That was easy.


Step 2: Figure out how to drive the bluetooth button device from the printer's controller. 


I recently posted about the very high precision of optical endstops and wondered about applications for rehoming the extruder at every layer change.  Maybe you could wipe the nozzle clean, detect layer shifting, etc.  Now there's one more use- trigger a camera so you can make fancy time lapse videos in which the print appears to grow out of the print bed with the extruder nowhere near the print.


I thought about chopping into the bluetooth button's PCB to add some wires but then I had to figure out how to get a signal out of the controller on every layer change, after the extruder was moved away from the print.


Then it occurred to me that there's a much easier way to go - just mount the bluetooth button in a location where the printer mechanism can push it.  No weird configuration in the controller and no wiring hacks needed, just send the mechanism to the button using custom gcode on layer change in the slicer. It can, but doesn't have to be, the home position.

Step 3: Figure out the best place to mount the bluetooth button on the printer and how it will get pushed. I designed and printed a bracket to hold the bluetooth button on the right side Y axis corner pulley block, and a corresponding "bumper" on the right side X axis pulley block. The bumper has a screw adjustment to set the Y position where the button gets pushed over a few mm range. In operation, at every layer change, I'll move the extruder to a specific X coordinate, then home the Y axis. When Y hit's home, it will also push the button and snap a picture.


It took a couple quick test prints to get the shape and size of the bracket to fit the bluetooth button, but once it fit, I finished the bracket design and printed it.  Simple!  Here's the Fusion360 model of the Mooni button and the slot that holds it. You'll have to add whatever it's going to take to mount it on your printer.


Mooni bluetooth button mount and pusher mounted in UMMD.  The Mooni button just drops in the slot.



Custom GCODE


I can send the extruder to any X ordinate (left-right) because it has nothing to do with pushing the button to make the photo sequence, but the extruder has to go to the back of the printer (Y=150), which means sending the entire X axis back there, in order to push the button. I could just move the extruder to the back of the printer without sending it to a specific X ordinate, but then it would be bouncing back and forth at the rear of the printer in the timelapse videos. I decided it would be best to send the extruder to the center of the X axis (X=0 in UMMD) to minimize the time it spends traveling, and so minimize print quality issues because of the relatively long time the extruder spends away from the print.  It also makes for nice symmetry in the photos and finished time lapse video, and my brain likes symmetry.

I created a custom printer profile (called "UMMD TL") in PrusaSlicer for making these movies that includes this custom gcode in the "after layer change" box:

G01 X00.00 Y145.00 F9000        ; go to (0,145) at 150 mm/sec
G01 Y150.00 F1200       ; go to (0,150) at 20 mm/sec and push the button
G04 P200                       ;  hold button for 200 ms
G01 Y145.00 F1200       ; back off the button
G04 S1.2                           ; wait 1.2 seconds for the picture to be taken
G01 F9000                     ; go back to the print at 150 mm/sec

If your printer's origin is located elsewhere, just set up the appropriate coordinates.  The 2 second delay is there because there seems to be a lot of variability in the time between pushing the button and actually snapping the picture. 

Note: I didn't use a G28 Y command to home the Y axis because that calls the Y homing macro in RepRap Firmware which moves quickly to the home position, then backs up and then slowly moves to home again. I didn't want that type of behavior for this.

As you will see in the layer synchronized time lapse video, below, moving the nozzle away from the print for a few seconds leads to some blobbing at the start of the new layer. The retract and unretract settings in the custom printer profile have to be tweaked to eliminate that problem.


Other Considerations


Making pictures this way adds a total of 3 seconds per layer. If the print is 100 mm tall and made of 500 layers, it will add 1500 seconds, or about 25 minutes to the print time. The time taken to snap a picture will depend on how large the print is, where it's located on the bed, and how fast you can move the extruder carriage out of the way to take the pictures.

The Mooni bluetooth button shuts itself off after 10 minutes of no activity, so if any of your print layers take 10 minutes or more (this is most common when doing solid fill layers at the bottom and top of a print) you may have to babysit it to push the button manually on each of those layers to keep the bluetooth button awake. Unfortunately that type of information isn't usually provided in the instruction sheet for these devices.

The Mooni button is powered by a CR2032 coin cell. I don't yet know how long it will last- so far I've got about 40 hours on one battery and it is still going. If you're making a super long print, you might want to put a fresh battery in the bluetooth button to ensure that it will last for the duration of the print. 

When you move the extruder away from the print, you want it to do so after the filament retracts (that's why the custom gcode goes in the "after layer change" box).

Open Camera allows you to select the resolution of the pictures right up to the maximum that the phone is capable of. That means you can see details in the print, which can be very useful. It also allows you to crop to a specific area of the still images to make your time lapse video. But, you have to be careful about selecting the resolution. If Open Camera runs out of memory to store the pictures, it stops making them. So do a little math- if your phone has 8GB of memory available, and your pictures are 15 MB each, you'll only be able to make about 500 images before the memory fills up. The same is true of Google Photos- the space to store images is limited by your account with Google. Choose a resolution to ensure that the phone/Google Photos won't run out of space before the print finishes.






Operation


When it's time to make a time lapse movie of a print, I slice using the custom time lapse printer profile, connect the bluetooth button to the phone, slide the button down into the bracket, mount the phone on the printer, start Open Camera, lock the focus and exposure, and start the print. At every layer change, the extruder goes to (0,150) which is the rear of the printer at the center of the X axis. When the Y axis reaches 150, it pushes the button and snaps a picture. Printing then resumes.


When I'm not making a layer synchronized time lapse movie, I just slice with a "normal" printer profile and leave the Mooni button out of the bracket. The screw that bumps the button has nothing to bump so everything behaves normally.

The Mooni button doesn't seem to mind the 50C enclosure temperature when I'm printing ABS.



Making a Movie From an Image Sequence


Once I have a sequence of images in the phone/camera, I copy them to a folder in my PC and use Irfanview (free) to batch process the images- crop, resize, color correct, rotate, etc., in one operation. Finally, Import the image sequence to imageJ (free) and Save As an avi file. That's it!


The Result


Here's an example of a layer synchronized time lapse video made using this setup:
As you can see, there's some interesting looking blobbing taking place at the back of the print.  I need to tweak the extruder retract and unretact settings to eliminate that.

You can expect to see more of these videos in future blog posts.

The user manual for the Mooni button is here.

4 comments:

  1. Any alternative apps to use with iPhones?

    ReplyDelete
    Replies
    1. If you're making a layer synchronized time lapse, you don't really need any special camera app, though the ability to lock focus and exposure will make for higher quality videos. I believe both AE and AF lock are available in Apple phone cameras.

      Delete
  2. I see you are having issues with blobs. Are you using a wipe setting? I just discovered this and it literally has changed my 3D printing life. I have no idea why people aren't more excited about this setting. In Simplify 3D I have the default 5mm wipe, and also "retract while wiping" in the advanced tab checked. I know Cura has a wipe setting and I think Slic3r does too. Hope this helps!

    ReplyDelete
    Replies
    1. Wipe helps primarily with blobbing at the point of retraction. The blobbing I get with this is at the point of restarting the extruder at the new print layer. That's a matter of tuning the unretract settings.

      Delete

Leave comments or a questions here and I'll try to post a response as soon as I can.