Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Battery-Powered Remote-Controlled Dual Motor System with Cytron URC10

View and Edit Project In Cirkit DesignerImage of Battery-Powered Remote-Controlled Dual Motor System with Cytron URC10

Circuit Documentation

Summary

This circuit is designed to control two GM25 DC motors using a Cytron URC10 motor driver, powered by a 3S LiPo battery. The circuit also includes a rocker switch for power control, a 7-segment panel voltmeter for voltage monitoring, and an R6FG receiver for remote control. The Cytron URC10 motor driver is programmed to receive signals from the R6FG receiver and control the motors accordingly.

Component List

  1. Cytron URC10

    • Description: Motor driver for controlling two DC motors.
    • Pins: M1A, M1B, VM, GND, M2A, M2B, G, V, D10, D11
  2. GM25 DC MOTOR (Motor 1)

    • Description: DC motor for mechanical movement.
    • Pins: +VE, -VE
  3. GM25 DC MOTOR (Motor 2)

    • Description: DC motor for mechanical movement.
    • Pins: +VE, -VE
  4. 3S LIPO BATTERY

    • Description: Power source for the circuit.
    • Pins: -VE, +VE
  5. Rocker Switch

    • Description: Switch to control the power supply.
    • Pins: Output, Input
  6. 7-Segment Panel Voltmeter

    • Description: Displays the voltage of the power supply.
    • Pins: V+, V-
  7. R6FG RECEIVER

    • Description: Receiver for remote control signals.
    • Pins: GND, VCC, CH1, CH2

Wiring Details

Cytron URC10

GM25 DC MOTOR (Motor 1)

GM25 DC MOTOR (Motor 2)

3S LIPO BATTERY

Rocker Switch

7-Segment Panel Voltmeter

R6FG RECEIVER

Documented Code

// Almost same as URC10 Motor Driver Pins
#define leftPWM 5
#define leftDir 4
#define rightPWM 6
#define rightDir 7

// Receiver pins
#define RX_CH_1 11   // Steering Channel (Turn Left / Right)
#define RX_CH_2 10  // Throttle channel (Move Forward / Backward)

// Parameters
#define deadZone 50  // Anything between -20 and 20 is STOP

int throttleCH, steeringCH;
int leftMotorSpeed, rightMotorSpeed;

void setup() {
  Serial.begin(9600);
  pinMode(leftPWM, OUTPUT);
  pinMode(leftDir, OUTPUT);
  pinMode(rightPWM, OUTPUT);
  pinMode(rightDir, OUTPUT);
  pinMode(RX_CH_1, INPUT);
  pinMode(RX_CH_2, INPUT);

  digitalWrite(leftDir, LOW);
  analogWrite(leftPWM, 0);
  digitalWrite(rightDir, LOW);
  analogWrite(rightPWM, 0);
}

// Main Loop
void loop() {

  // Read pulse width from receiver
  throttleCH = pulseIn(RX_CH_2, HIGH, 30000);
  steeringCH = pulseIn(RX_CH_1, HIGH, 30000);
  // Serial.print(" steeringCH : ");
  // Serial.println(steeringCH);
  // Serial.print(" throttleCH: ");
  // Serial.println(steeringCH);

  // Convert to PWM value (-255 to 255)
  throttleCH = pulseToPWM(throttleCH);
  steeringCH = pulseToPWM(steeringCH);

  // Channel 1 and Channel 2 Mixing
  leftMotorSpeed = throttleCH - steeringCH;
  rightMotorSpeed = throttleCH + steeringCH;

  // Drive motor
  drive(leftMotorSpeed, rightMotorSpeed);
  //  Serial.print("  leftMotorSpeed : ");
  //  Serial.println(leftMotorSpeed);
  //  Serial.print("   rightMotorSpeed: ");
  //  Serial.println(rightMotorSpeed);

  delay(1);
}

// Positive for forward, negative for reverse
void drive(int leftVal, int rightVal) {

  // Limit speed between -255 and 255
  leftVal = constrain(leftVal, -255, 255);
  rightVal = constrain(rightVal, -255, 255);

  // Set direction for left motor
  if (leftVal == 0) {
    analogWrite(leftDir, 0);
    analogWrite(leftPWM, 0);
  } else if (leftVal > 0) {
    digitalWrite(leftDir, HIGH);
    analogWrite(leftPWM, abs(leftVal));
  } else {
    digitalWrite(leftDir, LOW);
    analogWrite(leftPWM, abs(leftVal));

  }

  // Set direction for right motor
  if (rightVal == 0) {
    analogWrite(rightDir, 0);
    analogWrite(rightPWM, 0);

  } else if (rightVal > 0) {
    digitalWrite(rightDir, HIGH);
    analogWrite(rightPWM, abs(rightVal));
  } else {
    digitalWrite(rightDir, LOW);
    analogWrite(rightPWM, abs(rightVal));

  }
}

// Convert RC pulse value to motor PWM value
int pulseToPWM(int pulse) {

  // If we're receiving numbers, convert them to motor PWM
  if (pulse > 500) {
    pulse = map(pulse, 1000, 2000, -500, 500);
    pulse = constrain(pulse, -255, 255);
  } else {
    pulse = 0;
  }

  // Anything in deadzone should stop the motor
  if (abs(pulse) <= deadZone) {
    pulse = 0;
  }
  return pulse;
}

This code is designed to control the motors based on the signals received from the R6FG receiver. The setup function initializes the pins and sets the initial motor states. The loop function reads the pulse width from the receiver, converts it to a PWM value, and drives the motors accordingly. The drive function sets the motor direction and speed, while the pulseToPWM function converts the RC pulse value to a motor PWM value.