PHPackages                             dept-of-scrapyard-robotics/generic-fans - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. dept-of-scrapyard-robotics/generic-fans

ActiveLibrary[Framework](/categories/framework)

dept-of-scrapyard-robotics/generic-fans
=======================================

Drive generic digital and PWM fans with ScrapyardIO

0.7.x-dev(2w ago)02MITPHPPHP ^8.4|^8.5|^8.6

Since Jul 12Pushed 2w agoCompare

[ Source](https://github.com/DeptOfScrapyardRobotics/GenericFans)[ Packagist](https://packagist.org/packages/dept-of-scrapyard-robotics/generic-fans)[ Docs](https://dosr.projectsaturnstudios.com)[ RSS](/packages/dept-of-scrapyard-robotics-generic-fans/feed)WikiDiscussions 0.7.x Synced 1w ago

READMEChangelogDependencies (13)Versions (4)Used By (0)

Generic Fans
============

[](#generic-fans)

### Drive fans over digital GPIO and PWM with PHP

[](#drive-fans-over-digital-gpio-and-pwm-with-php)

PHP package for on/off case fans, PWM speed-controlled fans, and open-collector tachometers. It sits on the ScrapyardIO GPIO stack and plugs into the BareMetal Actuation fan components (`BasicFan`, `SpeedControllableFan`, `TachometerComponent`).

Compatible Digital Interfaces
=============================

[](#compatible-digital-interfaces)

Simple on/off fans (relay, MOSFET, or Pironman-style GPIO fans) are driven from a digital output pin.

You can interface with them the following ways:

- A Linux single-board computer's exposed GPIO pins using the POSIX / libgpiod carrier (`posix`)
- An MPSSE-enabled USB-to-serial device such as an FT232H using the USB carrier (`usb`) for digital out

Compatible PWM Interfaces
=========================

[](#compatible-pwm-interfaces)

4-pin speed-controlled fans are driven from a hardware PWM channel (duty cycle = speed %, period = carrier frequency).

You can interface with them the following ways:

- A Linux single-board computer's native PWM sysfs chips (`/sys/class/pwm/pwmchipN`) using the native carrier (`native`)
- *(Planned)* An I²C PWM expander such as the PCA9685 — not wired in this package yet

Compatible Tach Interfaces
==========================

[](#compatible-tach-interfaces)

Most PC / case fan tach lines are open-collector and need a pull-up. This package samples rising edges on a digital input and returns RPM (default: 2 pulses per revolution).

You can interface with them the following ways:

- A Linux single-board computer's exposed GPIO pins using the POSIX carrier (`posix`) with `LineBias::PULL_UP`
- An MPSSE-enabled USB digital input using the USB carrier (`usb`) with an appropriate pull-up

Dependencies
============

[](#dependencies)

This package makes use of modules within:

- [The ScrapyardIO Framework](https://github.com/ScrapyardIO/framework)

For digital on/off fans and tachometers you also need:

- [POSI Extension v^0.4.0 or newer](https://github.com/php-io-extensions/posi)
- [Microscrap POSIX Package](https://github.com/microscrap/posix)
- [Microscrap Native GPIO Package](https://github.com/microscrap/gpio)
- [Microscrap POSIX Drivers](https://github.com/microscrap/scrapyard-posix-drivers) (`posix` carrier)

For PWM speed-controlled fans you also need:

- [Microscrap Native Drivers](https://github.com/microscrap/scrapyard-native-drivers) (`native` PWM carrier)

Installing from Composer
========================

[](#installing-from-composer)

```
composer require dept-of-scrapyard-robotics/generic-fans
```

Basic Usage
===========

[](#basic-usage)

### Digital on/off fan (POSIX)

[](#digital-onoff-fan-posix)

```
