HAL-Configuration with Eagle
Contents
-
- 1. Requirements
-
- 2. Installing eagle2hal
-
- 3. Special Devices and conventions
-
-
- 3.1. loadrt / loadusr
-
- 3.2. thread
-
- 3.3. parameter
-
- 3.4. axis.X
-
- 3.5. motion
-
- 3.6. iocontrol
-
- 3.7. Logic gates and other devices
-
- 3.8. Clock-Pins
-
- 3.9. Dot-Pins
-
4. Example configuration
-
- 5. Using the hal-package - Troubleshooting
-
- 6. Create library components
-
-
- 6.1. Symbol
-
- 6.2. Device
-
- 6.3. Modify the ulp script
-
- 6.4. Warning
-
With this workaround the LinuxCNC hardware abstraction (HAL-) layer can be configured with the aid of Eagle CAD Schematics editor.
Since the export script and the library are a workaround for configuring hal-layer, basic knowledge about EAGLE and the hal-components are required.
The library contains only part of the hal components and makes no claim to be complete!
The export script does not check for any errors, so debugging is made by starting LinuxCNC and checking stdout/stderr-debug-prints
1. Requirements
- [LinuxCNC] (tested with version 2.2.2)
- [Eagle CAD] (tested with version 4.16r1)
- [Eagle2HAL] for eagle (includes library with hal-components and an export-script to generate hal-files)
- [upload:eagle2hal.tar.gz] The same with eagle2hal-2.4 with more hal components. I add paragraph 6 for hal component creation in eagle library. Charalampos Alexopoulos
2. Installing eagle2hal
Just copy the contents of the tarball to your eagle working directories (export-script to ./ulp, library to ./lbr, example script to ./projects).
3. Special Devices and conventions
Some of the devices have special functions and have to be treated in a certain way.
3.1. loadrt / loadusr
To add a 'loadrt ...'-line to the script, just place a 'LOADRT'-Device to the schematic.
If the order of all of the loadrt/loadusr-lines doesn't matter, just apply a useful name.
If it does matter (e.g. 'loardrt probe_parport' has to be executed before 'loadrt hal_parport'), start the name with an index (e.g. '0:trivkins'). The loadrt/loadusr-commands will be written in the order of the indeces to the hal-files.
Nothing will happen until now, because the name is not used anymore.
Now add a value to that device and enter the complete line to be written to the hal-file - thats it.
There are some predefined LOADRT_... - devices in the library that have no real special meaning and are treated as a generic 'LOADRT'-device.
3.2. thread
I know of two threads that are running im LinuxCNC realtime: BASE-THREAD and SERVO-THREAD (maybe there are more...).
If you want to hook functions into a thread you can do this by adding a 'THREAD'-Device to the schematic. Name this instance correctly, the export-script will use the name too hook the functions into this thread.
If the time-slot is important, you can choose between serveral time slots (negative and positive ones). If they are not sufficiant, just edit the device in the library and add some more pins by keeping the naming conventions...
3.3. parameter
To set a value to a parameter, add a 'PARAMETER'-device to the schematic and give it the desired value (will be written as a string in the configuration, so everything is possible here).
3.4. axis.X
3.5. motion
3.6. iocontrol
3.7. Logic gates and other devices
Just add them, hook the function to a thread and connect the pins the way you want to, they are loaded automatically by the export-script (as long as they are implemented in the export-script!).
3.8. Clock-Pins
Eagle's clock pins are always used as functions. Functions can be connected to threads.
These pins are treated in a special way, they should not be connected to other kind of pins.
3.9. Dot-Pins
Pins with a Dot in the schematic (usually a negatived pin) are always connecting parameters.
These pins are treated in a special way, they should not be connected to other kind of pins.
4. Example configuration

The example script martin_old.sch show the author's configuration of a small desktop-mill controlled over one parallel-port.
Left hand all the realtime-modules that are loaded at the beginning of the hal-configuration are listed.
Underneath the two threads are shown.
The center shows the default axis-configuration for three axis.
To the right the parallel port collects all the signals and routes them to the hardware.
All the stuff above the axis configuration is for generating a 'sleep'- and a 'boost'-signal for the axis-drivers.
('Sleep' is used to lower the stepper's current when no motion is commanded.
'Boost' increases the current when at least one stepper starts moving - OK, it should do so, but it doesn't work correct, at least it shows some more possibilities of this export-script...)
5. Using the hal-package - Troubleshooting
Keep in mind: This is only a workaround, so many bugs and errors may follow...
When starting a new configuration the easiest way is to copy an older one.
Export is done by executing the user language program 'hal-write.ulp'. Maybe you have a look at the source code and replace the export path to your needs.
It is very important to consider some rules and naming conventions:
- When adding new devices, check their names. Eagle names them starting at 1, HAL expects them starting at 0.
E.g. the first 'AND2'-device will be named 'AND2.1', So rename it to 'AND2.0' and everything will be fine ;-)
- Some devices only occur once in hal and are not counted.
E.g. a 'MOTION'-device it will be named 'MOTION1'. Rename it to 'MOTION'
- If you want to set parameters of a hal-component, use eagle's INVOKE-command. You'll see a list of implemented parameters and functions which you can add to the schematic.
- Connect only pins of the same kind to one net (DOT: parameters, CLK: functions)
- Don't wonder about trailing '_' or '.' in some components' names. The export script needs them - just ignore them.
6. Create library components
I spend several hours to understood how to make a library part for a hal-component. In order to help incapable people like me, i wrote some tips.
6.1. Symbol
- Add a text [>Name] on the Names layer
- For each pin set the properties
Name : the name as is in the man page
Visible: Pin
6.2. Device
- Create a device with a name as is in the Name part of man pages. eg. conv_float_u32
- Add the symbol that you create
Name: Live it empty
Add Level: Must
- Add symbol [PIN-FUCTION]
Name: . (Just a dot)
Add level: Must
- add symbol [PIN-PARAMETER] as many as required by the component.
Name: .name(A dot followed by the parameter name)
Add Level: I am not sure what is going here. I use [Must] and works.
- Connect all pins to the DUMMY package.
- Set the Prefix to the component name as is in the Functions part of the man page followed by a dot. e.g. conv-float-u32.
- Add a description from man page. This is optional, but it takes just a few seconds and we have a nice help for the component
Copy the html code from man page.Copy only the part from Name down to Licence.
6.3. Modify the ulp script
In the [hal-write-2.4.ulp[ file add your component name in the [dev_names] array. Thats it.
6.4. Warning
Those are things that i found in a trial and error procedure. It works for me but may contain errors.
[Contact the author] for feedback or questions.
Enjoy the bugs
Martin