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 formati16.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) => {
...
})
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 formatu8
)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) => {
...
})
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 formati16.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) => {
...
})
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 formati16.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()
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 formatu16
)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) => {
...
})
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 formati16.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()
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 formatu16
)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) => {
...
})
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 formatu16.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()
write
and read
will block until a server is bound to the client.
responseSpeed
Time to move 60°.
type:
Register<number>
(packing formatu16.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()
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 formati16.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) => {
...
})
write
and read
will block until a server is bound to the client.