From PMinMO.com

Jump to: navigation, search

After a couple of unsuccesful attempts to install and configure EMC2 and Ubuntu in the last couple of years, I can finally say I've succeeded in getting a system configured and running. EMC2 and Ubuntu Linux is a robust, no cost cnc controller software package. EMC2 is a very powerful, highly capable and zero cost motion controller that provides reliable ultra smooth motion control. What I'm going to attempt to do here is help other people that might want to do the same but have limited or no prior linux or EMC experience avoid the same pitfalls I did. The linuxcnc.org website is full of information and documentation, but I had a difficult time figuring out where to get the info I needed and whether it was a Linux question or EMC question. For example the most frustrating and what stopped me in prior attempts had nothing to do with EMC, but Ubuntu and support for wireless adapters. My machine/box that I wanted to load and configure isn't in a location that is easy to wire so I wanted a wireless connection to connect and transfer files. I finally just moved the pc to a spot where I could connect via a wired interface and was able to get going.


Halo Stepconf File

[Halo Stepconf File]

Bulletin Board Forum for PMinMO and EMC


Install Ubuntu and EMC2

Go to http://linuxcnc.org and download the iso file of the Ubuntu with EMC2 live CD and burn it. If your working in the Windows world, you will you will need an application to properly burn the iso image correctly. Win95, 98, ME, 2000, XP or Vista do not have the inherent capability to burn a .iso as an image, you will wind up with one file of the same name you downloaded on the CD. Go to Ubuntu's webpage for burning ISO'sto learn how to accomplish this task. Once you have created the CD, boot it to run the live cd for evaluation before loading it to make sure your pc configuration works. While the Ubuntu/Debian people have a robust set of hardware supported, there are still "holes" where hardware isn't supported or may have bugs.

Once you have established the fundamentals of your pc (video,keyboard,storage) are recognized, install Ubuntu (EMC2 and required support software will be installed as a part of the installation)

Linux Terminal Sudo and Gedit

A couple of aspects of Linux that a person new to Linux needs to know is that you use Terminal to do command line commands (non graphical) and that Gedit is a text editor that comes on the live EMC2 CD. You can use Gedit to edit configuration files and g-code files, etc. Terminal starts a window where you can do command line driven commands. For example, currently you need to run Terminal to do latency testing. Operating system files need root user privileges to modify. Sudo is a method to use root privileges with a command.

Latency Testing

In reality you need to determine how well suited your PC and it's hardware configuration is suited or tuned to run EMC. Start by running the latency test as you will need the numbers for building your configuration. Use the information in the Integrator's manual to run the latency tests, you can find it by doing a search in the Integrators manual.

Stepconf Wizard

If your building a stepper based machine, start with the Stepconf Wizard. This is a great tool to get your machine configured and becomes more robust as time passes. There is a menu item for this wizard in the later versions of the lived CD. You can also use this to "tune" you machine's motors per axis.

Head Scratchers

Periodically I run into something that other pieces of CNC software handles more loosely, or is different. Here are some that threw me off for a while:

Machine on and Master Reset is a three state operation.

M03 (M05) needs to have a speed parameter, so a plain M03 or M3 will turn the spindle off.

Touch Off with zero as the value is EMC's method to Zero a position.

From Windows User to Running EMC-Linux

So you have heard about EMC but your computer, tools and comfort zone is in one of the versions of Windows or even DOS, but you think you might want to run EMC. If that describes you, the objective of this article is to help you make the decisions and aid in the tools and process you will need. Succeed in that transition and installation and you will soon realize that EMC was worth the effort. If you can dedicate a computer to Linux and EMC the task is potentially easier than setting up a computer to dual boot both Windows and EMC. But if you have lots of data and tools on the PC then you may want to create a dual boot PC to facilitate usage.

Why EMC/Linux

Normal PC based Windows is not a real-time operating system. Linux at its core isn’t either, but Linux has the upper hand in that there is a real-time package that can be installed, RTAI. RTAI or Real Time Application Interface utilizes common personal computer hardware to run applications that depend on strict timing constraints such as needed by a motion control application. So underneath it, Linux with RTAI is better suited to motion control than Windows. Add to that, Ubuntu Linux and EMC are completely FREE! No limited number of lines of G-code, no 1 month trial for the free version, it’s a full fledged no gotcha PC based machine control application and a GUI based operating system that if you can “drive” Windows, you can “drive” Ubuntu. In addition, when you compare a Windows based CNC control program such MACH3 to EMC utilizing stepper motors and you’ll see what a great job the EMC developers have done. The stepper motors absolutely love the timing consistency that EMC provides.

There’s More!

With the Ubuntu/EMC2 prebuilt install, there is a free version of Open Office installed which is the equivalent of Word, Excel, PowerPoint and Outlook. There is also Firefox to browse the web, games ready to play, utilities and a whole universe of free applications ready to install if you so desire.

Making That Transition Easier – The First Recommendations

The enthusiasts at linuxcnc.org have done their part in making the transitions simpler by creating a LiveCD of Ubuntu Linux with RTAI and EMC2 already built. A LiveCD allows you to boot and try it out with your PC without installing Linux. Download the iso file and burn a cd on your Windows based PC. If you’re not familiar with how to burn an iso file to cd, refer to the Getting Started Document at http://linuxcnc.org. Recommendation number one, boot the live CD and make sure that your video board, PC peripherals and network run properly. If you rely on a wireless network, this can be an issue depending on the network card. The next recommendation in making the transition simpler is to dedicate a PC to Linux and EMC. You don’t need the latest and greatest PC as people have had success with 800mhz processors and 256M of ram and a 4G hard drive. That’s a minimalist system, not for the Linux beginner. Shoot for a 1 GHz P4 or AMD, etc equivalent and faster, with a minimum of 512M of ram with a hardwired Ethernet connection. A parallel port interface and a simple video board that doesn’t rely on a mother boards shared memory is also a strong recommendation. If you plan on or have an integrated motherboard with built in video, consider adding an inexpensive simple video board, it doesn’t take much. Bottom line, an older PC with a CD drive, 4G or greater hard drive, simple video board, simple keyboard and mouse and monitor, Linuxcnc LiveCD and your ready to get started.

Windows and Ubuntu-EMC on the same PC

If you decide you want Windows to be on the same PC, you can, and it’s really not that difficult. But depending on the computer configuration and how you want to do the dual boot, it starts to increase in complexity. The Linuxcnc LiveCD has the tools already on the cd to implement a dual boot setup. The first configuration explanation will be for one hard disk drive.

One Hard Drive Dual Boot

The first requirement is that you have the required free space available. 4Gig is the minimum, but larger is preferred, especially when you start finding the free applications available to be installed. To install Ubuntu/EMC your hard drive will need to have two partitions added to it, one for Linux and a second as a Linux swap partition. In addition, you will need the ability to boot either Windows or Linux/EMC. The LiveCD by default will install GRUB, which is a menu based boot loader. Grub will install over the Windows MBR (Master Boot Record) which makes some potential users uneasy, but GRUB makes a copy of the MBR so it can be reinstalled if the user needs too. There are methods to use the Windows NT boot loader, but it’s beyond the scope of this articles. Windows inherently does not have the ability to shrink the size of existing partitions, and in all likelihood you don’t have gigabytes of unformatted hard drive just sitting free. On the live CD is the application Gparted. Gparted is a low level disk utility that will resize partitions, create and delete partitions. Gparted recognizes file systems utilized in the Windows world such as FAT, FAT32, and NTFS as well as EXT3 which is the current preferred partition for Ubuntu Linux. So review you drive and determine how much free space you can make available, then boot the LiveCD, then under Administration select Partition Manager to start Gparted. Select the partition you want to resize and enter the new size and do an Apply. Once Gparted has resized the partition, exit Gparted. Then do the Linux/EMC install to your drive by double clicking the “Install” icon on the Ubuntu desktop.

Two Hard Drives – Dual Boot

If you are not comfortable with allowing Ubuntu to install GRUB over the master Boot Record of your Windows drive, a second hard drive is an option installing Ubuntu/EMC on the second drive. This is true if your BIOS will allow you to select which drive to boot from. Existing PC’s BIOS only allow one boot partition to be active on a drive, but you can have an active boot partition on each drive. By installing Ubuntu/EMC to a second drive and installing GRUB on the drive you can point the BIOS to boot from the Ubuntu drive. During the installation process GRUB scans for other bootable operating systems and adds those to the boot menu, so there is no need to catch the BIOS startup to select which drive to boot from.

Configuring EMC2 .ini file

At linuxcnc.org there is a great deal of documentation on EMC2. Here is there starting point for configuring EMC2: http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Configuring_EMC2 I'm going to focus on setting up a step/direction set of drivers such as those driving stepper motors. Essentially two files contain the information necessary to tell EMC2 how to behave when it starts up, and .ini file and that .ini file normally points to a .hal file. Variable information contained in the .ini file is described here: http://linuxcnc.org/docs/2.2/html/config_ini_config.html

The .ini file I currently have setup is below. High points I would like to make about the ini file.


There are several user interfaces (GUI) for emc2. "axis" is my prefered GUI because it has a graphical previewer as well as a backplotter, "tkemc" and "mini" are both simple alternatives. To change the GUI simply change the "DISPLAY = axis" line in the ini file to "DISPLAY = tkemc" as example for the tkemc GUI.


While you can include hal definitions in the ini file, it's normally in a separate file. 8020.hal is my hal file and the .ini file is set by "HALFILE = 8020.hal" as show below. You can have more than one hal file.


In the [traj] section set the AXES parameter for the number of your machine. "AXES = 3" for a three axis machine.

Setting up Home and Limit Switches

EMC has multiple home algorithms I just use the default. As seen below "HOME_SEQUENCE = 1" is how the algorithm is defined. More info here: http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Homing_And_Limit_Switch

Main AXIS Variables to get started (my explanation)

Each axis will need to be configured.

HOME = -1.0   Where you want that axis to move to at the end of the homing sequence
MAX_VELOCITY = 0.8   Maximum speed in units per second (i.e. Inches per second)
MAX_ACCELERATION = 20.0   Maximum Acceleration rate in units per second squared
SCALE = 8000.0   Steps per unit.  i.e. multiply steps per revolution by turns per unit 
FERROR = 0.05
MIN_LIMIT = -1.0  Soft limit definition
MAX_LIMIT = 11.0  Soft limit definition
HOME_OFFSET = -1.000000   The axis position of the "Home" switch

An .ini File in the beginning

# Generated by stepconf at Mon Jun  9 23:45:34 2008
# If you make changes to this file, they will be
# overwritten when you run stepconf again

MACHINE = 8020
NML_FILE = emc.nml

DISPLAY = axis
INTRO_GRAPHIC = emc2.gif
PROGRAM_PREFIX = /home/phil/emc2/nc_files
INCREMENTS = .1in .05in .01in .005in .001in .0005in .0001in
EDITOR = gedit

TASK = milltask
CYCLE_TIME = 0.010


EMCMOT = motmod
COMM_WAIT = 0.010
#BASE_PERIOD = 100000
SERVO_PERIOD = 1000000

HALFILE = 8020.hal
HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal

AXES = 3
CYCLE_TIME = 0.010

EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

HOME = -1.0
SCALE = 8000.0
FERROR = 0.05
MIN_LIMIT = -1.0
MAX_LIMIT = 11.0
HOME_OFFSET = -1.000000
HOME_SEARCH_VEL = 0.600000
HOME_LATCH_VEL = 0.062500

HOME = -2.0
SCALE = 8000.0
FERROR = 0.05
MIN_LIMIT = -2.1
MAX_LIMIT = 10.50
HOME_OFFSET = -2.000000
HOME_SEARCH_VEL = 0.500000
HOME_LATCH_VEL = 0.062500

HOME = 2.55
SCALE = 8000.0
FERROR = 0.05
MIN_LIMIT = -0.5
HOME_OFFSET = 2.5500000
HOME_SEARCH_VEL = -0.500000
HOME_LATCH_VEL = 0.062500

Configuring the .hal file

A capture of a conversation describing how to setup the hal file is here: http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?SampleParport Explaining the line in the hal file "net xstep => parport.0.pin-02-out" net is the signal name => is a "symbolic" connection of the signal name to a physical pin paraport.0 is the LPT port of the PC used and as defined by hal_parport cfg= pin-02-out is the physical pin as an output Explaining the line "setp parport.0.pin-02-out-reset 1" setp is set the parameter, so the line is on reset or initialization set it to a 1. To help understand the line "setp parport.0.pin-16-out-invert 1". The output signal paraport.0.pin-16-out is XOR'ed with the signal parport.0.pin-16-out-invert. So by seting that signal to 1 inverts the usage of parport.0.pin-16-out.

This is one of my hal files for my Halo board:

# Generated by stepconf at Mon Jun  9 23:45:34 2008
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg=0x378
setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
net spindle-cw <= motion.spindle-forward

net xstep => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir => parport.0.pin-03-out
net ystep => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
net ydir => parport.0.pin-05-out
setp parport.0.pin-05-out-invert 1
net zstep => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net zdir => parport.0.pin-07-out
net astep => parport.0.pin-08-out
setp parport.0.pin-08-out-reset 1
net adir => parport.0.pin-09-out
setp parport.0.pin-14-out-invert 1
net xenable => parport.0.pin-14-out
net spindle-cw => parport.0.pin-16-out
setp parport.0.pin-16-out-invert 1

net home-y <= parport.0.pin-12-in-not
net home-x <= parport.0.pin-13-in-not
net home-z <= parport.0.pin-15-in-not

setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
# setp stepgen.0.dirhold 19000
# setp stepgen.1.dirsetup 16000
setp stepgen.0.dirhold 5000
setp stepgen.0.dirsetup 2000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable
net home-x => axis.0.home-sw-in

setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 5000
setp stepgen.1.dirsetup 2000
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable
net home-y => axis.1.home-sw-in

setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 5000
setp stepgen.2.dirsetup 2000
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable
net home-z => axis.2.home-sw-in

net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

coordinate parameters emc.var

Parameter Number(s) 	Meaning
5061-5069 		Result of “G38.2” Probe
5161-5169 		“G28” Home
5181-5189 		“G30” Home
5211-5219 		“G92” offset
5220 			Coordinate System Number
5221-5229 		Coordinate System 1
5241-5249 		Coordinate System 2
5261-5269 		Coordinate System 3
5281-5289 		Coordinate System 4
5301-5309 		Coordinate System 5
5321-5329 		Coordinate System 6
5341-5349 		Coordinate System 7
5361-5369 		Coordinate System 8
5381-5389 		Coordinate System 9
5399 			Result of M66 - Check or wait for input

Parameter Number	Parameter Value	  Comment
       5161	             0.0	  G28  Home X
       5162	             0.0	  G28  Home Y

Skip Linux Logon Screen

In the etc/gdm directory is a file gdm.conf, editing that file by changing the line that has "AutomaticLoginEnable=false" to "AutomaticLoginEnable=true" will allow you to skip the logon screen. If you want to logon as a specific user then set the line "AutomaticLogin=" to the user name you created when you did the installation, such as "AutomaticLogin=phil". Since this file is in a protected directory you must open terminal and do a "sudo gedit" command. Then use open and save from the editor to find and open the file.

Personal tools