External devices

Contains modules which require extra hardware other than the PSLab itself.

motor

Motor control related classes.

Examples

>>> from pslab.external.motor import Servo
>>> servo = Servo("SQ1")
>>> servo.angle = 30  # Turn motor to 30 degrees position.
class pslab.external.motor.Servo(pin: str, pwm_generator: Optional[pslab.instrument.waveform_generator.PWMGenerator] = None, min_angle_pulse: int = 500, max_angle_pulse: int = 2500, angle_range: int = 180, frequency: float = 50)[source]

Bases: object

Control servo motors on SQ1-4.

Parameters
  • pin ({"SQ1", "SQ2", "SQ3", "SQ4"}) – Name of the digital output on which to generate the control signal.

  • pwm_generator (PWMGenerator, optional) – PWMGenerator instance with which to generate the control signal. Created automatically if not specified. When contolling multiple servos, they should all use the same PWMGenerator instance.

  • min_angle_pulse (int, optional) – Pulse length in microseconds corresponding to the minimum (0 degree) angle of the servo. The default value is 500.

  • max_angle_pulse (int, optional) – Pulse length in microseconds corresponding to the maximum (180 degree) angle of the servo. The default value is 2500.

  • angle_range (int) – Range of the servo in degrees. The default value is 180.

  • frequency (float, optional) – Frequency of the control signal in Hz. The default value is 50.

property angle

Angle of the servo in degrees.

Type

int or None