4. About the LinuxCNC
LinuxCNC is a descendent of the original
NIST(The National Institutes of Standards
and Technology) Enhanced Machine
Controller software.
LinuxCNC is precompiled with Ubuntu LTS
(long term support) versions for ease of
installation and longevity.
LinuxCNC runs on Linux using real time
extensions.
4
6. LinuxCNC software
System Requirements
700 MHz x86 processor (1.2 GHz x86
processor recommended).
384 MB of RAM (512 MB up to 1 GB
recommended).
8 GB hard disk.
Graphics card capable of at least 1024x768
resolution.
A network or Internet connection (not strictly
needed, but very useful for updates and for
communicating with the LinuxCNC community).
6
7. LinuxCNC software
LinuxCNC provides:
a graphical user interface (actually several
interfaces to choose from).
an interpreter for G-code (the RS-274 machine tool
programming language).
a realtime motion planning system with look-ahead.
operation of low-level machine electronics such as
sensors and motor drives.
an easy to use breadboard layer for quickly creating
a unique configuration for your machine.
a software PLC programmable with ladder diagrams
easy installation with a Live-CD.
7
9. LinuxCNC Hierarchical
Four main components to the LinuxCNC
software:
a motion controller (EMCMOT)
a discrete IO controller (EMCIO)
a task executor which coordinates them
(EMCTASK)
and one of several graphical user interfaces
In addition there is a layer called HAL
(Hardware Abstraction Layer) which
allows configuration of LinuxCNC without
the need of recompiling.
9
14. Configuring LinuxCNC
INI : The ini file overrides defaults that are
compiled into the LinuxCNC code.
HAL : The HAL files start up process modules and
provide linkages between LinuxCNC signals and
specific hardware pins.
VAR : The var file is a way for the interpreter to
save some values from one run to the next. These
values are saved from one run to another but not
always saved immediately.
TBL : The tbl file saves tool information.
NML : The nml file configures the communication
channels used by the LinuxCNC. It is normally
setup to run all of the communication within a
single computer but can be modified to
communicate between several computers.
14
15. Configuring LinuxCNC
The INI File Components
Comments
Sections
Variables
Custom Sections and Variables
Sections
Comments
Variables
15
16. Configuring LinuxCNC
Sections
[EMC] general information
[DISPLAY] settings related to the graphical user interface
[FILTER] settings input filter programs
[RS274NGC] settings used by the g-code interpreter
[EMCMOT] settings used by the real time motion
controller
[TASK] settings used by the task controller
[HAL] specifies .hal files
[HALUI] MDI commands used by HALUI
[TRAJ] additional settings used by the real time motion
controller
[AXIS_n] individual axis variables
[EMCIO] settings used by the I/O Controller
Example
16
18. Configuring LinuxCNC
Hardware Abstraction Layer (HAL)
Component
A HAL component is a piece of software with
well-defined inputs, outputs, and behavior,
that can be installed and interconnected as
needed.
Parameter
Many hardware components have adjustments
that are not connected to any other
components but still need to be accessed.
There are two types of parameters: input &
Output
18
19. Configuring LinuxCNC
Hardware Abstraction Layer (HAL)
Pin
Hardware components have terminals which
are used to interconnect them. The HAL
equivalent is a pin or HAL pin. HAL pins are
software entities that exist only inside the
computer.
Physical_Pin
Many I/O devices have real physical pins or
terminals that connect to external hardware.
To avoid confusion, these are referred to as
physical pins. These are the things that stick
out into the real world.
19
20. Configuring LinuxCNC
Hardware Abstraction Layer (HAL)
Signal
In a physical machine, the terminals of real
hardware components are interconnected by wires.
Type
Bit - a single TRUE/FALSE or ON/OFF value
float - a 64 bit floating point value, with
approximately 53 bits of resolution and over 1000
bits of dynamic range.
u32 - a 32 bit unsigned integer, legal values are 0
to 4,294,967,295
s32 - a 32 bit signed integer, legal values are 2,147,483,647 to +2,147,483,647
Both pins and signals have types, and signals can
only be connected to pins of the same type
20
21. Configuring LinuxCNC
Hardware Abstraction Layer (HAL)
Function
Each function is a block of code that performs
a specific action. The system integrator can
use threads to schedule a series of functions
to be executed in a particular order and at
specific time intervals.
Thread
A thread is a list of functions that runs at
specific intervals as part of a realtime task.
When a thread is first created, it has a specific
time interval (period), but no functions.
Functions can be added to the thread, and will
be executed in order every time the thread
runs.
21
23. Configuring LinuxCNC
HAL Commands
loadrt
The command loadrt loads a real time HAL
component. Real time component
functions need to be added to a thread to
be updated at the rate of the thread
23
24. Configuring LinuxCNC
HAL Commands
addf
The command addf adds a real time
component function to a thread. You have
to add a function from a HAL real time
component to a thread to get the function
to update at the rate of the thread.
24
25. Configuring LinuxCNC
HAL Commands
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 cannot load
real time components into user space.
25
30. Appendix
Parallel Port Driver
installing
Pins
loadrt hal_parport cfg="<config-string>"
parport.<p>.pin-<n>-out (bit) Drives a physical output pin.
parport.<p>.pin-<n>-in (bit) Tracks a physical input pin.
parport.<p>.pin-<n>-in-not (bit)Tracks a physical input pin,
but inverted.
Parameters
parport.<p>.pin-<n>-out-invert (bit) Inverts an output pin.
parport.<p>.pin-<n>-out-reset (bit) (only for out pins) TRUE
if this pin should be reset when the -reset function is executed.
parport.<p>.reset-time' (U32) The time (in nanoseconds)
between a pin is set by write and reset by the reset function if
it is enabled.
30
31. Appendix
Parallel Port Driver
Functions
parport.<p>.read (funct) Reads physical input pins
of port <portnum> and updates HAL -in and -innot pins.
parport.read-all (funct) Reads physical input pins of
all ports and updates HAL -in and -in-not pins.
parport.<p>.write (funct) Reads HAL -out pins of
port <p> and updates that port’s physical output
pins.
parport.write-all (funct) Reads HAL -out pins of all
ports and updates all physical output pins.
parport.<p>.reset (funct) Waits until reset-time has
elapsed since the associated write, then resets pins
to values indicated by -out-invert and -outinvert settings.
31
32. Appendix
software step pulse generation
installing
loadrt stepgen step_type=type0[,type1...]
[ctrl_type=type0[,type1...]] [user_step_type=#,#...]
FUNCTIONS
stepgen.make-pulses (no floating-point)
Generates the step pulses, using information computed
by update-freq. Must be called as frequently as possible, to
maximize the attainable step rate and minimize jitter.
Operates on all channels at once.
stepgen.capture-position (uses floating point)
Captures position feedback value from the high speed code
and makes it available on a pin for use elsewhere in the
system. Operates on all channels at once.
stepgen.update-freq (uses floating point)
Accepts a velocity or position command and converts it into a
form usable by make-pulses for step generation. Operates
on all channels at once.
32
33. Appendix
software step pulse generation
PINS
stepgen.N.counts s32 out
The current position, in counts, for channel N. Updated by captureposition.
stepgen.N.position-fb float out
The current position, in length units (see parameter position-scale).
Updated by capture-position.
stepgen.N.enable bit in
Enables output steps - when false, no steps are generated.
stepgen.N.velocity-cmd float in (velocity mode only)
Commanded velocity, in length units per second (see
parameter position-scale).
stepgen.N.position-cmd float in (position mode only)
Commanded position, in length units (see parameter position-scale).
stepgen.N.step bit out
Step pulse output.
stepgen.N.dir bit out
Direction output: low for forward, high for reverse.
33
34. Appendix
software step pulse generation
PARAMETERS
stepgen.N.frequency float ro
The current step rate, in steps per second, for channel N.
stepgen.N.maxaccel float rw
The acceleration/deceleration limit, in length units per second squared.
stepgen.N.maxvel float rw
The maximum allowable velocity, in length units per second. If the requested maximum
velocity cannot be reached with the current combination of scaling andmake-pulses thread
period, it will be reset to the highest attainable value.
stepgen.N.position-scale float rw
The scaling for position feedback, position command, and velocity command, in steps per
length unit.
stepgen.N.rawcounts s32 ro
The position in counts, as updated by make-pulses. (Note: this is updated more frequently
than the counts pin.)
stepgen.N.steplen u32 rw
The length of the step pulses, in nanoseconds. Measured from rising edge to falling edge.
stepgen.N.stepspace u32 rw
The minimum space between step pulses, in nanoseconds. Measured from falling edge to
rising edge.
stepgen.N.dirsetup u32 rw
The minimum setup time from direction to step, in nanoseconds periods. Measured from
change of direction to rising edge of step.
stepgen.N.dirhold u32 rw
The minimum hold time of direction after step, in nanoseconds. Measured from falling edge
of step to change of direction.
34
63. AXIS
1.
2.
3.
4.
Create an .xml file that contains your
panel description and put it in your
config directory.
Add the PyVCP entry to the [DISPLAY]
section of the ini file with your .xml file
name.
Add the POSTGUI_HALFILE entry to the
[HAL] section of the ini file with the
name of your postgui HAL file name.
Add the links to HAL pins for your panel
in the postgui.hal file to connect your
PyVCP panel to LinuxCNC
63
67. Stand Alone
1.
2.
3.
Create an .xml file that contains
your panel description and put it in
your config directory
Add a loadusr line to your .hal file
to load each panel.
Add the links to HAL pins for your
panel in the postgui.hal file
to connect your PyVCP panel to
LinuxCNC.
67
69. Widgets
Bits are off/on signals
Numbers can be float, s32 or u32
1.
2.
3.
4.
5.
indicate bit signals: led, rectled
control bit signals: button, checkbutton,
radiobutton
indicate number signals: number, s32, u32,
bar, meter
control number signals: spinbox, scale,
jogwheel
Helper widgets: hbox, vbox, table, label,
labelframe
69
70. Widgets -- General Notes
tag-based and attribute-based
syntax
<led halpin="my-led"/>
<led>
<halpin>"my-led"</halpin>
</led>
Comments
<!-- My Comment -->
70