Giter Site home page Giter Site logo

oksion / cm4iofan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tmsmr/cm4iofan

0.0 0.0 0.0 11.28 MB

Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO.

License: MIT License

Go 100.00%

cm4iofan's Introduction

cm4iofan

Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO.

Requirements

  • Enabled i2c_vc overlay (dtparam=i2c_vc=on in /boot/config.txt)
  • Loaded i2c-dev module (e.g. modprobe i2c-dev or using /etc/modules)
  • A user in the i2c group (or root)

Using the Go Module

import "github.com/tmsmr/cm4iofan"
 
...

ctrl, err := cm4iofan.New()
if err != nil {
	panic(err)
}
err = ctrl.SetDutyCycle(50)
if err != nil {
	panic(err)
}

Using fanctl

  • Build with cd fanctl && go build.
  • For every tagged version of the Go Module, the fanctl utility is built in a GitHub Action (Available on the Releases page).
$ fanctl set 50
$ fanctl get
50
$ fanctl rpm
2623

POC with thermal monitoring

You may use https://github.com/tmsmr/chilld as thermal controller on your Raspberry Pi Compute Module 4 IO Board.

Comments

Direct Setting mode vs. Fan Speed Control mode

The EMC2301 has a built-in closed loop Fan Speed Control algorithm (Besides many awesome features), that allows the user to select a target RPM which is controlled by a PID. I opted for the Direct Setting mode, because it feels more natural to me (Yes, i know that duty cycle/RPM is far from linear...).

Should i use this for my 24/7-running project?

If you want nothing but a reliable/automatic cooling solution for your CM4IO, you should probably go with something like https://github.com/neg2led/cm4io-fan.

There are scenarios where this Module might be handy (Well, that's why i built it...). But keep in mind, all you do with it, is setting the fan's PWM signal:

  • Some fans won't stop with 0% duty cycle.
  • Most fans will stall with a low duty cycle.
  • ...

TACH to RPM conversion

Unfortunately it is not possible to detect RPM's lower than 500 using the EMC2301. That's why the RPM measurement returns a RPMResult:

type RPMResult struct {
    Rpm int
    Stopped bool
    Undef bool
}
  • When the PWM duty cycle is set to 0%, Stopped is true. This is only true for fans that are able to stop completely!
  • When the calculated RPM is below 500 (smallest value could be 480), it is not possible to determine the real RPM. In this case Undef is true.

On poles, edges and ranges...

The EMC2301 may be used to control a wide variety of PWM fans. TACH measurement works different based on the fan's design type (emc2301.pdf: 4.4 Tachometer Measurement).

Noctua's PWM specification states that (regardless of the actual motor design) the tachometer always pulses two times per revolution (Emulating a fan with 2 poles). I think this is true for other regular, modern PWM fans. That's why i settled with the following values for the RPM calculation:

  • poles = 2
  • n = 5

Since i wanted to measure RPM's as low as possible, RANGE[1:0] is set to 500 RPM. This means the TACH multiplier is m = 1.

Using these values, a simplified formula for TACH conversion can be used (emc2301.pdf: EQUATION 4-3).

cm4iofan's People

Contributors

tmsmr avatar oksion avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.