Serial Monitor Stops when Using Motor Drive Module

Greetings,

First time poster here. I am troubleshooting an issue with my RC submarine ballast control system. I have an Arduino Nano (classic, official) connected to an RC receiver and a DC motor drive module (Drok L298 Dual H Bridge). The motor driver is powered directly by a 12 volt battery.

The problem is that whenever I command surface (D3 --> LOW, D4 --> HIGH), the serial monitor stops outputting. The device keeps working properly with motor responding to RC inputs, but I can no longer see things print to the serial monitor. Commanding dive with the motor running the other direction works with no issue.

Troubleshooting I have tried already:

  • Increase serial communication rate (error persists)
  • Use the other motor port (error persists)
  • Increase delay between loops (error persists)
  • Use a USB cable with the red wire cut (error persists)
  • Disconnect motor from motor driver (serial monitor fixed)
  • Disconnect data pins from motor driver (serial monitor fixed)

My hypothesis is that the motor is causing interference the serial interface. Please reply if you have a question or suggestion. Thanks!

int RCValue;
#define RCPin 2
int motor1pin1 = 3; // White wire, Goes to IN1
int motor1pin2 = 4; // Yellow wire, Goes to IN2
int motor2pin1 = 5; // Green wire, Goes to IN3
int motor2pin2 = 6; // Blue wire, Goes to IN4

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
  // Pump Motor & LED
  pinMode(motor1pin1, OUTPUT); // Controls IN1
  pinMode(motor1pin2, OUTPUT); // Controls IN2
  pinMode(motor2pin1, OUTPUT); // Controls IN3
  pinMode(motor2pin2, OUTPUT); // Controls IN4
  

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(100);
  // RC Input
  RCValue = pulseIn(RCPin, HIGH); // Read RC Value
  Serial.println(RCValue);
if (RCValue > 1700){
    Serial.println("Diving");
    digitalWrite(motor1pin1, HIGH);
    digitalWrite(motor1pin2, LOW);

  } else if (RCValue > 1300){
    Serial.println("Neutral");
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, LOW);

  } else {
    Serial.println("Surfacing");
    digitalWrite(motor1pin1, LOW);
    digitalWrite(motor1pin2, HIGH);

  }

}

Good point.
How do you power the setup.
Is motor power shared with Arduino power.
Which "motor drive module".
Post an annotated block diagram.
Leo..

Thanks for the reply. Link to Motor Driver
I would attach my wiring diagram but I am not allowed to as a new user.

Google Drive Link to Wiring Diagram

It makes more sense to power the Nano with 5volt, on the 5volt pin, from the buck converter instead of with 12volt on Vin.
Please insert your image (.jpg or .png) directly into your post (drag-n-drop).
Leo..

I used to have it on 5 volt from the buck but it wouldn't communicate at all with serial. Arduino recommends minimum 6 volts

That's for the Vin pin.

If you have a reliable 5volt, then connect it to the 5volt pin of the Nano (as said).
Leo..

Thank you for the correction. I connected the 5v from the buck to 5v on the Nano and the issue persists

UPDATE: I switch to my normal USB cable with 5v line intact. With Arduino powered through 5V, the problem has gone away and I can now view serial monitor while the motor is active.

My theory is that serial monitor works more reliably if the USB voltage and Arduino supplied voltage are the same.

Thank you @Wawa for your time!

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