17 - Mechanical design - machine design
Intro
The goal for this assignment was to made a machine that makes something using the Gestalt framework. Making a CNC machine is a complex work made by many parts. For this reason this was a group assignment and you can see the final result on the Frosinone Fablab page. In the division of the task I decided to program the Gestalt framework to make the machine work as I wanted to practice with Python and I want to learn how to use stepper motors.
The hardware
Our kit included these elements:
- 4 stages = stepper + rod bar
- 8 guide bars
- 4 gestalt circuit boards
- misc materials as nylon bearings
- RS485 connecting cable
- 4 resistor
- plugs
The nodes are connected each others in a chain (daisychain) with a ribbon cable and then, through the fabnet and the RS485, to the pc
In group we decided to make a foamcutter machine similar to the one described here . However we simplyfied it making the two z axes working together. So the result was a 3 axis machine (with two motors moving the Z axis). We used the power supply of our lab.
Programming with the Gestalt framework
I started downloading the framework and reading this documentation and this tutorial . I alse red the work of Ellison Moyer. The architecture of the Gestalt framework is very interesting. Each node is networked and is represented inside a virtual machine. In this way it is very easy to configure a new machine. I didn’t find an extensive documentation of methods and properties of the gestalt library so I did a bit of reverse engineering using the examples and the comments in the code. A very useful file is functions.py that is well commented and helps understanding the main methods of the library. Moreover I studied also the remote procedure call routines using also the page http://tq.mit.edu .
To make the machine work you need to install the gestalt library with python setup.py install
If not installed, install pyserial. Indeed pygestalt need pyserial for serial communication with the nodes. It is important to do not hot plug the boards. So the correct procedure is connecting the boards together and to the Fabnet, connect them to the pc and then to the power supply. To connect the boards together you can use a ribbon cable. Pay attention to the two connectors on the board. One for in and one for out. Always check the polarity when plugging the cable. Moreover the power supply should be setted up to provide 12 V and (I discovered while using the nodes) up to 2 A.
From a software point of view if you want to create new machine you have to import the Gestalt library
then you define the virtual machine class that is a set of functions and parameters that defines the machine (i.e. number of axis, kinematics etc)
then you tell to gestalt how to connect with the nodes. Here is important to change the name of the serial port used:
a very important part is the definition of the axis. Here you can define how many axis will have your machine. In the definition there is also the python file that describes the virtual node class, with important parameters and routines of the nodes. We have 4 nodes of the same type but you can have different type of nodes together. The last line defines the compound nodes. It is useful as you can treat the nodes as one. Sending a command to a compound node affects all the nodes that are listed in it.In our case we have two axis (z and k) that make the same moves
Another important point is where you can set the kinematics properties of the nodes. They depends on the physical characteristics of the nodes used (step, microstep, pulleys etc). It is very important to correctly set up the parameters or it will result in an incorrect movement of the node especially regarding the correspondence between the machine coordinates and real world coordinates.
The you can initialize the functions for moving the machine. You can see the corresponding class in the functions.py file. Here we initialize the map and the job command. As we have a compound node (z and k) we set it as the third argument that will be sent to the machine. However I had problems making the machine work with a compound node. Even if I checked the code a number of times I wasn't able to solve it so I continued sending commands separately to the two axis used for Z (z and k in the code).
When you create an instance of the machine with this line instancename = virtualMachine(persistenceFile = “filename.vmp") you create a “persistence file” that stores the machine configuration. Indeed when you first run your code the nodes will start flashing and a message will ask you to identify the axis. You have to press a button on the the gestalt board to tell to the system the correct axis sequence. I started making two nodes working using the xy_plotter.py example. You can see in the video above the procedure to identify the axis:
If you want to reconfigure that you just have to delete the .vmp file. Then you can choose the way you want to control the machine. You can include the virtual machine into a python program, you can put the commands directly into the code or you can use the RPC to remotely call the functions of the gestalt. I used the last one as I think it is the more flexible. You can expose functions with this command
Using RPC is very useful as I can make any kind of interface using a webpage (with Javascript) or another programming language without touching anymore the server written in Python. This makes the system very flexible. As I didn’t find a complete documentation to better understand how to call the remote procedures I analyzed the calls made by the site http://tq.mit.edu. In the video above you can see the stepper moving using the tq.mit.edu interface:
I made a first interface prototype visible at http://www.my-id.org/utilities/test_interface_5.html that sends commands to the machine using ajax calls. I planned the following workflow:
- jog the machine to reach an home position
- set the home position (set position 0 on every axis)
- load a file
- run the file
You can see the interface below:
I created a command to load a local files or a remote file containing a path that the machine will follow. Inside the file I put commands that are mapped into another RPC function: fileReader.addFunctions(('move',virtualmachine.move), ('jog', virtualmachine.jog))
Indeed reading from a file is better than send a series of commands directly from a website (Javascript) as HTTP protocol is stateless and there is a risk of a delay due to network issues. Here you can see the coordinates (and the RPC commands) to make a simple square:
In the videos above you can see a test of the machine drawing the cube with the hot-end tool (hot-end unmounted) and with a pen.
Using the machine I encountered some problems that I wasn’t able to solve.
- Sometimes the machine stops to react to the commands even if the software continues to send (the debug messages say {'writePosition': 0, 'stepsRemaining': 255, 'readPosition': 1, 'currentKey': 0, 'statusCode': 0}). However the two led in the usb plug start blinking very fast. Probably is some buffer overflow in the serial communication. Supporting this theory is the fact if the codes restarts sometimes the machine executes the last command sent.
- I wasn't able to make the compound node work (axis z and k) as described before
- Sometimes The last node of the physical chain sometimes doesn’t react to the commands. But it is maybe because there is not enough current available. Giving more current from the power supply (up to 3A) it doesn't happen.
- Moreover I see that using several axis together draws a lot of current (up to 3 Amps) and the boards can become really hot. To avoid damages, when this occurred I sent the "disable motors" RPC command.