Skip to main content

Servo

Servo is a small motor with arm that can be pointing at a specific direction. Typically a servo angle is between 0° and 180° where 90° is the middle resting position.

The min_pulse/max_pulse may be read-only if the servo is permanently affixed to its Jacdac controller.

import { Servo } from "@devicescript/core"

const servo = new Servo()

Registers

angle

Specifies the angle of the arm (request).

  • type: Register<number> (packing format i16.16)

  • read and write

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.angle.read()
await servo.angle.write(value)
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.angle.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

enabled

Turn the power to the servo on/off.

  • type: Register<boolean> (packing format u8)

  • read and write

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.enabled.read()
await servo.enabled.write(value)
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.enabled.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

offset

Correction applied to the angle to account for the servo arm drift.

  • type: Register<number> (packing format i16.16)

  • read and write

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.offset.read()
await servo.offset.write(value)
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.offset.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

minValue

Lowest angle that can be set, typically 0 °.

  • type: Register<number> (packing format i16.16)

  • constant: the register value will not change (until the next reset)

  • read only

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.minValue.read()
note

write and read will block until a server is bound to the client.

minPulse

The length of pulse corresponding to lowest angle.

  • type: Register<number> (packing format u16)

  • optional: this register may not be implemented

  • read and write

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.minPulse.read()
await servo.minPulse.write(value)
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.minPulse.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

maxValue

Highest angle that can be set, typically 180°.

  • type: Register<number> (packing format i16.16)

  • constant: the register value will not change (until the next reset)

  • read only

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.maxValue.read()
note

write and read will block until a server is bound to the client.

maxPulse

The length of pulse corresponding to highest angle.

  • type: Register<number> (packing format u16)

  • optional: this register may not be implemented

  • read and write

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.maxPulse.read()
await servo.maxPulse.write(value)
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.maxPulse.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

stallTorque

The servo motor will stop rotating when it is trying to move a stall_torque weight at a radial distance of 1.0 cm.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.stallTorque.read()
note

write and read will block until a server is bound to the client.

responseSpeed

Time to move 60°.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.responseSpeed.read()
note

write and read will block until a server is bound to the client.

reading

The current physical position of the arm, if the device has a way to sense the position.

  • type: Register<number> (packing format i16.16)

  • optional: this register may not be implemented

  • read only

import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
const value = await servo.reading.read()
  • track incoming values
import { Servo } from "@devicescript/core"

const servo = new Servo()
// ...
servo.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.