Pluto Logo

by Drona Aviation

Profile
Menu
Documentation
Pluto-IDE & MagisV2 SDK
Pluto-IDE & MagisV2 API Reference

Motor

Code with Pluto-IDE

Pluto-IDE is the professional development environment required to build, flash, and monitor firmware using the MagisV2 library on Pluto Drones.

Get Pluto-IDE

Motor.h

Bidirectional motor control interface for drone motor management.

Enumerations

motor_direction_e

typedef enum motor_direction {
    CLOCK_WISE = 0,     // Clockwise rotation
    ANTICLOCK_WISE      // Counter-clockwise rotation
} motor_direction_e;

bidirectional_motor_e

typedef enum bidirectional_motor {
    M1,    // Motor 1
    M2,    // Motor 2
    M5,    // Motor 5
    M6,    // Motor 6
    M7,    // Motor 7
    M8     // Motor 8
} bidirectional_motor_e;

Global Variables

  • bool usingMotorAPI - Flag indicating motor API usage

Functions

void Motor_Init(bidirectional_motor_e _motor)

Initializes specified motor for bidirectional control.

Parameters:

  • _motor - Motor to initialize

void Motor_Set(bidirectional_motor_e _motor, int16_t pwmValue)

Sets PWM value for specified motor.

Parameters:

  • _motor - Motor to control
  • pwmValue - PWM value (positive/negative for direction, magnitude for speed)

void Motor_SetDir(bidirectional_motor_e motor, motor_direction_e direction)

Sets rotation direction for specified motor.

Parameters:

  • motor - Motor to control
  • direction - Rotation direction (CLOCK_WISE or ANTICLOCK_WISE)

Usage Example

// Initialize motors
Motor_Init(M1);
Motor_Init(M2);
Motor_Init(M5);
Motor_Init(M6);

// Set directions
Motor_SetDir(M1, CLOCK_WISE);
Motor_SetDir(M2, ANTICLOCK_WISE);

// Set motor speeds
Motor_Set(M1, 1200);   // Forward at medium speed
Motor_Set(M2, -800);   // Reverse at low speed
Motor_Set(M5, 0);      // Stop motor
Motor_Set(M6, 1500);   // Forward at high speed

// Gradual speed increase
for (int speed = 0; speed <= 1500; speed += 100) {
    Motor_Set(M1, speed);
    delay(100);
}