Voltage drop in my system

Hello,

I am giving joystick inputs to an an arduino mega and i am then giving those inputs to an arduino uno r3 through i2c. From the arduino uno i am controlling a PCA9685 motor driver with four servos. I am giving the arduinos 5V and the PCA 5V but the power going to the PCA is outputting 2V instead of 5V. When i input joytick commands the voltage going to the PCA immediately drops to 2V.

Attached is my setup.

Here is the Wire diagram for my setup.

And here is my code.

Master (Arduino Mega)

#include <Wire.h>

int joy1XPin = A0;  // Joystick 1 X-axis pin
int joy1YPin = A1;  // Joystick 1 Y-axis pin
int joy2XPin = A2;  // Joystick 2 X-axis pin
int joy2YPin = A3;  // Joystick 2 Y-axis pin

int joy1XVal, joy1YVal, joy2XVal, joy2YVal;

void setup() {
  Serial.begin(9600);
  Wire.begin();  // Join I2C bus as master
}

void loop() {
  // Read joystick values for Joystick 1 and Joystick 2
  joy1XVal = analogRead(joy1XPin);  // Read X-axis of Joystick 1
  joy1YVal = analogRead(joy1YPin);  // Read Y-axis of Joystick 1
  joy2XVal = analogRead(joy2XPin);  // Read X-axis of Joystick 2
  joy2YVal = analogRead(joy2YPin);  // Read Y-axis of Joystick 2

  // Print joystick values to the serial monitor (for debugging)
  Serial.print("Joy1 X: ");
  Serial.print(joy1XVal);
  Serial.print(" Joy1 Y: ");
  Serial.print(joy1YVal);
  Serial.print(" Joy2 X: ");
  Serial.print(joy2XVal);
  Serial.print(" Joy2 Y: ");
  Serial.println(joy2YVal);

  // Send joystick values to slave (Arduino Uno) over I2C
  Wire.beginTransmission(8);  // Begin transmission to slave with address 8
  Wire.write((joy1XVal >> 8) & 0xFF);  // Send high byte of Joystick 1 X value
  Wire.write(joy1XVal & 0xFF);         // Send low byte of Joystick 1 X value
  Wire.write((joy1YVal >> 8) & 0xFF);  // Send high byte of Joystick 1 Y value
  Wire.write(joy1YVal & 0xFF);         // Send low byte of Joystick 1 Y value

  Wire.write((joy2XVal >> 8) & 0xFF);  // Send high byte of Joystick 2 X value
  Wire.write(joy2XVal & 0xFF);         // Send low byte of Joystick 2 X value
  Wire.write((joy2YVal >> 8) & 0xFF);  // Send high byte of Joystick 2 Y value
  Wire.write(joy2YVal & 0xFF);         // Send low byte of Joystick 2 Y value

  Wire.endTransmission();  // End transmission

  delay(50);  // Delay for joystick readings and smoother transmission
}

Slave (Arduino Uno R3)

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();  // Create PCA9685 object

int joy1XVal, joy1YVal, joy2XVal, joy2YVal;

// Define the deadzone size (e.g., ±100 units from center)
const int deadzone = 100;
const int centerValue = 512;

void setup() {
  Serial.begin(9600);
  
  Wire.begin(8);  // Join I2C bus as slave with address 8
  Wire.onRequest(requestEvent);  // Called when master requests data
  Wire.onReceive(receiveEvent);  // Called when data is received
  
  pwm.begin();  // Initialize the PCA9685 module
  pwm.setPWMFreq(60);  // Set PWM frequency to 60Hz for servos
}

void loop() {
  // Map joystick values to servo positions for Joystick 1 (X and Y axes)
  int servo1Pos = map(joy1XVal, 0, 1023, 500, 2500);  // Map joystick 1 X-axis to servo 1 (PWM range: 500 to 2500)
  int servo2Pos = map(joy1YVal, 0, 1023, 500, 2500);  // Map joystick 1 Y-axis to servo 2 (PWM range: 500 to 2500)

  // Map joystick values to servo positions for Joystick 2 (X and Y axes)
  int servo3Pos = map(joy2XVal, 0, 1023, 500, 2500);  // Map joystick 2 X-axis to servo 3
  int servo4Pos = map(joy2YVal, 0, 1023, 500, 2500);  // Map joystick 2 Y-axis to servo 4

  // Apply deadzone logic for joystick 1 X and Y values
  if (abs(joy1XVal - centerValue) < deadzone) {
    servo1Pos = 1500; // Set servo 1 to center position if within deadzone
  }
  if (abs(joy1YVal - centerValue) < deadzone) {
    servo2Pos = 1500; // Set servo 2 to center position if within deadzone
  }

  // Apply deadzone logic for joystick 2 X and Y values
  if (abs(joy2XVal - centerValue) < deadzone) {
    servo3Pos = 1500; // Set servo 3 to center position if within deadzone
  }
  if (abs(joy2YVal - centerValue) < deadzone) {
    servo4Pos = 1500; // Set servo 4 to center position if within deadzone
  }

  // Control servos on channels 0 to 3 using the Adafruit_PWMServoDriver
  pwm.writeMicroseconds(0, servo1Pos);  // Control servo 1 (Joystick 1 X-axis)
  pwm.writeMicroseconds(1, servo2Pos);  // Control servo 2 (Joystick 1 Y-axis)
  pwm.writeMicroseconds(2, servo3Pos);  // Control servo 3 (Joystick 2 X-axis)
  pwm.writeMicroseconds(3, servo4Pos);  // Control servo 4 (Joystick 2 Y-axis)

  delay(50);  // Delay for servo adjustment
}

// This function is called when the slave receives data from the master
void receiveEvent(int howMany) {
  joy1XVal = (Wire.read() << 8) | Wire.read(); // Receive X value for Joystick 1
  joy1YVal = (Wire.read() << 8) | Wire.read(); // Receive Y value for Joystick 1

  joy2XVal = (Wire.read() << 8) | Wire.read(); // Receive X value for Joystick 2
  joy2YVal = (Wire.read() << 8) | Wire.read(); // Receive Y value for Joystick 2
}

// This function is called when the master requests data from the slave
void requestEvent() {
  // You can send data back to the master here if needed
  // For now, we won't send anything
}

Part of your setup at any rate. Whatever is supplying power to the PCAs appears to be out of frame.

2 Likes

If you want accurate results fast post an annotated schematic. It appears you have several problems. Here are some hints that may help.
Gil's Crispy Critter Rules for Processor Hardware:

  1. Rule #1: An Arduino is NOT a Power Supply!
  2. Rule #2: Never connect anything inductive (motors, speakers) directly to an Arduino!
  3. Rule #3: Avoid connecting or disconnecting wires while the power is on.
  4. Rule #4: Do not apply power to any pin unless you are certain of what you're doing.
  5. Rule #5: Do not exceed the maximum voltage ratings.
  6. Rule #6: Many Arduinos cannot power transmitters directly.
  7. Rule #7: Before powering your project, take a break and double-check the wiring.

LaryD’s Corollaries:

  1. Coro #1: When starting out, add a 220Ω resistor in series with both input and output pins to protect against shorts.
  2. Coro #2: Invest in a Digital Multi-Meter (DMM) to measure voltages, currents, and resistance.

Note: Violating these rules can turn your Arduinos into crispy critters. For optimal performance, keep your wires under 25 cm (10 inches).

Additional Tips:

  • The L293 motor driver, though common, is inefficient as it can lose around 3V as heat when driving both legs of a motor. Consider using a motor driver with MOSFET outputs to reduce heat loss and conserve battery power.
  • For more on powering Arduino boards, explore this guide: Powering Alternatives for Arduino Boards.
3 Likes

How to Get the Right Help Faster:

You can spend weeks spinning your wheels, or you might get lucky and solve your problem quickly. To avoid unnecessary delays, it’s crucial to provide an annotated schematic of your circuit as you have it wired, showing all connections, including power, ground, and supplies.

Why Detailed Information Matters:

  • Annotated Schematics: These are essential because they show exactly how your circuit is set up. Without them, it's difficult for anyone to understand what you’ve done, which makes troubleshooting nearly impossible. Fritzing diagrams or unclear pictures are not enough.
  • Technical Information: Many modules look similar and may even have the same name, but they can function differently. This is why we always ask for links to detailed technical information—not just sales pages like those on Amazon, which often lack the specifics we need.
  • Show All Connections: It’s important to include every connection, especially power and ground, in your schematic. Missing these details makes it hard to determine if a setup issue might be causing your problem.

My Process:

When I see a question, I spend a moment assessing it. If it’s missing critical information, I might ask for it. However, if it's repeatedly lacking important details, I may assume the questioner is not serious and move on to another query.

What You Need to Consider:

We don’t know your skill level or what resources you have available. If you’re missing key technical details or seem unprepared, it may indicate that you need to spend more time learning the basics before starting your project.

Providing the right information upfront will help you get the best possible assistance and avoid the frustration of running into dead ends. Let us help you by sharing what you have clearly and completely!

2 Likes

Very likely the servo power supply is completely inadequate. 4.8 to 6V at 1 Ampere per servo for SG-90 servos, and 2.5 Amperes per servo for large ones like the MG996R.

About 95% of all servo problems reported on this forum are due to exactly that.

2 Likes

Thank you i will try this tomorrow!

It is a 12V 24A power supply with anderson plugs connected to volt regulators which are shown in the photos

Do you have quality common grounds?

1 Like

My money would be a current restriction somewhere. Like perhaps those Dupont cables I see going to the PCA's power terminal. As @jremington pointed out, those four big servos could take up to 10A when first moving. I'd not be the least surprised if those little wires became good resistors when overloaded.

And I also suspect that PCA board is either a very old Adafruit model or a clone. I say this because it appears to have the tiny SOT23 MOSFET that could only handle 4A on it. Adafruit switched to a larger device that could handle 20+A quite some time ago because the little ones tended to burn up when handling more than a few servos. The clone makers, alas, have not caught up.

1 Like

What "volt regulators"? Can they supply 2.5 Amperes per servo?

The photo is uninterpretable. For help on this forum, post a wiring diagram with all pins, connections and parts clearly identified.

2 Likes

My common ground is just connecting the mega GND to the uno GND

I can control the full voltage and full amperage output to the system, not to individual loads.

Yes it is an Adafruit motor driver clone.

I wouldn't be surprised if the only thing keeping that SOT23 MOSFET from burning up is the limited current that either your "volt regulators" (whatever they are) or your wiring can supply.

It might be a good idea to file this link away for future reference once you get your current issue sorted out. I imagine you're going to be needing to buy one of these.

1 Like

That could be an explanation, I think my regulators have built in overload control.

So do you think my issue is that my board inherently isn't able to supply my servos enough power?

I couldn't even begin to speculate. You've told us absolutely nothing about them. If you want informed answers, you're going to have to start providing details.

1 Like

This is information on my servos.

Here is information about my volt regulators.

【Parameter】 DROK Power Supply Module input volt range is DC 5.3-32V; Output volt range is DC 1.2-32V which is variable. Output current can reach to 8A and Output Power can reach to 120W for long-time use. If enhance heat dissipation, this converter can reach 12A and 160W output.
【Characteristics】 This Buck Converter is equipped with LCD Display, Acrylic Case and Heat Sink. LCD Screen can display input/output voltage, output current and output power. Voltage precision is 0.05V, current precision is 0.005A. Acrylic case can keep the converter board away from dust, which is protective. Heat Sink can keep module 120W for long-time using in a low temperature. If you want to reach maximum power 160W, please improve heat dissipation.
【Easy Operation】 A user manual will be included in package, which can help you easier to operate. The button can control ouput voltage ON/OFF status, and you can set the default output state is ON/OFF for the next time. The potentiometer can help you to adjust volt amp in a simple and fast way.
【Protection】 It has reverse-connect protection, short circuit protection and over current protection. When you connect the input wire reversely or short circuit, the module will not burn. And roate the CC potentiometer to set over current protection value you want.
【Application】 The volt conversion board can be used for 5v 6v 9v 12v 24V 30V 32V 3a 5a 10a devices, like solar panel, lab, experiment, RV, All-Terrain Vehicle, car, battery charger, LED stripes, etc.

What other information do you need?

The servo stall current is 2.3 A, which each servo briefly draws every time it starts moving.

So your voltage regulators, wiring and the servo power distribution board are inadequate for four servos.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.