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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pamoja_actuators-0.1.15.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.15.0

File hashes

Hashes for pamoja_actuators-0.1.15.tar.gz
Algorithm Hash digest
SHA256 7bb98fbf3cd20a4df769882c543b5e60b4b18bc01898183db82f6c98b2624f08
MD5 23859a0ce0c58288fdf2f8f358dceb31
BLAKE2b-256 ab1a53049071b3e673e76eb2835ae3ee27719ef2497c5309772bd100c52c9f5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pamoja_actuators-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 890d52352986723f862f30f90b079f8b4e051153cd38918eb925a584def64135
MD5 de7f7e6fc33e538e5f5dd9649eeaad29
BLAKE2b-256 f03d258bab74b43046ae8bfae198d7bfffc2926fa81d907f730fb6271c27a585

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.17

2 files

0.1.16

2 files

This release

0.1.15 This release

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