/HALs |
The NG Hardware Abstraction Layer
Contents
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 Description |
The do-nothing HAL |
HAL Quality |
proven |
Needed actors |
0 |
Description |
This HAL really does nothing. It's using no actors and can't fly. |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
The 'blc' HAL
HAL Description |
The BLC test HAL |
HAL Quality |
only for testing purposes |
Needed actors |
0 |
Description |
This 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.HAL |
The chosen HW abstraction layer |
|
BLC1 |
BL-Controller 1 output, set this to get actor 1 moving |
|
BLC2 |
BL-Controller 2 output, set this to get actor 2 moving |
|
... |
... |
|
BLC16 |
BL-Controller 16 output, set this to get actor 16 moving |
The 'quad' HAL
HAL Description |
The 4 rotor Quadcopter HAL |
HAL Quality |
proven |
Needed actors |
4 |
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. |
|
|
Motor 1 |
front |
Motor 2 |
back |
Motor 3 |
right |
Motor 4 |
left |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
The 'quadX' HAL
HAL Description |
The 4 rotor Quadcopter HAL (X-formation) |
HAL Quality |
proven |
Needed actors |
4 |
Description |
This 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 1 |
front-left |
Motor 2 |
back-right |
Motor 3 |
front-right |
Motor 4 |
back-left |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
The 'quadR' HAL
HAL Description |
The 4 rotor Quadcopter HAL (reverse) |
HAL Quality |
proven |
Needed actors |
4 |
Description |
This 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 1 |
back |
Motor 2 |
front |
Motor 3 |
right |
Motor 4 |
left |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
The 'Y6' HAL
HAL Description |
The 6 rotor Y6 Hexakopter Coax HAL |
HAL Quality |
proven |
Needed actors |
6 |
Description |
This 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 1 |
front-left-up |
Motor 2 |
front-right-up |
Motor 3 |
back-up |
Motor 4 |
front-left-down |
Motor 5 |
front-right-down |
Motor 6 |
back-down |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
|
HAL.fact.top |
Throttle factor for top layer |
|
HAL.fact.bottom |
Throttle factor for bottom layer |
The 'X8' HAL
HAL Description |
The 8 rotor X8 Oktocopter Coax HAL |
HAL Quality |
ready for test flights |
Needed actors |
8 |
Description |
This 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 1 |
front-up |
Motor 2 |
back-up |
Motor 3 |
right-up |
Motor 4 |
left-up |
Motor 5 |
front-down |
Motor 6 |
back-down |
Motor 7 |
right-down |
Motor 8 |
left-down |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
|
HAL.fact.top |
Throttle factor for top layer |
|
HAL.fact.bottom |
Throttle factor for bottom layer |
The 'X8X' HAL
HAL Description |
The 8 rotor X8 Oktocopter Coax HAL (X-formation) |
HAL Quality |
ready for test flights |
Needed actors |
8 |
Description |
This 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 1 |
front-left-up |
Motor 2 |
back-right-up |
Motor 3 |
front-right-up |
Motor 4 |
back-left-up |
Motor 5 |
front-left-down |
Motor 6 |
back-right-down |
Motor 7 |
front-right-down |
Motor 8 |
back-left-down |
|
Parameters: |
HW.HAL |
The chosen HW abstraction layer |
|
HAL.fact.top |
Throttle factor for top layer |
|
HAL.fact.bottom |
Throttle 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
