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.

Tuesday, April 21, 2020

COVID-19 Printing Projects

People all over the country are printing stuff for healthcare workers to help make up for shortages of PPE even though we have the GREATEST healthcare system in the WORLD! 
I have been doing some printing with a bunch of people from the Milwaukee Makerspace.

Bias Tape Folders



First it was bias tape folders for people sewing face masks. People were printing a design from Thingiverse.  I loaded up the bed and printed 50 of them in one go.  It took something like 20 hours. The design was excessively solid- like you could drive a tank over it.  Unfortunately I didn't keep any photos of them printing.


The original bias tape folder design from Thingiverse.  This is used to fold thin strips of cloth so it can be sewn to the edges of masks. It will never have any real mechanical force applied, yet the walls are 2 mm or so thick.


I redesigned it using the basic dimensions I pulled from the STL file on Thingiverse (why don't people post the CAD files?).  The new design used much less plastic and printed much faster because most of it is just 1.2 mm thick perimeters, so 3 passes with a 0.4 mm nozzle.  I printed a couple batches of 77 parts at a time, about 12 hours per batch.

My bias tape folder design.

The new design is more than solid enough to do the job of folding strips of cloth and will easily withstand being stepped on, though I can't say the same about the foot doing the stepping!


77 at a time.  I probably could have bumped it up to a 9 x 13 array.


Earsavers


Next was earsavers for people who wear the masks with elastic ear loops. I know from experience that those things can get pretty uncomfortable. 


Earsaver in use.

I printed a dozen of the preferred design from Thingiverse and it took 2 hours and 28 minutes. I managed to break a couple of them when I tried to pry them off the bed. Looking at the design and the way they print I decided to see if there was a better design out there, so I checked all the remixes on Thingiverse and didn't see anything I liked. 


The Thingiverse design for earsavers.  I can fit 12 on the bed at one time.

It was time for another redesign. There were numerous problems with the original design. It was too thick and inflexible (that's why they broke while I was taking them off the bed), there were many areas where the extruder has to lay down infill, which takes much too long, and there were too many sharp corners, all of which slows down printing.

Come on people!  We're trying to use a slow process (3D printing) to mass produce stuff as quickly as possible. You have to think in terms of how the slicer and printer work to minimize print time.  The forces applied to an earsaver by the elastic ear loops in just a few 10s of grams.  It doesn't need to be thick to do its job, and it's better for wearer comfort if the thing is flexible, and that means thin. If you want it to print fast, you want perimeters only. That means the structure of the print should be a small whole number multiple of the line width. Infill takes a long time, so eliminate it!

I designed the new earsavers so that everything would be a perimeter. I copied the gross dimensions and shape from the original STL file. The ribs are 2.4 mm wide, so 6 passes of a 0.4 mm nozzle at perimeter speed, and no infill. They print in only three, 0.25 mm layers using about 1 g of filament each, and 12 of them print in about 37 minutes (at 150 mm/sec).


Earsavers from Mark Rehorst on Vimeo.


The new design earsavers print in <1/2 the time and use much less filament, and come off the bed without breaking. They flex easily so are more comfortable to wear than the original design.

Here are the Fusion360 CAD files for my bias tape folder and earsaver designs.  You can DL the CAD files or just export STLs.

For anyone building a 3D printer, notice the location of the prints and the skirt in the photo above. You really can print literally edge to edge on the bed without autotramming and auto zeroing if you build the printer right.



Sunday, April 19, 2020

Tube Organizer for the Refrigerator

What are you supposed to do with all those tubes?


We eat a lot of Japanese food in my house. Many of the seasonings that are used in Japanese cooking come in squeeze tubes. They aren't very heavy and they tend to fall down in the refrigerator door shelves and get lost under the taller bottles and cans. 


At my wife's request, I designed and printed an organizer that will keep the tubes upright and can also hold some of the pouches of soy sauce and wasabi (or Taco Bell hot sauce, mustard packets, etc.) that typically come with grocery-store sushi. The shape is narrow so it will fit in the door shelves, but can also be put on a regular shelf in the refrigerator. Initially I designed it without a bottom, but later realized that it will be easier to deal with on a regular shelf if it has a bottom. Then you can just pick the whole thing up and take it to the table when you're eating, and put it back in the refrigerator when you're done.


Normally, when I design anything, I model the stuff that has to fit in the printed part first, but this was so simple I just made a couple measurements of tubes we had in the refrigerator, and the width of the refrigerator door shelves and started drawing.



This is it. About 10 minutes to draw and 5 hours to print at 80 mm/sec.


Overall size is 195x83x52mm. I designed it with 1.2 mm thick walls- just 3 quick passes of a 0.4 mm nozzle, and tough enough to withstand any sort of abuse it might have to endure without being excessively overbuilt. It'll probably hold up fine if you drop it on the floor. It's tall enough to keep things upright but still allow you to see the labels on the tubes.



Here it is on the printer, waiting for the bed to cool off before attempting to remove it. If you try to take it off while the bed is hot you're liable to damage the print.


It used about 37g of ABS filament. 
PETG would probably be good for this print, too. 



And here's the finished print.


The Final Test


This thing is going to hold food and there will eventually be leaks because someone didn't screw a cap on tightly, etc.  Wouldn't it be nice if you could just put the thing in the dishwasher with the dishes? I was curious about whether this thing (or any ABS print) would hold up under the chemical and thermal assaults of a dishwasher so I put it in with a load of dishes and ran a "sanitize" cycle that gets pretty hot.  No problem!  It came out looking perfect- no distortions or cracks anywhere.  Of course, that's just one cycle - the result may be different after 20 cycles.  I'll update in a year or two after many cycles through the dishwasher.

The Fusion360 file is here.

Thursday, April 16, 2020

iHSV Servomotor Information

I recently ordered a couple iHSV42-40-07-24 78W servomotors from China with the intention of trying them in the sand table and probably also UMMD. There isn't a lot of information on these things out there, and I spent quite a while searching, so I decided to place everything I found here so others may be able to make easier use of the motors.

The motors all appear to be made by Just Motion Control in Shenzen, and are sold by many companies that list on ebay and Ali-express. The specific motors I ordered are NEMA-17 size, but the same controller is found on NEMA-23 and NEMA-34 size motors, too.  One manual covers all of them.


The motor driver accepts 5V step/direction/enable signals like many stepper motor drivers, so you can drive these motors using anything you would use to drive a stepper. I spotted this device in a youtube video and it appears to be very useful for anyone who might be playing with either stepper or servomotors of this type:





You can find them on ebay for under $10. There are other parts with similar function, but this type can handle supply voltages up to 160VDC so you won't need a separate power supply to power this device for almost any stepper or servo motor you may be testing. Here's a link to an ebay seller, but it may disappear at any time.


I made a Fusion360 CAD model of the iHSV42-40-07-24 that you can download. It is primarily useful to get the overall size, but details such as the mounting hole spacing, length of the shaft, etc., are accurate enough to design mounts.  When I found differences between the actual motor and the drawing in the manual, I used measurements from the motor itself, so the CAD model is of the specific motors I received from China. As always, what you recieve from China may be slightly different!



Fusion360 model of the iHSV42-40-07-24 motor.


Printed motor mount for the sand table that I designed around the CAD model of the motor. There's an F625 bearing in the top of the mount to support the free end of the motor shaft.




To get optimum performance from the motors, you have to tune them for your specific application. That is accomplished by making an RS-232 serial connection to the motor and then using software that JMC provides to tweak about 100 different parameters.  You can use a USB to serial converter of this type to make the connection,  You can use a USB to RS-232 adapter of this type if your computer doesn't have a DB-9 serial port. Any adapter that says it uses a PL2303 chipset should work. The motors have spring terminal connections for wires, not a DB9 connector, so you'll have to either cut up an old serial cable or add a few wires to a DB9 socket so you can connect to the motors. You only need to connect the Tx, Rx, and Gnd leads from the RS-232 cable to the motor.  Be sure to connect the Tx output on the cable to the Rx on the motor, and the Rx on the cable to Tx on the motor. If you can't get the computer to talk to the motor, try swapping the Tx and Rx connections, most easily done at the motor.

Software to tune the motors is here. Plug n your USB to RS-232 cable, then unzip and run JmcServoPcControl.exe

Before you can tune parameters, you have to get your computer talking to the motors. The manual says the default communication speed is 9600 bps, but my motors were factory programmed for 57,600 bps, 8 data bits, even parity, and 1 stop bit.  The first thing to do when you open up the motor programming/monitoring software is to set the serial communications parameters. Once you get the software talking to the motors, there will be a few green lights on the bottom of the window in the software indicating that the motor is on-line. Then you can start tweaking parameters.

The manual for the motors is mostly useless other than to show what all the parameters are- there's no information about tuning procedures. I found that the software provides a bit more information about the parameters and clues to the settings, but you have to connect to a motor to be able to see that stuff. I grabbed screenshots of every page defining the parameters in the software and put them together in a zip file that you can download here. The individual pages are labeled for the specific parameter numbers they define so it is easy to find the one you're looking for. I may have altered some of the parameter values before I captured the pages, so you may see something a little different the first time you connect to your motors.

P01-01 parameter page from servo software


How do you know what to tune? There's the rub! I found some useful information on tuning servomotors at these sites:

http://s3.cnccookbook.com/CCServoTuning.htm

https://www.machinedesign.com/archive/article/21827276/tuning-servomotors
Parker Motion Servo Fundamentals

There appears to be three main operating modes for the motors, speed, position, and torque control modes, selected by the P01-01 parameter (see image above). The motor driver has some autotune modes built in to simplify the tuning process. If you enable one of those modes, the driver will make adjustments on the fly to optimize performance for speed, positioning, or current. Check page 19 of the motor manual for the P01-02 parameter setting. Once you've selected an operating and autotuning mode, there remains just a few variables to adjust manually.  The Parker Motion white paper linked above has a pretty easy to understand explanation of the process of tweaking the remaining variables.


I ran into a few youtube videos of people doing various things with the NEMA-23 and 34 versions of the motors. There's a good series of videos, in German, that go into some detail about tuning the motors for a CNC machining application:





















Saturday, April 11, 2020

Cell phone Mount #2 for UMMD

Who Needs RPi?


A while back I posted some info about using an old cell phone to monitor 3D print progress.  I used my old Droid Turbo phone with a 24 Mp camera, an app called OpenCamera, and Google Photos to capture the images and make them viewable via any web browser, all without any advertising or subscription fees.

The mount for the camera used suction cups to stick it to the clear front panel of the printer. 




That works fine when I need to keep the printer closed to print ABS, but looking through the cover reduces the image quality a bit. When I'm printing PLA (rarely), TPU, or PETG, I can keep the printer open, so I decided to design a mount that will allow me to put the phone on the printer's frame without the front cover in place.


The New Design


The mount prints in 6 pieces-  3 thumbwheels, the camera mount, an armature, and the frame bracket. It uses a t-nut to mount on the 4040 t-slot frame of the printer.


CAD rendering of the phone mount. The phone slides into the mount and is held securely.  Everything is repositionable. 
CAD rendering of the back side of the phone mount.



The thumbwheels are my "standard" type, that were detailed in this post.

Here is the finished phone mount on the printer:


The camera's field of view captures the entire print bed.


The underside of the phone mount.
Back side of the phone mount.


Another view.  The white dots on the back of the phone are the velcro tape that secures the phone to the original suction cup mount.


Mounted on the printer. This mount would work even when the printer is closed, except that the front slot gets covered by the lower front cover.


You can see what the camera sees here.  In operation the camera will be powered via the uUSB port on the far right edge of the phone.
The Fusion360 CAD file for this design is here- you'll probably have to make a lot of modifications to suit your phone and printer, but it's there if you want it.

I may cut a notch in the lower front cover of the printer to allow this phone mount to be used even with the cover in place.

Here's a high resolution time-lapse video of a 14+ hour print I made a week or so ago.  This one is looking through the front cover of the printer. I reduced the high res images to 720 vertical pixels to make the video.  The only thing I don't like about OpenCamera is there doesn't seem to be any way to fix the focus of the camera, so it tends to hunt a bit and focus on different areas in different frames, especially if the extruder carriage is anywhere near the center of the frame.  Actually, Open Camera does allow fixing the focus- it is one of the options in the settings menu, just not very clearly labeled. In the video below, I did not use the fixed focus setting, but will do so in the future.