# Module Configuration Blocks

Analog and temperature modules take a configuration block over the backplane.
Both libraries send the factory default at sign-on, so a module reads correctly
without one. Send a block only to override that default.

| Module | Block length |
|---|---|
| SLM-AI-8-V, SLM-AI-8-mA | 2 bytes |
| SLM-THM-4 | 20 bytes |
| All other modules | None |

Every field is a big-endian 16-bit word. A block sent to a module that takes
none is ignored.

## Channel enable

Channels are enabled contiguously from CH1, which cannot be disabled. The word
is `0x4000 + (n - 1)`, where `n` is the number of channels enabled.

| Value | Channels |
|---|---|
| `0x4000` | CH1 |
| `0x4001` | CH1 - CH2 |
| `0x4003` | CH1 - CH4 |
| `0x4007` | CH1 - CH8 |

## SLM-AI-8-V and SLM-AI-8-mA

| Bytes | Field |
|---|---|
| 0-1 | Channel enable |

Default: `0x40 0x07`, all eight channels.

```python
module.configure_module((0x40, 0x03))   # CH1 - CH4 only
```

## SLM-THM-4

| Bytes | Field |
|---|---|
| 0-1 | Channel enable, `0x4000` - `0x4003` |
| 2-3 | Burnout detection and units |
| 4-5 | CH1 range, `0x2100 + code` |
| 6-7 | CH2 range, `0x2200 + code` |
| 8-9 | CH3 range, `0x2300 + code` |
| 10-11 | CH4 range, `0x2400 + code` |
| 12-19 | Reserved, write zero |

Burnout detection and units:

| Value | Meaning |
|---|---|
| `0x6001` | Low burnout, degrees C |
| `0x6003` | High burnout, degrees C |
| `0x6005` | Low burnout, degrees F |
| `0x6007` | High burnout, degrees F |

Range codes, occupying the low nibble of each channel word:

| Code | Range | Code | Range |
|---|---|---|---|
| `0x0` | Type J | `0x8` | Type C |
| `0x1` | Type K | `0x9` | 0 - 39 mV |
| `0x2` | Type E | `0xA` | ±39 mV |
| `0x3` | Type R | `0xB` | ±78 mV |
| `0x4` | Type S | `0xC` | 0 - 156 mV |
| `0x5` | Type T | `0xD` | ±156 mV |
| `0x6` | Type B | `0xE` | 0 - 1.25 V |
| `0x7` | Type N | | |

Default: CH1 - CH4 enabled, low burnout, degrees Fahrenheit, Type J on every
channel.

```python
module.configure_module((
    0x40, 0x03,   # CH1 - CH4
    0x60, 0x01,   # low burnout, degrees C
    0x21, 0x01,   # CH1 Type K
    0x22, 0x00,   # CH2 Type J
    0x23, 0x00,   # CH3 Type J
    0x24, 0x00,   # CH4 Type J
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
))
```

```{important}
The factory default is degrees **Fahrenheit** and Type **J** on every channel.
A Type K sensor read as Type J is linearised with the wrong curve: the error is
small near ambient and grows with temperature.
```
