This documentation is no longer maintained. For documentation of the current version of emc2, please see http://www.linuxcnc.org/docview/html

Table of Contents

1 Getting Started

1.1 Hal Commands

1.1.1 loadrt

The command "loadrt" loads a real time HAL component. Real time components need to be added to threads to do anything. You can not load a user space component into the real time space.

The syntax and an example:

loadrt <component> <options>

loadrt mux4 count=1

1.1.2 addf

The command "addf" adds a function to a real time thread. If you used the Stepper Config Wizard to generate your config you will have two threads.

The syntax and an example:

addf <component> <thread>

addf mux4 servo-thread

1.1.3 loadusr

The command "loadusr" loads a user space HAL component. User space programs are their own separate processes, which optionally talk to other HAL components via pins and parameters. You can not load real time components into user space.

The syntax and an example:

loadusr <component> <options>

loadusr or2 count=2

1.1.4 net

The command "net" creates a "connection" between a signal and and one or more pins. The direction indicator "<= and =>" is only to make it easier to read for humans and is not used by net.

The syntax and an example:

net <signal-name> <pin-name> <opt-direction> <opt-pin-name>

net both-home-y <= paraport.0.pin-11-in

1.1.5 setp

The command "setp" sets the value of a pin or parameter. The values will depend on the type of the pin or parameter.

For more information on floating point numbers see:

http://en.wikipedia.org/wiki/Floating_point

Some components have parameters that need to be set before use. Parameters can be set before use or while running as needed. You can not use setp on a pin that is connected to a signal.

The syntax and an example:

setp <pin/parameter-name> <value>

setp parport.0.pin-08-out TRUE

1.2 Hal Files

If you used the Stepper Config Wizard to generate your config you will have up to three HAL files in your config directory.

1.3 Logic Components

Hal contains several real time logic components. Logic components follow a "Truth Table" that states what the output is for any given input. Typically these are bit manipulators and follow electrical logic gate truth tables.

1.3.1 and2

The "and2" component is a two input "and" gate. The truth table below shows the ouput based on each combination of input.

Syntax

and2 [count=N|names=name1[,name2...]]

Functions

and2.n

Pins

and2.N.in0 (bit, in)
and2.N.in1 (bit, in)
and2.N.out (bit, out)

Truth Table

in0 in1 out
False False False
True False False
False True False
True True True

1.3.2 not

The "not" component is a bit inverter.

Syntax

not [count=n|names=name1[,name2...]]

Functions

not.n

Pins

not.n.in (bit, in)
not.n.out (bit, out)

Truth Table

in out
True False
False True

1.3.3 or2

The "or2" component is a two input OR gate.

Syntax

or2[count=,|names=name1[,name2...]]

Functions

or2.n

Pins

or2.n.in0 (bit, in)
or2.n.in1 (bit, in)
or2.n.out (bit, out)

Truth Table

in0 in1 out
True False True
True True True
False True True
False False False

1.3.4 xor2

The "xor2" component is a two input XOR (exclusive OR)gate.

Syntax

xor2[count=,|names=name1[,name2...]]

Functions

xor2.n

Pins

xor2.n.in0 (bit, in)
xor2.n.in1 (bit, in)
xor2.n.out (bit, out)

Truth Table

in0 in1 out
True False True
True True False
False True True
False False False

1.3.5 Logic Examples

An "and2" example connecting two inputs to one output.

loadrt and2 count=1
addf and2.0 servo-thread
net my-sigin1 and2.0.in0 <= paraport.0.pin-11-in
net my-sigin2 and2.0.in.1 <= paraport.0.pin-12-in
net both-on paraport.0.pin-14-out <= and2.0.out

In the above example one copy of and2 is loaded into real time space and added to the servo thread. Next pin 11 of the parallel port is connected to the in0 bit of the and gate. Next pin 12 is connected to the in1 bit of the and gate. Last we connect the and2 out bit to the parallel port pin 14. So following the truth table for and2 if pin 11 and pin 12 are on then the output pin 14 will be on.