> Documentation index: https://nao-rs.lukaloehr.com/llms.txt, a list of every page in this documentation.

# Head fan

> How nao-rs reads the CPU temperature and sets the head fan through the CPU module's board controller.

The NAO6's head computer is a Congatec conga-QA3 module (board name `QA32`).
Its board controller reads the CPU temperature and drives the head fan's PWM.
Linux reaches it through Congatec's `cgosdrv` kernel driver at `/dev/cgos`,
which HULKs-OS loads at boot. Aldebaran's fan daemon `alfand` used it; on
HULKs-OS `alfand` doesn't run, so nothing controls the fan there.

The `fan` crate talks to `/dev/cgos` directly, with the same requests as
Aldebaran's fan library. The policy that decides the speed is on [Temperatures,
fan and thermal protection](https://nao-rs.lukaloehr.com/safety/thermal.md).

## Setting the speed

Setting a speed of 0 to 100 % sends, in this order:

1. the fan limits, with the new speed as the maximum output;
2. a board info request. When the board is not a `QA32`, it stops here and
   counts as success;
3. a speed above 100 is an error;
4. the board controller command "set PWM frequency";
5. the board controller command "set duty cycle" with the speed.

Reading the speed returns the maximum output from the fan info.

## Reading the temperature

The CPU temperature comes from the board controller in thousandths of a
degree. Each reading is written to `/var/run/alfand/cputemp` (six digits), as
Aldebaran's library does, so tools that read that file keep working.

## Checked live

On the robot (2026-11-06): board `QA32`, CPU at 52 °C, speed set to 70 and to
60 and read back. The control law is identical to Aldebaran's library on
300,000 random configurations.

The `fanspeed` and `faninfo` tools are described on [Temperatures, fan and
thermal protection](https://nao-rs.lukaloehr.com/safety/thermal.md#fan-tools).

## Related topics

- [Hardware reference](https://nao-rs.lukaloehr.com/hardware.md)
- [Chest board link](https://nao-rs.lukaloehr.com/hardware/chest-board.md)
- [Body sensors and units](https://nao-rs.lukaloehr.com/hardware/sensors.md)
- [Head devices](https://nao-rs.lukaloehr.com/hardware/head.md)
- [LEDs](https://nao-rs.lukaloehr.com/hardware/leds.md)
- Previous: [LEDs](https://nao-rs.lukaloehr.com/hardware/leds.md)
- Next: [Verification and parity](https://nao-rs.lukaloehr.com/verification.md)
