You need to have downloaded and installed the Ruby interpreter from Ruby Windows installer or Linux users can get it from the Ruby Download page Most Linux distributions include Ruby by default.
For windows users Ruby is pretty much a standard install. For Linux users it must be built but this is a pretty easy step and if you have already built EMC2 then all the tools are already present.
For those who are not aware of Ruby it is a powerful scripting language that competes in the same space as Python and Perl. It was invented after both Python and Perl and it is more heavily influenced by Smalltalk and Simula which means that it is more of a True Object Oriented language. No programming language is perfect but Ruby is pretty nice and Python programmers can make the switch quickly. It is also easy for Visual Basic programmers to use. Even non programmers can use it for scripting quickly and easily.
The CNCUtil library is composed of a series of Ruby script files which must be present on your computer before you can use them. You can download the cncutil.org CNC Utility Library from http://cncutil.org/download We are extending this library on a daily basis so you may want to stop back and download new versions periodically.
If you are using windows XP or Linux then the utility to unzip it is built in. If you are using older windows systems you will need a unzip tool such as Stuffit expander which can be obtained free from http://www.stuffit.com/win/expander/
While you are downloading it may be helpful to download the a good programming editor. Any text editor will work but you will find it easier if you have one that notifies you when a file has changed and automatically reloads the file.
The ruby programs are all ran from either the Linux or the windows command prompt. If you are using Linux then you probably already know how to use shell windows. If you are using windows then you will find it under Start, Programs, Accessories or alternatively you can use START, RUN and type in CMD. Once you start the command console you should get a window that looks something like the following window.
Once you have a command prompt running, The first thing you have to do is change to where you have the CNCUtil
library stored which is also the same place you will save your scripts
at least while you are getting started. On my machine that is on my
C: drive in the \CNCUtil sub directory. You change directories as shown
the next window.
Now you can run any of the programs stored in that directory. You can see a
list of the available ruby programs by using the command DIR *.rb. You would
normally only want to see part of them so you can filter this list with
part of the name such as DIR *test*.rb as is shown in the next picture.
You run
the ruby programs by typing ruby filename.rb as shown in the
picture below which
is running the program "test_rect.rb" which happens to be one of our
examples which mills out pocket rectangles. The .rb extension is a
convention since all ruby scripts end with .rb by convention.
You will notice that Ruby starts showing the GCODE on the console window
which doesn't do us much good since we need to save it in a file that can
be ran by our CNC driver such as EMC2. As it turns out both Linux and
DOS use the same convention for saving the contents results of a run into
a file. You use the same command ruby test_rect.rb but this time we add
"> test_output.ngc" which will save the results in the file test_output.ngc
as shown in the next picture. Note the .ngc file extension is what EMC2 expects
by default but other CNC drivers use different extensions.
You can change the output name to any valid dos file name but we recomend that you
avoid all punctuation other than - and avoid all spaces. The same thing applies
to new programs that you may write.
Now that you have the output GCODE file stored such as we did in "test_output.ngc"
the next step is to open up in the GCODE emulator and and run it as shown in the
next picture. One important step is to make sure you tell the emulator how large
your source material will be and to configure your bits for the correct diameter.
My emulator defaults to 100 x 100 inches which is pretty much worthless for showing
the 3 inch parts I normally work on.
I normally do everything above on my windows machine and then transer the .ngc files over to my Linux machine to run through EMC2 but sometimes I will do it all on my Linux machine. One of the great things about EMC2 is that it runs on Linux which has plenty of power left over to run a variety of nice editors and web browsers.
If you are doing a lot of editing it is worth looking into using CVS to keep track of your ruby source code and ngc files. CVS not only provides a good way to keep track of versions of your programs but it also makes it very easy to keep multiple computers up to date with the lattest versions of the programs. The CVS client and server is free on Linux so the EMC2 box can also perform this function. The CVS client is free on windows.
(c) cncutil.org - All rights Reserved # See (C) notice in http://cncutil.org/CNCUtil/license.txt for license and copyright.