Skip to main content

Motor

caution

This service is rc and may change in the future.

A DC motor.

import { Motor } from "@devicescript/core"

const motor = new Motor()

Registers

speed

Relative speed of the motor. Use positive/negative values to run the motor forwards and backwards. Positive is recommended to be clockwise rotation and negative counterclockwise. A speed of 0 while enabled acts as brake.

  • type: Register<number> (packing format i1.15)

  • read and write

import { Motor } from "@devicescript/core"

const motor = new Motor()
// ...
const value = await motor.speed.read()
await motor.speed.write(value)
  • track incoming values
import { Motor } from "@devicescript/core"

const motor = new Motor()
// ...
motor.speed.subscribe(async (value) => {
...
})
note

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

enabled

Turn the power to the motor on/off.

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

  • read and write

import { Motor } from "@devicescript/core"

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

const motor = new Motor()
// ...
motor.enabled.subscribe(async (value) => {
...
})
note

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

loadTorque

Torque required to produce the rated power of an electrical motor at load speed.

  • 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 { Motor } from "@devicescript/core"

const motor = new Motor()
// ...
const value = await motor.loadTorque.read()
note

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

loadRotationSpeed

Revolutions per minute of the motor under full load.

  • 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 { Motor } from "@devicescript/core"

const motor = new Motor()
// ...
const value = await motor.loadRotationSpeed.read()
note

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

reversible

Indicates if the motor can run backwards.

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

  • optional: this register may not be implemented

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

  • read only

import { Motor } from "@devicescript/core"

const motor = new Motor()
// ...
const value = await motor.reversible.read()
note

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