Skip to main content

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#.

API reference read the guide documentation

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 centred 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.
centred = pwm.servo(1500, 50)
print(f"centred servo goes low at count {pwm.counts(centred).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
TypeScript @pamoja/actuators reference
Python pamoja-actuators reference
C# Pamoja.Actuators reference

Documentation

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pamoja_actuators-0.1.16.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pamoja_actuators-0.1.16-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pamoja_actuators-0.1.16.tar.gz.

File metadata

  • Download URL: pamoja_actuators-0.1.16.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for pamoja_actuators-0.1.16.tar.gz
Algorithm Hash digest
SHA256 3fbd8345a52de4d9d80ebf9f6064e21ea46a6f99ed91cc630ccc30175e886909
MD5 95531b6c4aade5c68b91fa67644398fe
BLAKE2b-256 7fe505ec060104f086eb80fbc59a03073174eb2761bdc2affeb33c6b36d29d90

See more details on using hashes here.

File details

Details for the file pamoja_actuators-0.1.16-py3-none-any.whl.

File metadata

File hashes

Hashes for pamoja_actuators-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 06dd104a6f5ea2b719e9e77833c5f1a1f566426a6c9db375f65a52175b4836cc
MD5 c839a510d6d0bcf7fa64b02b93c05e5c
BLAKE2b-256 61d447d818a9a951aa8eb725eee548c83ae3f8880926cf851d292b87fe3e8c67

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.17

2 files

This release

0.1.16 This release

2 files

0.1.15

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page