Friday, March 25, 2016

Chilipeppr GPIO JSON Server Setup

On the Chilipeppr interface, I noticed there was a button under Workspace TinyG titled GPIO. When you click on it, it gives you two options:

  • 'Download the GPIO JSON Server (Raspberry Pi & BBB) 
  • 'Connect to Host'

So, I went to the google machine, entered 'chilipeppr GPIO' into the search bar and came across this post from John Lauer. Basically, this feature will allow you to configure GPIO pins on the Raspi or Beagle Bone Black which can be controlled through the Chilipeppr interface. Sounds to me like we need a relay and we can remotely control our spindle (on/off, no speed) and vacuum!

Safety note: Do not mess with mains voltage! You can seriously shock yourself or even cause death. Please consult a professional.


Items used in this build: (purchasing through these affiliate links helps me to hack on)



How to install GPIO JSON Server on a Raspi2

As with most of my raspi tutorials, please make sure download and install an OS for the Raspi. I chose Raspian - Here is an installation guide. Then make sure to update and upgrade your OS before continueing. 


Step 1: Download and 'install' the server to your Raspi (<1 min)

To download the gpio-json-server directly on your raspi, type in:
wget https://github.com/benjamind/gpio-json-server/raw/master/gpio-json-server

Then to make the file executable...
sudo chmod +x gpio-json-server

And to run it...

sudo ./gpio-json-server
At this point you should be able to connect to your GPIO JSON server through chilipeppr by entering your Raspi-ip address into the GPIO widget.

Step 2: Automatically Start GPIO JSON Server on Boot (~2 mins)

If you followed step 3.1 from my X-Carve TinyG and Raspi post, you should have a file set up to start up the JSON server when your raspi boots up. If not, go back and look at that step first. 

Now, we need to edit the auto-start script to include the GPIO JSON server as well.

First, we need to know the location you placed the gpio-json-server. Mine was located here:

/home/pi/gpio-json-server
Then we need to add this file location to the /etc/init.d/serial-port-json-server file:
sudo nano /etc/init.d/serial-port-json-server

Within the file enter your gpio-json-server location from above after the '#do something" line as shown below in blue.
case "$1" in
  start)
    log_begin_msg "Starting Serial Port JSON Server service"
# do something
        /home/pi/serial-port-json-server_linux_arm/serial-port-json-server -regex usb|acm &
        /home/pi/gpio-json-server
Be sure to add an '&' at the end of the line above the blue location to ensure both files are started. Then all we have to do is re-build the auto-start script.
sudo update-rc.d serial-port-json-server defaults


Step 3: Reboot Raspi and Enjoy (~2 mins)

Reboot your Raspi, 
sudo reboot
and enjoy GPIO control through Chilipeppr!


Step 4: Hook up your relay

Go to the google machine and search 'Raspi relay' to learn how to wire up your GPIOs to a relay.




Resources:



X-Cam Part 1: X-Carve Spindle Camera for Positioning

After several weeks of running my X-Carve, I have wanted to connect a webcam to my Raspi in order to:
  1. More accurately set the home position of a work piece (i.e. Zeroing CNC with Camera)
  2. Monitor a carve (a different post)
  3. Create a time lapse video of a carve (review when things go wrong)
Previously, I had used a Raspi to create a motion detecting security camera and video streaming device (that was recently replaced by a Canary); therefore, I knew it was possible to transmit video from a Raspi over the web to be viewed in a web browser. The question now was just how to do it...

After some research on Chilipeppr, Raspi and the TinyG, I came across many of the articles listed in the reference section, which eventually led me down the rabbit hole of the mjpg-streamer. This article claimed that one could stream 30FPS video from a Raspi2 to a web browser with extremely low CPU usage (<15%); sounds like a winner!

Items used in this build: (purchasing through these affiliate links helps me to hack on)

How I Installed mpjg-streamer for Raspi2

I followed this tutorial put together by Rober Cudmore (thank you!!!) for the most part; had to hack it a little bit to make it work for me.


Step 0: Get a Raspi2, Install Raspian and update and upgrade it.

I used a Raspberry Pi 2 for this build as it is what I use as my JSON sever for my CNC machine. THe 4 cores of the Raspi2 make it great for this build, so I do not have to worry about the camera(s) streaming affecting the commands sent from Chilipeppr (CNC control program).

Download and install an OS for the Raspi. I chose Raspian - Here is an installation guide.
sudo apt-get update
sudo apt-get upgrade

Expand the file system and enable the camera with:
sudo raspi-config

Step 1: Install mjpg-streamer

install libjpeg8

Check that USB camera is detected by the Raspi:
lsusb
Now check the format of the camera with:
v4l2-ctl --all
Output from Pi.... (about half way down you will see 'Pixel Format' - this is important to note for later)
   :
   :
 Pixel Format  : 'MJPG'
   :
   :

Now let's download the mjpg-streamer...
 wget http//sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip

and upzip it...
unzip mjpg-streamer-code-182.zip

and then build it...
# build with 'make'
    cd mjpg-streamer-182
    cd mjpg-streamer
    make mjpg_streamer input_file.so input_uvc.so output_http.so

Now, let's copy some configuration files to a new location...
# install by copying
    sudo cp mjpg_streamer /usr/local/bin
    sudo cp output_http.so input_file.so input_uvc.so /usr/local/lib/
    sudo cp -R www /usr/local/www

And change the LD_LIBRARY_PATH to where we copied the previous configuration files...
#export LD_LIBRARY_PATH=/usr/local/lib/

If all went well, we should be able to run it with:
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so" -o "/usr/local/lib/output_http.so -w /usr/local/www"

Well no errors were thrown, but there is no video displayed in the browser (see below for links to view)...

Raspi Output:

MJPG Streamer Version: svn rev:
Using V4L2 device.: /dev/video0
Desired Resolution: 640 x 480
Frames Per Second.: 5
Format............: MJPEG
Adding control for Pan (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Tilt (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
 : 
 : 
www-folder-path...: /usr/local/www/
HTTP TCP port.....: 8080
username:password.: disabled
commands..........: enabled

Let's go to the google machine... 
    Search Term: 'UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device'


After some reading and deciphering, I found this forum that gave some insight to the issue. With some trial and error, I got it running with the following command:
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -n -y f 15 -r 640x480" -o "/usr/local/lib/output_http.so -w /usr/local/www"

Here is a snap shop of the stream (viewed at http://<raspi-ip>:8080 or http://<raspi-ip>:8080/?action=stream



Step 3.1: Reduce CPU Load (optional)

Using htop, I noticed it was running at 100% CPU for one core. I knew this could be reduced from reading this article, so I gave it a shot.

Install vlc

sudo apt-get install vlc
Create a script to run vlc with the desired settings...
sudo nano videostream.sh
Make it executable:
sudo chmod +x videostream.sh
Then run it:
./videostream.sh

I got some errors (shown below), but it still works...
@JsonCNCpi ~ $ ./videostream.sh
VIDIOC_ENUM_FMT: failed: Invalid argument
unknown control 'compression_quality'
Frame rate set to 30.000 fps
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x197dee0] inhibit interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0x197dee0] main interface error: no suitable interface module
[0x1981230] main interface error: no suitable interface module
[0x18118f0] main libvlc error: interface "globalhotkeys,none" initialization failed
[0x1831850] dummy interface: using the dummy interface module...

Here is a snap shop of the low CPU use stream (viewed at http://<raspi-ip>:8554/webcam.mjpg)



Step 4: To view your mjpg stream:

Type this into your web browser to access the interface
  http://<raspi-ip>:8080

Type this into your web browser to view the stream directly
  http://<raspi-ip>:8080?action=stream

To view the stream using the low CPU stream:
  http://<raspi-ip>:8554/webcam.mjpg



Step 4.1: To view your mjpg stream within Chilipeppr:

To view you webcam stream in Chilipeppr, head over to http://chilipeppr.com/xpix




In the Cam(v1) widget, click on the gear (settings), and enter in your MJPEG URL. Click close and you should be able to see your webcam view. 



Note: By hovering over the screen shot, the image will zoom in 4x.
Note 2: You can set the X and Y offset along with the real distance width fields to use your camera as an accurate positioning device. 




Step 5: Auto-Start Camera - Coming soon 




Resources

Wednesday, March 2, 2016

Flux Delta First Impressions

Now that I got the Flux Delta all set up, lets give it a try. One of my favorite STLs to print with any new printer is called 3DBenchy. Not only is it a cute little boat you can give to a friend, but also tests a variety of things such as dimensional accuracy, overhangs, gaps, and much more as detailed here.

Step 1: Download the STL.
Step 2: Import STL into Flux Studio.
Step 3: Click 'Start'




and now we wait... for 2 hr 12 mins...

or 3 minutes...

Bad Adhesion look like...
Looks like we got a case of bad adhesion... Click 'STOP' (or hold the white Flux button on the front of the printer), and we will adjust a few settings...

Restart and wait for it... or 4 minutes later...

Bad adhesion again...

Another case of bad adhesion... Click 'STOP', adjust a few settings, and do some research...

Restart and another 5 minutes later...

Another case of bad adhesion... Click 'STOP', adjust a few settings, and do some more research...

Restart and another 5 minutes later...


Bad adhesion... STOP, adjust a few settings, do some more research...
Bad adhesion... STOP, adjust a few settings, do some more research...
Bad adhesion... STOP, adjust a few settings, do some more research...
Bad adhesion... STOP, adjust a few settings, do some more research...
Bad adhesion... STOP, adjust a few settings, do some more research...


After many failed attempts, I finally got something to stick (punny :) )! Surface prep for this build consisted of cleaning the build platform with acetone and then randomly and slowly applying glue stick from a few seconds after I clicked "Start" in the Flux Studio until the print head started to move...

It's Working! It's Working!
Here are the settings I changed and what they were set at for this build:

  • brim_width = 5
  • first_layer_extrusion_width = 140%
  • first_layer_height = 0.2
  • first_layer_speed = 15
  • first_layer_temperature = 220
  • raft_layers = 3
  • skirt_height = 1
  • skirts = 4

and now we actually wait...

15 minutes into 3DBenchy
30 minutes into 3DBenchy
60 minutes into 3DBenchy

90 minutes into 3D Benchy

and wait, what?!?!? It's done!

Flux Delta 3D Benchy Trial 1

Some Stringing, some trouble on overhanging circles, overall good quality!
Stringing through doorways

Back Window stringing and overhang loop

Stringing in front of 3DBenchy


My initial impressions are as follows:


  • Documentation: Poor
    • There is hardly anything in the manual, I found a post in the forum that helped, but seriously this needs some work.
  • Set up: Simple
    • Closest thing to a 'unpack,' plug and play printer I have encountered.
  • From Set up to Print: Average (luck is involved)
    • Due to the precision required and all the variables involved with getting a good print, there is some luck involved after shipping a machine to the other side of the globe. That said, with a little perseverance and patients, I was able to get this printer working in a reasonable amount of time.
  • Software: Needs improvement
    • Definitely an 'Alpha' version. Issues so far: Can't use camera while printing... Why have it there if you can't remotely monitor the print and view a time lapse of the print afterwards!?!? Once you exit the device manager (to see progress), you can't reconnect to printer? Error/bug? Availability of settings is alright (through the advanced menu); however, I could not set the first layer to print at 230C.
  • Hardware: Seems okay... 
    • I like the wifi and the USB port; however, not having a display will require that a mobile app be created or the computer application work for remote monitoring. As far as the durability and maintenance of the machine, only time will tell.

Overall, I am happy with my purchase at this time. It is a sexy looking machine that took some work to design and built. After a little tuning and swearing, I was able to print a 'challenging' piece with better than average results. Some fine tuning is required to get the machine to my quality standards, but this worked better than most out of the box! For proof of those 'better results', stayed tuned!


From my research I also came across these posts that were interesting:

Here are the next few things I plan to print:

  1. Universal Oil Filter
  2. SD Card Mountain
  3. Lightsaber
My next steps will involve using the scanning and the engraving/drawing options!

The Wait is over!!! The Un-boxing and Setup of The Flux Delta 3D Printer

After a slight delay (original ship date of July 2015), my second Kickstarter based 3D printer actually arrived, on a day with a massive snow storm (March 2016). I rushed to get home; it only took twice the amount of time with an average HR of over 120!


After all this time, what did I get???

The package was covered with a dusting of snow, and only had one small dent in the lower corner of the outer box.


Upon opening the box, I found a drawing module and roll of filament nicely placed at the top of the package.



After removing the drawing module and filament, I was able to use the yellow straps and lift the printer box out of its outer shell. No damage seen on this box! Quite an impressive feat traveling from Taiwan to Michigan! 


After cutting off the yellow straps and opening the box, I found this impressive looking packaging holding the ~1/8" aluminum printing bed perfectly cradled by copious amounts of foam.


Take out the build platform and grab the handle to remove the foam. Companies that spend time creating designing quality packaging like this must also spend a ton of time on the product itself. Only time will tell...


There it is! My beautiful Flux Delta 3D Printer!


Here it is after I removed it from the box. Not even a scratch on the thing. What is that cardboard that seems to have encased the bottom of the print? Keep reading...


In the box strategically placed within the bottom of the printer frame was the manual, the magnetic rods to attach your 'printing' tool...



Let's Get Thing Working!

On a side note, I really like the magnetic rods used on this Delta printer. They 'snap' right in place and held rigid in the position they were attached, while allowing rotation at the joints as required by the Delta mechanism. 


... the printer module. Is it just me, or is this packaging spectacular?


Add the cables! (a micro usb cable, a power cable, and a printer module control cable - maybe USB-C?)



Also included in a package near the filament was some lovely Japanese Scotch Glue stick and a scraper (to assist with parts sticking to the build platform) 


Here is the printer fully assembled. The Bowen tube (filament from the roll to the extrusion head) was in the top of the printer (with an extra!) and was really easy to install. [i.e. screw the end with the screw into the printer module and press the open tube end into the top of the printer at the other connection.] 
Add the printer control cable to the top of the module and then plug that in to the top of the printer (close to the Bowen tube location - kind of hard to see). Make sure you press this connection in all the way or you will not be able to print anything!


Next, I followed these instructions on setup from the Flux Forum.

Things to note during setup:
  • Lubricate balls at end of rods. I did this by touching the ball to the lube, then spreading evenly with finger.
  • Install build platform with UNPRINTED side up.
  • Apply two layers of glue for better adhesion.


After some (user) issues installing the software and upgrading the firmware (see below for tips), I applied some glue to the base plate and clicked print... 

 


Drum roll please... Well after 1.5 hours of printing (why start small?)... Wait for it... 



No seriously, my next post will be about first impressions of the printer.


Slight Software and Firmware Issues

After connecting my printer to my computer and setting it up via the software, I was informed I must upgrade my firmware. With the firmware that was installed on my printer prior to shipping (arrived 3/1/16), you must use a USB drive to update the firmware. After this update, it looks like the firmware will be updated via wifi and the Flux Studio.

To update your firmware, follow these steps.

After several attempts to update the firmware (restarting after waiting 10-30 minutes), I found this forum post. After reading through it, I re-formatted my USB drive as FAT32, and then retried the updating firmware "Through USB drive"

It was like magic! The lights behaved as they said in the instructions (~3 minutes), then the machine homed itself (to the top) and I was ready to begin printing!