Boltduino: Power Adapter & USB Cable conflict

Hi :wave:t5:

I have an issue with the Power Adapter of the Robotics and Arduino Kit.
All seems to be well and the robot performs the specific tasks if I plug in the USB cable along with my computer. But as soon as I disconnect the USB Cable and plug the 12V DC Power Adapter, the robot moves backward or forward only. However, I tried connecting the USB and the Power Adapter altogether and it works but I had to drag my laptop around which I think is a little risky.

Please do you have any idea why this is happening?
If yes, what would you suggest I do?

Hi @francoisgonothitoure, I think i get your problem. I was also facing the same problem. The problem was in my code, for the robot to work properly with DC adapter only we need to
Add stop and delay of 500 millisecond after each function call in between our code.
You also didn’t include the delay and stop functions in the code, if I’m not mistaken.

The DC motor used in our project has a 12 volt operating voltage. The robot requires extra power to operate because it has two motors and a motor driver IC, so when the adapter and USB are connected at the same time, the robot receives the correct power and functions as intended.
When the adapter is the only thing connected, the first function can be called without any issues, but when it tries to call the second function, it can’t acquire enough power for a sudden transition. A built-in reset is provided on the Boltduino board, allowing it to automatically reset and resume operations when the working environment is insufficient.

Here it is the code for “First Robot” with stop and delay functions included.

void stationary() {
  digitalWrite(4,LOW);
  digitalWrite(7,LOW);
  digitalWrite(12,LOW);
  digitalWrite(8,LOW);
}

void forward() {
  digitalWrite(4,HIGH);
  digitalWrite(7,LOW);
  digitalWrite(12,HIGH);
  digitalWrite(8,LOW);
}

void reverse() {
  digitalWrite(4,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(12,LOW);
  digitalWrite(8,HIGH);;
}

void left() {
  digitalWrite(4,HIGH);
  digitalWrite(7,LOW);
  digitalWrite(12,LOW);
  digitalWrite(8,HIGH);
}

void right() {
  digitalWrite(4,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(12,HIGH);
  digitalWrite(8,LOW);
}

void left_forward() {
  digitalWrite(4,LOW);
  digitalWrite(7,LOW);
  digitalWrite(12,HIGH);
  digitalWrite(8,LOW);
}

void right_forward() {
  digitalWrite(4,HIGH);
  digitalWrite(7,LOW);
  digitalWrite(12,LOW);
  digitalWrite(8,LOW);
}

void left_reverse() {
  digitalWrite(4,LOW);
  digitalWrite(7,HIGH);
  digitalWrite(12,LOW);
  digitalWrite(8,LOW);
}

void right_reverse() {
  digitalWrite(4,LOW);
  digitalWrite(7,LOW);
  digitalWrite(12,LOW);
  digitalWrite(8,HIGH);
}
void setup() {
  // put your setup code here, to run once:
  pinMode(5,OUTPUT);    //Enable pin for left motor will receive 5V and motor sheild will convert it into 12V supply
  pinMode(4,OUTPUT);    //Pin declaration for control pin 1 of left motor
  pinMode(7,OUTPUT);    //Pin declaration for control pin 2 of left motor
  pinMode(6,OUTPUT);    //Enable pin for right motor will receive 5V and motor sheild will convert it into 12V supply
  pinMode(12,OUTPUT);   //Pin declaration for control pin 1 of right motor
  pinMode(8,OUTPUT);    //Pin declaration for control pin 2 of right motor
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  stationary();
  delay(5000);
  
  forward();
  delay(5000);
  stationary();
  delay(500);
  
  reverse();
  delay(5000);
  stationary();
  delay(500);
  
  left();
  delay(5000);
  stationary();
  delay(500);
  
  right();
  delay(5000);
  stationary();
  delay(500);
  
  left_forward();
  delay(5000);
  stationary();
  delay(500);
  
  right_forward();
  delay(5000);
  stationary();
  delay(500);
  
  left_reverse();
  delay(5000);
  stationary();
  delay(500);
  
  right_reverse();
  delay(5000);
  stationary();
  delay(500);
}

Hope this was helpful. If you still can’t fix the problem, please tag me and if you can, please respond as well :upside_down_face:

Hi @francoisgonothitoure,
I would request you to make a video of your robot so I can better understand what exactly is happening. Upload that video on Google Drive and post a link to the same here.

Hi @mr.sushen

Thank you for the thorough explanation.
And yes, you totally understood the question.

However, I tried implementing the first solution without success, the robot still performs the first motion only. So in my case adding stop and delay of 500 ms after each function didn’t fix the issue.
But instead of my computer, I used a 5V 2A Power Bank along with the Power Adapter and it works fine. So in my opinion, I think it’s an issue with the 12V Power Adapter (which I am sure doesn’t meet the Power requirement for the whole circuit).

Also, why would the USB cable make the robot perform all motions (but slower) while it only gives 5V?
In addition, why would the DC Power Adapter that gives 12V not be able to make the robot performs all actions? Finally, why is it that when the USB Cable and the Power Adapter used altogether make the robot perform all motions (but faster this time)?

Here is the code I used :point_down:t5:

// Variables: M1 or Right Motor
int enable_right_motor = 5;
int right_motor_control_1 = 4;
int right_motor_control_2 = 7;

// Variables: M2 or Left Motor
int enable_left_motor = 6;
int left_motor_control_1 = 12;
int left_motor_control_2 = 8;

// Function: stable motion
void stable() {
  digitalWrite(enable_right_motor, LOW);
  digitalWrite(enable_left_motor, LOW);
}

// Function: forward motion
void forward() {
  // M1
  digitalWrite(right_motor_control_1, HIGH);
  digitalWrite(right_motor_control_2, LOW);
  // M2
  digitalWrite(left_motor_control_1, HIGH);
  digitalWrite(left_motor_control_2, LOW);
}

// Function: reverse motion
void reverse() {
  // M1
  digitalWrite(right_motor_control_1, LOW);
  digitalWrite(right_motor_control_2, HIGH);
  // M2
  digitalWrite(left_motor_control_1, LOW);
  digitalWrite(left_motor_control_2, HIGH);
}

// Function: right motion
void right() {
  // M1
  digitalWrite(right_motor_control_1, LOW);
  digitalWrite(right_motor_control_2, HIGH);
  // M2
  digitalWrite(left_motor_control_1, HIGH);
  digitalWrite(left_motor_control_2, LOW);
}

// Function: left motion
void left() {
  // M1
  digitalWrite(right_motor_control_1, HIGH);
  digitalWrite(right_motor_control_2, LOW);
  // M2
  digitalWrite(left_motor_control_1, LOW);
  digitalWrite(left_motor_control_2, HIGH);
}

// Function: left forward
void left_forward() {
  // M1
  digitalWrite(right_motor_control_1, HIGH);
  digitalWrite(right_motor_control_2, LOW);
  // M2
  digitalWrite(left_motor_control_1, LOW);
  digitalWrite(left_motor_control_2, LOW);
}

// Function: right forward
void right_forward() {
  // M1
  digitalWrite(right_motor_control_1, LOW);
  digitalWrite(right_motor_control_2, LOW);
  // M2
  digitalWrite(left_motor_control_1, HIGH);
  digitalWrite(left_motor_control_2, LOW);
}

// Function: left reverse
void left_reverse() {
  // M1
  digitalWrite(right_motor_control_1, LOW);
  digitalWrite(right_motor_control_2, LOW);
  // M2
  digitalWrite(left_motor_control_1, LOW);
  digitalWrite(left_motor_control_2, HIGH);
}

// Function: right reverse
void right_reverse() {
  // M1
  digitalWrite(right_motor_control_1, LOW);
  digitalWrite(right_motor_control_2, HIGH);
  // M2
  digitalWrite(left_motor_control_1, LOW);
  digitalWrite(left_motor_control_2, LOW);
}

// Function: setup 
void setup() {
  pinMode(enable_right_motor, OUTPUT);
  digitalWrite(enable_right_motor, HIGH);

  pinMode(enable_left_motor, OUTPUT);
  digitalWrite(enable_left_motor, HIGH);

  pinMode(right_motor_control_1, OUTPUT);
  pinMode(right_motor_control_2, OUTPUT);

  pinMode(left_motor_control_1, OUTPUT);
  pinMode(left_motor_control_2, OUTPUT);
}

// Function: loop
void loop() {
  stable();
  delay(5000);
  forward();
  delay(5000);
  reverse();
  delay(5000);
  right();
  delay(5000);
  left();
  delay(5000);
  left_forward();
  delay(5000);
  right_forward();
  delay(5000);
  left_reverse();
  delay(5000);
  right_reverse();
  delay(5000);
}

Please let me know if you have any other solution that would help.

Regards,
Francois

Hi @raghav.srivastava

Can you please refer to answer here :point_right:t5: Boltduino: Power Adapter & USB Cable conflict - #2 by mr.sushen?

There is a thorough explanation given by both me and @mr.sushen

Please let me know if this could attempting to fix the problem.

Regards,
Francois Gonothi Toure

@francoisgonothitoure I’ll go through your and @mr.sushen’s answer and will get back to you shortly.

Hi @raghav.srivastava
We will be waiting for you.
Thanks in advance !!!

@francoisgonothitoure apologies for the delay, I missed this one.
I have read through your and @mr.sushen’s message.

I would like to confirm if you are using the power adapter provided in the kit? Also, it might be the case that the ground of the Bolt/Boltduino is not connected to some component. Make sure you connect the ground of the Bolt/Boltduino to the ground of the Motor driver.

Also, if it doesn’t work then you may share the circuit connections here.

I can have a remote session with you if the problem persists, let me know if you need that.

Hello @raghav.srivastava

I just double checked the connection and, to my knowledge, the circuit connection is okay.

Maybe a remote session would help me fix the issue. We can have the meeting anytime today at your convenience. Please let me know of the timing beforehand.

Regards,
Francois Gonothi Toure

@francoisgonothitoure as per your convenience let me know the timing. Also, send me an email regarding the same along with the appropriate date and time at raghav.srivastava@boltiot.com so I can invite you on google meet. Apologies for missing out on your message today(Sunday).

@raghav.srivastava

I just sent you an email and I am sure you might be able to see it in your inbox by now

@francoisgonothitoure yes I have received your mail and will reply shortly. Keep an eye on your mailbox.