HAL Pins

HAL Tutorial

Creating widgets that connect to HAL (Hardware Abstract Layer) is as simple as adding a few Dynamic Properties. See Dynamic Properties for step by step instructions to add a Dynamic Property.

Typically the Dynamic Properties are String type with some exceptions being Bool and Color. Connections from Flex HAL objects to other HAL objects must be done in the file assigned to the POSTGUI_HALFILE variable in the [HAL] section typically named postgui.hal.

[HAL]
HALFILE = main.hal
POSTGUI_HALFILE = postgui.hal

The property pin_name defines the HAL pin name that is prefixed with flexhal. A pin_name of my-button would be flexhal.my-button in HAL.

Note

Dynamic Property names are case sensitive and must be all lower case. Hal types and directions are case sensitive and must be all caps. The function value must be lower case.

Note

Hal pin names can containe a-z, A-Z, 0-9, underscore _, or dash -.

HAL Button

A QPushButton, QCheckBox or QRadioButton can be assigned to a HAL bit pin by adding two string type Dynamic Properties. A pin_name of my-button would be flexhal.my-button in HAL. HAL pins can be connected in the postgui.hal file.

HAL Push Button

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

Optionally the button can be disabled when the power is off by adding a Dynamic Property named state_off and setting the value to disabled.

Optionally if the HAL button requires all joints to be homed before being enabled, you can specify that by adding a Dynamic Property named required and set the value to homed.

HAL Button Options

Property Type

Property Name

Pin Value

String

state_off

disabled

String

required

homed

_images/hal-09.png

Warning

By default, no QRadioButtons are checked unless you set one checked in the Designer. Starting up with none checked could be a problem if you expect one to be selected at startup.

HAL LED Button

A QPushButton can be a HAL LED button by adding two dynamic properties. The pin_name property will be the HAL pin name you use to connect the button state in the postgui.hal file. The button can be momentary or checkable.

HAL LED Button Dynamic Properties

Property Type

Property Name

Pin Value

String

function

hal_led_button

String

pin_name

any unique name

HAL Spinbox

A QSpinBox can be a HAL number pin by adding three string type Dynamic Properties. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-spinbox would be in HAL flexhal.my-spinbox. The spinbox is an Out type that will set the value of the HAL pin to match the value of the spinbox.

HAL Spin Box

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

hal_type

HAL_S32 or HAL_U32

HAL Double Spinbox

A QDoubleSpinBox can be a HAL number pin by adding two string type Dynamic Properties. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-spinbox would be in HAL flexhal.my-spinbox. The spinbox is an Out type that will set the value of the HAL pin to match the value of the spinbox.

HAL Spin Box

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

Slider

A QSlider can be a HAL pin by adding these three string type Dynamic Properties. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-slider would be in HAL flexhal.my-slider. A QSlider supports only integers so to connect it to a float HAL pin use conv_s32_float or conv_u32_float.

See Dynamic Properties for step by step instructions to add a Dynamic Property

HAL Slider

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

hal_type

HAL_S32 or HAL_U32

HAL I/O

A HAL I/O object has an input and output on the same pin. The pin can set an input pin of another HAL object and the pin can be set by another HAL object output pin. The HAL I/O will stay synchronized with the pin it’s connected to.

A QPushButton (set to checkable), QCheckBox, QRadioButton, QSpinBox, QDoubleSpinBox or a QSlider can be a HAL I/O object.

HAL I/O

Property Type

Property Name

Pin Value

String

function

hal_io

String

pin_name

any unique name

String

hal_type

HAL_BIT for a QCheckBox

QPushButton or QRadioButton

String

hal_type

HAL_FLOAT for a QDoubleSpinBox

String

hal_type

HAL_S32 or HAL_U32 for a QSpinBox or QSlider

String

hal_dir

HAL_IO

Label

A QLabel can be used to monitor HAL pins. HAL connections must be made in the post gui HAL file. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-reader would be in HAL flexhal.my-reader.

HAL Label

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

hal_type

HAL_BIT or HAL_FLOAT or HAL_S32 or HAL_U32

Note

A HAL_FLOAT QLabel can have a string Dynamic Property called precision with a value of the number of decimal digits.

Bool Label

A QLabel of hal_type HAL_BIT can have True and False text by adding two additional Dynamic Properties.

See Dynamic Properties for step by step instructions to add a Dynamic Property

HAL Bool Label

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

true_text

text to display when True

String

false_text

text to display when False

_images/hal-bool-label-01.png

Multi-State Label

A QLabel of hal_type HAL_U32 can have multiple text by adding as many Dynamic Properties as needed. The text_n starts at 0 for example text_0, text_1 etc.

HAL Multi-State Label

Property Type

Property Name

Pin Value

String

function

hal_msl

String

pin_name

any unique name

String

text_n

text to display when value is equal to n

Note

The text values must start at 0 and be sequencial.

_images/hal-msl.png

HAL LED

A QLabel can be used as a HAL LED indicator by adding the following properties to a blank label. Colors are optional, if not supplied red for off and green for on will be used. The pin_name is the hal name the LED will have.

The HAL LED needs to be connected in the postgui.hal file and can only be connected to a HAL pin of type bit with a HAL direction of OUT or a signal that is connected to a HAL pin of type bit with a HAL direction of OUT. Only one OUT direction can be connected to a signal while multiple IN directions can be connected to a signal.

HAL LED

Property Type

Property Name

Pin Value

Bool

hal_led

True

String

function

hal_led

String

pin_name

any unique name

Color

on_color

color of your choice

Color

off_color

color of your choice

Int

edge_margin

space between circle and edge of the label

Note

Select Other to get the list and select Color. You can copy and paste the hex color value into the color picker.

HAL LED Label

Similar to the HAL LED except the LED is in the upper right corner so the label can have text. If On/Off colors are not specified then Red will be Off and Green will be On.

HAL LED Label

Property Type

Property Name

Pin Value

Bool

hal_led_label

True

String

function

hal_led

String

pin_name

any unique name

Color

led_on_color

color of your choice

Color

led_off_color

color of your choice

Int

led_diameter

diameter of led

Int

led_right_offset

offset from right edge

Int

led_top_offset

offset from top edge

LCD

A QLCDNumber can be used to monitor HAL pins. HAL connections must be made in the post gui HAL file. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-reader would be in HAL flexhal.my-reader.

HAL LCD

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

hal_type

HAL_FLOAT or HAL_S32 or HAL_U32

Note

A HAL_FLOAT QLCDNumber can have a string Dynamic Property called precision with a value of the number of decimal digits.

Progress Bar

A QProgressBar can be used to monitor HAL pins. HAL connections must be made in the post gui HAL file. The pin_name used will create a HAL pin prefixed with flexhal. A pin_name of my-bar would be in HAL flexhal.my-bar.

HAL Progressbar

Property Type

Property Name

Pin Value

String

function

hal_pin

String

pin_name

any unique name

String

hal_type

HAL_S32 or HAL_U32

Step by Step

Note

This example is for a QPushButton

You can use a QPushButton as a momentary output, or with checkable selected for a toggle type output, or QCheckBox or QRadioButton for a HAL output control.

Drag the widget into the GUI and the widget can have any name you like; names are not used by HAL controls in Flex GUI - it is the following that matters.

Click on the widget to select it then click on the green plus sign in the Property Editor for that widget to add a Dynamic Property and select String.

See Dynamic Properties for step by step instructions to add a Dynamic Property

_images/hal-01.png

Set the Property Name to function and click Ok

_images/hal-02.png

Set the Value to hal_pin; this tells Flex GUI that this widget is going to be for a HAL pin

_images/hal-03.png

Add another string Dynamic Property named pin_name and set the value to any unique name

_images/hal-04.png

Add another Dynamic Property named hal_type and set the value to HAL_BIT

_images/hal-05.png

Add another Dynamic Property named hal_dir and set the value to HAL_OUT

_images/hal-06.png

If you added Show HAL to your menu, you can open up the Halshow program and view the pin names

_images/hal-07.png

The pin names will all start with flexhal plus the unique name you gave them

_images/hal-08.png

Now you can connect the Flex HAL pin in the postgui.hal file like normal

net some-signal-name flexhal.hal-test-01 => some-other-pin-in

After installing Flex GUI, from the CNC menu, you can copy the Flex GUI examples and look at the hal-btn example.

HAL Pin Types:

HAL_BIT
HAL_FLOAT
HAL_S32
HAL_U32

HAL Pin Directions:

HAL_IN
HAL_OUT
HAL_IO