Adding Cycle Start/Stop to EMC2

April 3rd, 2011

logitech dual

I have been delighted to be able to easily convert my companies’ shop fabricated CNC Oxy-Acetylene cutting machine from the 6502 assembly language control which it used since the 1980′s to a modern day open-source control, EMC2 (Enhanced Machine Controller).

After the old control’s EPROM program storage failed, I discovered and switched over to the MACH3 CNC control in a single afternoon. Unfortunately I soon discovered some of the limitations in its g-code programming. The lack of parametric programming in MACH3 was an extreme surprise. I heavily use the macro language in FANUC controls to customize my programs and decided to try out EMC2 once I found it supported parametric programming. Since the switch to EMC2, I have been very happy and am in the process of learning its intricacies.

One problem with using EMC2 as a flame cutting machine controller is that it is keyboard based, which is inconvenient for use with our machine which is semi-automatic. Torch height and gas controls are all manually adjusted so the operator must continually go back and forth between the keyboard and the torch. It is often difficult to find the right button on the keyboard during the flame cutting operation and the burning goggles which are worn by the operator only add to the confusion.

The ideal solution would be to have a remote pendant to control the machine’s movement with one hand while adjusting the torch with the other. Luckily I was able to find other websites which had already did the heavy lifting in designing a working pendant. The simplest solution others had discovered was to use a Logitech game controller which plugged into the computer’s USB port. Among the many websites which offered information in this regard, two which were invaluable were:

Simple Remote Pendant using a $10-20 joypad with halui and hal_input

and

Using a Joypad to Move Your CNC Machine

The problem I found was that I wasn’t so much interested in joystick control of the torch movement; the keyboard arrow keys work pretty well for jogging the torch around. What I wanted were buttons similar to the cycle start and cycle stop buttons found on Fanuc and other machine tool controls.

In flame cutting a part, the torch will sometimes blow itself out; before the operator can react, the torch continues on the path of the cut some distance. Since there is no way to back the torch up, the cutting has to be restarted from the beginning. When restarting the cut, the operator’s task is to stop the torch at the end of the last cut, preheat the metal to cutting temperature, turn on the cutting oxygen and resume the cut. Doing these steps with one hand on a keyboard trying to find the ‘r’ and ‘s’ keys to pause and resume is nearly impossible.

With these issues in mind I decided to minimize the functioning controls on the gamepad to only two buttons; one would act as the cycle start button and the other would act as the cycle stop button. The cycle start button would have two functions. The first would be to initially begin the g-code program. The other cycle start function would be to resume program execution after it had been paused. The cycle stop button would have just a single function; to pause a running program’s execution. On the keypad, the number three button would correspond to the cycle start button and the number one button would take the role of the cycle stop button.

The rest of the article assumes that the reader is already familiar with the inner workings of EMC2 and linux. Reams of information on EMC2 can be obtained at the wiki pages at www.linuxcnc.org

In order for the gamepad to be recognized by EMC2, various configuration files must be edited by hand with the linux text editor GEDIT. For the purpose of EMC2, our machine was given the name “XYIndexHead,” so that name is used as a prefix in some of the folder and filenames to be edited. In our situation, the folder where the files to be edited can be found here: ~/emc2/configs/XYindexHead

In that folder, the following changes were made to three files:

To the file “custom.hal”, the following line was added:

loadusr -W hal_input -KRAL Dual
# ————————————-

To the file “XYIndexHead.ini” (in the [HAL] section), the following line was added:

HALUI = halui
# ————————————-

To the file “custom_postgui.hal”, the following lines were added:

loadrt not
loadrt and2 count=4
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf not.0 servo-thread

net cycleStart <= input.0.btn-thumb2 # button (3)
net cycleStop <= input.0.btn-trigger # button (1)
net cycleStop => halui.program.pause

net modeIsAuto not.0.in

# Intermediate test: output is true if
# mode is auto and the cycle start button has been pushed

net cycleStart and2.0.in0
net modeIsAuto and2.0.in1
net startAndAuto and2.0.out => and2.1.in0

# When the cycle start button is pushed,
# start the program only if it is currently idle

net programIsIdle and2.1.in1
net cycleStartRun and2.1.out => halui.program.run

# When the cycle start button is pushed,
# resume the program only if it is currently paused

net cycleStart and2.2.in0
net programIsPaused and2.2.in1
net cycleStartResume and2.2.out => halui.program.resume

# When the cycle start button is pushed,
# set the mode to auto only if the mode is not already auto

notModeIsAuto not.0.out => and2.3.in0
net cycleStart and2.3.in1
net setModeAuto and2.3.out => halui.mode.auto
# ————————————-

… more information to follow as time permits

OS X on Mini 10V

December 20th, 2009

Sweet

Schizoid computer.

Beam Welder Project

December 20th, 2009

Air arcing addition updates:

Check it out.