Historical project documentation. Content is maintained in GitLab.

HALs

Documentation/NGOS/Signals/Shells/Cmds/Ctrl/HALs/Conf/Params/Behaviors/Receiver/GPSNext Chapter

The NG Hardware Abstraction Layer

The HAL Concept of the NG

Introduction

To be able to fly the available Controllers with different motor/propeller configurations a NG has a Hardware Abstraction Layer called HAL. The HAL layer can be exchanged and has a simple common API. This allows to support different propeller/motor configurations as well as different actor types (i2c-blc, servo, i2c-servo).

Concept

A NG controller will calculate and output corrections relative to the 3 axis pitch, roll and yaw.

The above corrections output by the choosen controller then gets passed to the Hardware Abstraction Layer, which can be exchanged similar to controllers. The choosen HAL then calculates single actor output values for each actor available and supported in this HAL and passes these values forth to the actor output layer.

Implementation

The HAL API is quite simple. Each HAL consists of a HAL init, input and output function. The HAL’s input function gets called before the controller’s closed-loop step gets done and the HAL’s output function get’s called after the closed-loop step.

The HAL has the possibility to modify the controller input data before it runs and it has the ability to alter the controller’s output data after it did it’s calculations.

This allows HALs to do their transformations of input and output data needed to support specific HAL features.

A HAL’s output function essentially receives 4 values from a controller. That’s a correction factor for nick, roll and yaw. A fourth value is the current throttle. These four values then get projected onto the choosen motor/propeller/actor configuration.

The implemented HALs

Several HALs are already implemented. Essentially all we needed till now. A HAL is easy to implement and so we have to expect that the number of HALs will grow fast.

The ’none’ HAL

HAL DescriptionThe do-nothing HAL
HAL Qualityproven
Needed actors0
DescriptionThis HAL really does nothing. It's using no actors and can't fly.
Parameters:HW.HALThe chosen HW abstraction layer

The ‘blc’ HAL

HAL DescriptionThe BLC test HAL
HAL Qualityonly for testing purposes
Needed actors0
DescriptionThis HAL can't fly. It's suited for testing single BLC-Controllers. Controller output is ignored and the HAL outputs the values below to the available actors.
Parameters:HW.HALThe chosen HW abstraction layer
BLC1BL-Controller 1 output, set this to get actor 1 moving (0=off ... 65535=max power. The motors may not start spinning before ~4000.)
BLC2BL-Controller 2 output, set this to get actor 2 moving
......
BLC16BL-Controller 16 output, set this to get actor 16 moving

The ‘quad’ HAL

HAL DescriptionThe 4 rotor Quadcopter HAL
HAL Qualityproven
Needed actors4
DescriptionThis is the classical 4 rotor (non-cross) Quadcopter HAL. It allows to fly a classical QuadCopter with a front, back, left and right motor.
Motor 1front (CW)
Motor 2back (CW)
Motor 3right (CCW)
Motor 4left (CCW)
Parameters:HW.HALThe chosen HW abstraction layer

The ‘quadX’ HAL

HAL DescriptionThe 4 rotor Quadcopter HAL (X-formation)
HAL Qualityproven
Needed actors4
DescriptionThis is the classical 4 rotor (cross or X) Quadcopter HAL. It allows to fly the classical QuadCopter in X-formation, meaning a front left and right motor and a back left and right motor.
Motor 1front-left (CW)
Motor 2back-right (CW)
Motor 3front-right (CCW)
Motor 4back-left (CCW)
Parameters:HW.HALThe chosen HW abstraction layer

The ‘quadR’ HAL

HAL DescriptionThe 4 rotor Quadcopter HAL (reverse)
HAL Qualityproven
Needed actors4
DescriptionThis is the classical 4 rotor (non-cross) Quadcopter HAL in reverse mode! It allows to fly a classical QuadCopter with a front, back, left and right motor in reverse mode meaning the back becomes the front.
Motor 1back
Motor 2front
Motor 3right
Motor 4left
Parameters:HW.HALThe chosen HW abstraction layer

The ‘quad45’ HAL

HAL DescriptionThe 4 rotor Quadcopter HAL turned by 45 degrees
HAL Qualityflying
Needed actors4
DescriptionThis is the classical 4 rotor (non-cross) QuadCopter HAL turned by 45 degrees. It allows to fly a classical QuadCopter with a front, back, left and right motor with with a Sensor Board turned by 45 degrees so that the flat side is front.
Motor 1front
Motor 2back
Motor 3right
Motor 4left
Parameters:HW.HALThe chosen HW abstraction layer

The ‘Y6’ HAL

HAL DescriptionThe 6 rotor Y6 Hexakopter Coax HAL
HAL Qualityproven
Needed actors6
DescriptionThis is the new Y6 HAL in normal mode. It allows to fly a Y6 hexacopter. You need to attach front-left up/down, front-right up/down and back up/down motors.
Motor 1front-left-up
Motor 2front-right-up
Motor 3back-up
Motor 4front-left-down
Motor 5front-right-down
Motor 6back-down
Parameters:HW.HALThe chosen HW abstraction layer
HAL.fact.topThrottle factor for top layer
HAL.fact.bottomThrottle factor for bottom layer

The ‘X8’ HAL

HAL DescriptionThe 8 rotor X8 Oktocopter Coax HAL
HAL Qualityready for test flights
Needed actors8
DescriptionThis is the classical 8 rotor (non-cross) coax QuadCopter HAL. It allows to fly a classical Quadcopter with a front up/down, back up/down, left up/down and right up/down motors in coax configuration.
Motor 1front-up
Motor 2back-up
Motor 3right-up
Motor 4left-up
Motor 5front-down
Motor 6back-down
Motor 7right-down
Motor 8left-down
Parameters:HW.HALThe chosen HW abstraction layer
HAL.fact.topThrottle factor for top layer
HAL.fact.bottomThrottle factor for bottom layer

The ‘X8X’ HAL

HAL DescriptionThe 8 rotor X8 Oktocopter Coax HAL (X-formation)
HAL Qualityready for test flights
Needed actors8
DescriptionThis is the classical 8 rotor (non-cross) coax QuadCopter HAL. It allows to fly a classical Quadcopter with a front up/down, back up/down, left up/down and right up/down motors in coax configuration.
Motor 1front-left-up
Motor 2back-right-up
Motor 3front-right-up
Motor 4back-left-up
Motor 5front-left-down
Motor 6back-right-down
Motor 7front-right-down
Motor 8back-left-down
Parameters:HW.HALThe chosen HW abstraction layer
HAL.fact.topThrottle factor for top layer
HAL.fact.bottomThrottle factor for bottom layer

Configure the HAL

You can configure your NG for different hardware configurations. You do this by choosing the right HAL Hardware Abstraction Layer) for your propeller/motor configuration.

The list of available HALs

The command list hal shows all existing HALs and their current status:

. {{{

list hal

Possible ‘HW.HAL’ settings:

00  none    The do-nothing HAL (proven)
01  blc     The BLC test HAL (only for testing purposes)
02  quad    The 4 rotor Quadcopter HAL (proven)
03  quadX   The 4 rotor Quadcopter HAL (X-formation) (proven)
04  quadR   The 4 rotor Quadcopter HAL (reverse) (proven)
05  Y6      The 6 rotor Y6 Hexakopter Coax HAL (proven)
06  X8      The 8 rotor X8 Oktocopter Coax HAL (ready for test flights)
07  X8X     The 8 rotor X8 Oktokopter Coax HAL (X-formation) (only for testing purposes)

}}}

Setting a new HAL

When you have decided which HAL to use, you can choose it by setting the global variable HW.HAL:

. {{{

set HW.HAL quad

Activated propeller HAL ‘quad’ Setting ‘HW.HAL’ to HAL ‘quad’ }}}

Verifying the current HAL

With the commands show hal and scan actors you can verify that everything works as expected:

. {{{ Current HAL: quad

HAL Id:                    2
HAL Description:           The 4 rotor Quadcopter HAL
HAL Quality:               proven

Needed number of actors:   4
Detected number of actors: 0

Motor 1: front
Motor 2: back
Motor 3: right
Motor 4: left

Description:

This is the classical 4 rotor (non-cross) QuadCopter HAL. It allows to fly a classical QuadCopter with a front, back, left and right motor.

Current HAL configuration:

HW.HAL quad HW abstraction layer

scan actors

Scanning I2C1 actor bus… Scan finished.

Busscan results I2C1 [0x10..0xf6]

Found device at 0x52 Found device at 0x54 Found device at 0x56 Found device at 0x58

Using actor addresses: 0x52, 0x54, 0x56, 0x58 Actor state machine will be STARTED in Holger BL-Ctrl mode!

Found actors in current setup: 4 Needed actors in current HAL: 4 }}}