control

Note

WIP

ROS2

ROS2 is the main framework for the control part.

protocals

PWM

PWM is used to directly control the motor.

This project uses continuous rotation servos, which allow for continuous movement in either direction rather than fixed positional control.

Overview

Pulse Width Modulation (PWM) is used to control servos by varying the pulse width within a fixed frequency cycle.

Key Concepts

  • Frequency:

    • Typically 50 Hz for servos.

    • Each cycle lasts 20 milliseconds (ms).

  • Pulse Width:

    • Duration the signal is high within each cycle.

    • Range: 0.5 ms (500 µs) to 2.5 ms (2500 µs).

  • Duty Cycle:

    • Calculated as \( \frac{\text{Pulse Width}}{\text{Period}} \).

    • Determines the servo position or speed.

Servo Control

50hz

  • Stop:

    • Pulse width around 1.45 ms to 1.5 ms.

    • duty_cycle 0x1430 - 0x1499

  • Forward Rotation:

    • Pulse width from 1.45 ms down to 0.5 ms.

    • 0x1429-0x600

    • 4911 slowest

  • Reverse Rotation:

    • Pulse width from 1.5 ms up to 2.5 ms.

    • 0x1500 - 0x2200

    • 5328 slowest

Example

  • Period: 20 ms (50 Hz frequency).

  • Pulse Width for Stop: 1.45 ms to 1.5 ms.

  • Duty Cycle for Stop: \( \frac{1.5 \, \text{ms}}{20 \, \text{ms}} = 7.5\% \).

I2C

I2C is used to communicate with the motor driver. In this case, the motor driver is a PCA9685A.

PCA9685

  • Purpose:

    • PWM controller for servos and LEDs.

  • Connection:

    • Communicates with Raspberry Pi via I2C.

  • Features:

    • 16-channel PWM outputs.

    • Adjustable frequency for precise control.

  • Benefits:

    • Simplifies control of multiple servos.

    • Reduces wiring complexity with two-wire I2C interface.