Saturday, May 24, 2014

Cloudify: setup reprap 3D printer with octoprint, mjpg_streamer on raspberry pi

Cloudify: setup reprap 3D printer with octoprint, mjpg_streamer on raspberry pi
The process to 3D print a 3D model can be quite an obstacle, i.e need to have physical access to the 3D printer and a SD card handy, power hog, heat emission, UFP emission. What if we can remotely send a 3D model (in *.STL) to be 3D printed on a 3D printer and also observe the 3D printing process over the Internet? Definitely it is going to be convenient as everything can be done at the fingertips; godsend piece of technology for those can’t wait for the 3D printers to be locked down in a facility equipped with exhaust and medical grade filter that is capable of filtering Ultra Fine Particles (UFP) in the range of 100 nanomether that is much finer than PM2.5. The purpose of this article is to share a step by step guide of setting up 3D printer to print remotely.
Raspberry Pi is acting as the “brain”, wirelessly receiving GCODE (instructions for the 3D printer to work by processing a 3D model file in STL using software such as Slic3r http://slic3r.org/ ) from the front end that is interfacing between human and 3D printer via OctoPrint http://octoprint.org/ providing minute control over the 3D printer; feedback to human by streaming 3D printing process via MJPG_streamer http://sourceforge.net/projects/mjpg-streamer/ . Most 3D printers in the market have only 1 MCU, e.g 1 brain. Usually 3D printing is done by inserting a SD card that contains the GCODE and to be read by the 3D printer. Having a second brain opens up more opportunity to build computing capacity for the 3D printer. Cloudify, refers to scaling up this computing methodology to support more users and more 3D printers.
A quick note: Raspberry Pi is sensitive to power drop, especially when there are a few components drawing substantial amount of power to operate. One of the tell-tale sign is when a keyboard is plugged in to console the raspberry pi, the keystrokes appear to be non-responsive.
Another not so quick note: Throughout this process of setting up, yours truly learnt that apparently not all USB webcamera out there work out of the box on the raspberry pi. The details steps of configuring and observations done are recorded at the end of this article.
Parts needed
  1. RepRap 3D printer or equivalent, known baud rate of the 3D printer e.g 250000
  2. Powered USB hub, preferably 5V 1A; (tested with Belkin F4U020)
  3. USB webcam (tested both Creative VF0220; A1 pro M035 ); list of tested USB webcam on raspberry pi is here http://elinux.org/RPi_USB_Webcams
  4. Raspberry Pi as the controller/brain;
  5. WiFi adapter;
  6. WiFi Access Point; IFF necessary
Steps required
  1. If there is an existing pi setup and reflash the SD card image is not an option, build octoprint on your raspberry pi https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian. Alternatively, download octopi image https://github.com/guysoft/OctoPi; it is a custom fit raspbian with the goodies such as octoprint, mjpg_streamer, and more!
  2. Setup WiFi access for the raspberry pi. Depending on the WiFi network connected to, the wpa_supplicant.conf will vary. Here are 2 examples of configuration http://shin-ajaran.blogspot.sg/2013/06/raspberry-pi-connecting-to-wifi-in-ucl.html ; http://shin-ajaran.blogspot.sg/2013/06/a-poor-lads-guide-to-install-raspberry.html
  3. Wire the parts according to the following picture that describes the wiring connection
 
  1. Turn on the powered USB hub, the reprap3D printer, the WiFi Access Point (If used)
  2. Console in via SSH using Putty or equivalent;
  3. Issue the command “lsusb” to verify the devices are mounted accordingly to raspberry pi
  4. Navigate to the ip-address using firefox or safari and be presented with the GUI of OctoPrint. On the upper LHS select the appropriate interface where reprap3D printer is connected e.g ttyUSB0 and the corresponding baud rate e.g 250000. Failure in doing so, the reprap 3D printer will not be interfaced. The following diagram describes the reprap 3D printer that is connected to octoprint

  5. Determine the control between the OctoPrint and reprap 3D printer by setting the temperature and observe the temperature over time. The following diagram describes the temperature recorded over time
  6. Click on the control tab. If the webcamera work out of the box, there should be a live feed in this tab as describe in the following picture. Otherwise, refer to the appendix on configuring USB webcams/troubleshooting
  7. Streaming of the 3D printing process can be observed from a browser pointing to http://IP-address/webcam/?action=stream
    D:\eee tech lead\octoprint reprap\wa3.PNG
  8. The GCODE viewer tab is a visualization of GCODE used in progress. The following diagram depicts the progress of printing an Arduino Yun Bumper. The step by step guide to 3D print with this computing methodology is available here
Appendix: troubleshooting the webcam for streaming
Finding the right USB webcamera (model/make), the right picture format (JPEG;YUY2), the right resolution (640x320, etc), and the right frame per second (fps) for mjpg_streamer on Raspberry pi is a tedious process. Getting the usb webcam to work is a little bit trickier than expected. Having a usb webcam that is not listed on the supported webcam on raspberry pi doesn’t help either. So yours truly is left on his own to conduct a few rounds of A/B tests.
The location to configure the webcam daemon that uses mjpg_streamer included in octopi is available at “ /home/pi/scripts/” the parameters associated with the webcam can be modified in the script “webcamDaemon” available in that directory. After completing the changes, save the file and execute the script. If this screen is encountered, a reboot of the raspberry pi is required.
The following describes the parameters used to determine the best output with Creative VF0220
##VF0220
#YUY2 320x240 @10fps = green
#YUY2 320x240 @25fps = green, hang after a while
#JPEG 320x240 @10fps = varying colour according to light. hang after awhile;cannot boot complete
#JPEG 320x240 @15fps = partial works with varying colour
#JPEG 320x240 @25fps=same as above with more frames of lights
#JPEG 320x240 @1fps = cant open cam; cannot boot complete;hang.
#JPEG 640x480 @15fps = varying colour then hangs very fast
#JPEG 640x480 @1fps = varying colour then hangs afte a while; then throw 503
#JPEG 352x288 @8fps= throws 503
#YUY2 352x288 @8fps= throws 503
This is the best can be achieved with VF0220


Courtesy of TSO Mark, yours truly get to use an USB webcam that is marketed locally as A1 pro, but recognised as M035 on raspberry pi.

The following observations are recorded
##M035
#JPEG 352x288 @15fps = no disp
#YUY2 352x288 @15fps = ok; hang if move camera too often.
#YUY2 352x288 @8fps= ok; no hang

1 comment:

justin albert said...

Excellent is the only word i can give u for this wonderful blog, keep it up. I will come back again to read some more interesting things on this topic

Photocopier Repairs Basildon