PHPackages                             dept-of-scrapyard-robotics/generic-servos - 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-servos

ActiveLibrary[Framework](/categories/framework)

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

Drive positional and continuous servos over PWM with ScrapyardIO

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

Since Jul 12Pushed 2w agoCompare

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

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

Generic Servos
==============

[](#generic-servos)

### Drive hobby servos over PWM with PHP

[](#drive-hobby-servos-over-pwm-with-php)

PHP package for positional (angle) and continuous-rotation hobby servos. It sits on the ScrapyardIO GPIO PWM stack and plugs into the BareMetal Actuation servo components (`PositionalServo`, `ContinuousServo`).

**Which kind do I need?**

- **Positional** (`GenericPositionalServo`) — the horn holds an angle (`to()`, `center()`, `sweep()`). Arms, flaps, camera pans.
- **Continuous** (`GenericContinuousServo`) — the shaft spins (`cw()` / `ccw()` / `stop()`). Wheels, winches, continuous drives. Neutral is a deadband around mid-pulse, not a parked angle.

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

[](#compatible-pwm-interfaces)

Hobby servos are driven from a hardware PWM channel at a **50 Hz** frame (`20_000_000` ns period). Pulse width in microseconds maps to angle (positional) or spin direction/speed (continuous).

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 — reserved in the package suggests and transport todos, not wired yet

Default pulse range is **1000–2000 µs** (safe for most hobby servos). Narrower or wider ranges can be passed at construction or via `calibrate()`.

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

[](#dependencies)

This package makes use of modules within:

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

For PWM-driven servos you also need:

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

Confirm the host exposes PWM and that your user can write the sysfs nodes (often root, or a udev-granted group). See the native-drivers README Requirements for details:

```
ls /sys/class/pwm
```

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

[](#installing-from-composer)

```
composer require dept-of-scrapyard-robotics/generic-servos
composer require microscrap/native-drivers
```

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

[](#basic-usage)

Build the PWM channel with the GPIO facade, then hand that channel to the servo IC. Call `boot()` (or pass `boot_now: true`) so the driver sets the 50 Hz frame, parks at the starting position / deadband, and enables the channel.

### Positional servo (native sysfs)

[](#positional-servo-native-sysfs)

```
