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, install
TypeScript @pamoja/actuators reference, install
Python pamoja-actuators reference, install
C# Pamoja.Actuators reference, install

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.17.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.17-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pamoja_actuators-0.1.17.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.17.tar.gz
Algorithm Hash digest
SHA256 4924e1883f6ad990ecb87b0859d270df1d0d21fd5ed11c7fce8ec4df6c1ed624
MD5 f8d2dbafbf892d6f837acb1bea597336
BLAKE2b-256 1edd9fb5ad9fb6e0ffbd5c934cbe317efff3be03912cbd95d93dd794e4568ed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pamoja_actuators-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 f26ac4cebd00864b025118ac9a8e2511b32d3166edf8d5c50f5dc4e415b571f9
MD5 efe261f94f23359ba9fe7be7be231a9c
BLAKE2b-256 776d812f4070384617dd148655b9fae1b0c2c15b46ff2c8e14f0fdcaa84204d2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.17 This release

2 files

0.1.16

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