pamoja-actuators
PCA9685 PWM and servo pulses, and stepper coil sequencing. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-actuators
from pamoja import actuators
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/actuators.py:
from pamoja.actuators import Direction, Drive, Stepper, pca9685, pwm, steps_for_degrees
# A servo bank wants 50 Hz. The prescale register that produces it is derived from the
# part's 25 MHz internal oscillator, so a caller names the rate it wants rather than
# working the divider out.
prescale = pca9685.prescale_for_frequency(50)
print(f"prescale {prescale} gives {pca9685.frequency_for_prescale(prescale):.1f} Hz")
# Each channel owns four consecutive registers, so a whole channel is written in one bus
# transaction rather than four.
print(f"channel 3 starts at register 0x{pca9685.channel_register(3):02X}")
# A centered hobby servo holds its output high for 1500 us of the 20 ms period. The part
# counts in 4096 steps per period, so that is where the pulse ends.
centered = pwm.servo(1500, 50)
print(f"centered servo goes low at count {pwm.counts(centered).off} of 4096")
# Fully off carries its own flag rather than a zero duty, which would still hold the
# output high for the first count of every period.
print(f"full off flag set: {pwm.counts(pwm.full_off()).off != pwm.counts(pwm.duty(0)).off}")
# A stepper is driven by walking a pattern of coil states. Half-step drive interleaves
# the one-coil and two-coil patterns, so it has twice as many.
motor = Stepper(Drive.HALF_STEP)
print(f"coils {motor.coils:04b} at rest")
for _ in range(2):
print(f"coils {motor.step(Direction.FORWARD):04b} after a step")
# The patterns wrap, so the motor runs indefinitely either way, and an angle converts to
# whole steps: a quarter turn of a 1.8-degree motor is fifty of them.
for _ in range(2, Drive.HALF_STEP.step_count):
motor.step(Direction.FORWARD)
print(f"coils {motor.coils:04b} back at the start of the cycle")
print(f"a quarter turn is {steps_for_degrees(90.0, 200)} steps")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-actuators |
reference, docs.rs, install |
| TypeScript | @pamoja/actuators |
reference, install |
| Python | pamoja-actuators |
reference, install |
| C# | Pamoja.Actuators |
reference, install |
Documentation
pamoja.actuatorsreference, every class and function in this module.- The Actuator drivers guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Release files for pamoja-actuators 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pamoja_actuators-0.1.18.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pamoja_actuators-0.1.18-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / pamoja_actuators-0.1.18.tar.gz
| Download URL | pamoja_actuators-0.1.18.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac0a215aa48784bc2b1c0719dfffc2763637c4b546993bc2a0aed4cdb3d6e21a
|
|
BLAKE2b-256 checksum How to use checksums |
2f92abee26cd2fc6a8b8b1902feb793dc878bd4ae36ef525108cd29ff222ed78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pamoja_actuators-0.1.18-py3-none-any.whl
| Download URL | pamoja_actuators-0.1.18-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86f3381e71c600fa59167d63c15716f44b7ec18d6aeef00e4ffd459406698f20
|
|
BLAKE2b-256 checksum How to use checksums |
8b047fad4b2daf14ee4726a69985a44687758c910cbf9a922d05f29fc5a69246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|