16. Wild card¶
¶
Aims¶
The idea of this week is to do something that we have not done in the other week. considering that we are in lockdown since 5th week anything that we will do would be wild.
kidding…
the team in fablab Barcelona push this week and setup an amazing CNC by the sea. we got access through a web interface to a CNC machine on top of a sand box. This allow us to generate some marlin gcode and run it on the CNC.
CNC by the Sea¶
For the design and g-code generating I have used grasshopper. because the workflow was very seamless. I started with a design then I could constantly generate g-code and simulation thorough my design process. Also this made the debugging easier.
Design¶
First I made a simple script to make cleaning for the board. So I made the path in a way that make the jogging path to minimum and cover most of the working area of the machine with the possibility to adjust the working area that you need for your piece. Moreover, you can choose the resolution of the cleaning by setting the distance between the lines.
After that I made couple of random generated design patterns using grasshopper. I used a grasshopper plug-in to generate maze in a rectangle. Also as always I tried my Hilbert curve.
Generate G-code with grasshopper¶
In grasshopper, to process the curves to the gcode we had to convert them to polylines. After that we need to deconstruct the polylines to the lines. After that we separate the lines and generate the jogging paths to reach to each separated pieces. Then we use text formatting to format the start end point of each path to the G-code. At the end we stack all of the lines together to achieve a gcode text which later on we can save it in a file and send it to the machine.
remote connection to CNC¶
To make this happen the instructors has set up a cncjs on RassberryPi in the lab which is a JavaScript Web interface for cnc control. furthermore, in order to get some visual they connect two camera streaming system which allow us to get approximate understanding of Machine movement. At the end they made the revers proxy server using Nginx to make a safe access point from outside world.
You can follow up their documentation here!
My understanding from this system is that in fablab they connect RassberryPi to local network and set web server (cncjs) on it. After that they used mjpg-streamer to setup the cameras for Rassberry. Also, the Rassberry connected to the cnc board which is a Arduino Mega with marlin firmware running on it. After setting up this locally in order to make it available trough the intent they setup a static IP address on a DHCP server. So basically whenever we send the request from our computer it goes to DHCP server and they return the IP address. Now from our router we will rout to the fablab router. From there, The fablab router will return the cncjs webapp that runs on the RassberryPi.
PS: This is my interpretation form the documentation on the setup of this system and it may have some false information.
Running CNC¶
this is the part that I have done. At first I connect to the camera streams through the static IP s that provided by instructors. Then connect to the CNCjs server through a log in safe process. At the beginning I had a lot of widget in the window which were annoying later on I add a modification json file for interface.
The rest of process was just opening a usb port to the cnc and I could move the machine from my home. Fantastic!
Generate GCode¶
In order to do so I used grasshopper and couple of user object developed by my instructor.
The basic function of the component is that it reduce a nurbs curve to polylines and then take
the coordination of each line and constructing a G1
command for marlin firmware.
G1 X145.00 Y581.75 Z24.09 F3000
Then there are the jogging command which has been handled by G0
command.
the path of it generated from end point of the last path, start point of the next one,
and the jogging height which is a user input.
Also there was servo connected to the board which was controlling a blade to wipe the sand.
the command to access it is M280 P1 S90
.
I used it a lot to draw instead of cleaning.
Final sand drawing¶
In the following I shared couple of my designs and final results on the machine. it was definitely a fun experiment.