Skip to content

Add NUSense Fan Controller functionality#38

Merged
miles-p merged 24 commits intomainfrom
punch/fan-controller
Apr 13, 2026
Merged

Add NUSense Fan Controller functionality#38
miles-p merged 24 commits intomainfrom
punch/fan-controller

Conversation

@miles-p
Copy link
Copy Markdown
Contributor

@miles-p miles-p commented Apr 8, 2026

This PR is linked to functionality on NUBots PR#1763

This PR enables use of the MAX31760 Fan controller IC on the NUSense board, detects if a fan has dropped below a set RPM threshold, and passes a fan warning to NUSense through the existing ProtoBuf framework.

This chip has the functionality to automatically control a tachometer-enabled fan, however this behavior has not been implemented. On startup of NUSense, the fans are put in manual mode (disable all automatic control and write PWM directly to the fans) and sends them full blast (255/255) for full fan speed.

In the NUSense super-loop, the fan controller IC is polled for each fans speed, and is then compared against the fan controller warning threshold (100RPM) which determines whether or not to report an error back to the NUC.

Copy link
Copy Markdown
Member

@ysims ysims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you use the nanopb tool in the NUbots/NUbots repo to update the NUSenseData protobuf files here? It's been a while, so I can't remember exactly, but mostly interested to know if the tool is working well still as-is, otherwise if you had to do anything like update libraries make sure they go in the other PR for the next person.

I'm assuming that only the pb.* files are auto generated.

It looks like a lot of comments, but a lot of them are the same point just repeated.
Some of this is convention, which can be confusing here if the auto generated code does something different.

Good stuff!

Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Inc/i2c.h Outdated
Comment thread NUSense/Core/Src/fan_controller.c Outdated
Comment thread NUSense/Core/Src/fan_controller.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/main.cpp Outdated
Comment thread NUSense/Core/Src/main.cpp Outdated
@miles-p miles-p changed the title Punch/fan controller Add NUSense Fan Controller functionality Apr 9, 2026
@miles-p miles-p requested a review from ysims April 9, 2026 12:03
@miles-p
Copy link
Copy Markdown
Contributor Author

miles-p commented Apr 9, 2026

Did you use the nanopb tool in the NUbots/NUbots repo to update the NUSenseData protobuf files here? It's been a while, so I can't remember exactly, but mostly interested to know if the tool is working well still as-is, otherwise if you had to do anything like update libraries make sure they go in the other PR for the next person.

I'm assuming that only the pb.* files are auto generated.

It looks like a lot of comments, but a lot of them are the same point just repeated. Some of this is convention, which can be confusing here if the auto generated code does something different.

Good stuff!

Yes - autogenerated by ./b nusense generate_nanopb_message
I accidentally neglected to read the docs at first and hand wrote them, copying other pb layouts - then I rolled back and did it all properly...

Copy link
Copy Markdown
Member

@ysims ysims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice re:the nanopb tool, and yeah definitely something that can get missed. Is there a NUSense page going up on NUbook? It would be good to mention this in a NUSense development page

Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
Comment thread NUSense/Core/Src/i2c.c Outdated
@Claegtun
Copy link
Copy Markdown
Contributor

Nice re:the nanopb tool, and yeah definitely something that can get missed. Is there a NUSense page going up on NUbook? It would be good to mention this in a NUSense development page

There is a draft. Will definitely add. I forgot about the new ./b tool.

@JohanneMontano
Copy link
Copy Markdown
Contributor

wait theres a tool to generate nanopb messages in the code base?

Copy link
Copy Markdown
Contributor

@JohanneMontano JohanneMontano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

Comment thread NUSense/Core/Inc/fan_controller.h
Comment thread NUSense/Core/Src/fan_controller.c Outdated
Comment thread NUSense/Core/Src/fan_controller.c Outdated
@miles-p
Copy link
Copy Markdown
Contributor Author

miles-p commented Apr 10, 2026

wait theres a tool to generate nanopb messages in the code base?

you're as surprised as I was after I had handwritten out all the message stuff...

@miles-p miles-p requested a review from ysims April 10, 2026 04:19
@JohanneMontano
Copy link
Copy Markdown
Contributor

wait theres a tool to generate nanopb messages in the code base?

you're as surprised as I was after I had handwritten out all the message stuff...

I dont remember writing the tool ngl lol

@miles-p miles-p merged commit 50f2e84 into main Apr 13, 2026
@miles-p miles-p deleted the punch/fan-controller branch April 13, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants