MotorShield breaks Serial communication?

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
VanKurt
 
Posts: 21
Joined: Fri Jan 31, 2014 11:09 am

Re: MotorShield breaks Serial communication?

Post by VanKurt »

I was using a USB port (=> 500mA).

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: MotorShield breaks Serial communication?

Post by adafruit_support_bill »

500mA is plenty for the shield alone. But not so great for powering motors.

Running the shield is going to put a little more noise on the 5v rail. But not nearly as much as you would get with actual motors. There are many reasons why it is better to have a separate supply for the motors.

User avatar
mannphde
 
Posts: 2
Joined: Wed Dec 07, 2016 1:22 pm

Re: MotorShield breaks Serial communication?

Post by mannphde »

Hey I have a Problem with my adafruit motor shield V2
with an ulrasonic sensor srf03 my car drives automaticlly.
But now i want to drive my car with my smartphone (bluetooth zs-040).
But the bluetooth singnals (serialRead) are permanently overwritten from the motorshield.

I get the bluetooth signals from my smartphone into int status2 but the signals are fast overwritten by some other signals but there are only the bluetooth modul and the motorshield

In all baudrates are many freaky signals, when the motorshield starts to drive a motor the signal change in an other freaky ascci
Whats the problem here?
Thanks for help!


Code: Select all

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
int trigger = 12;
int echo = 9;
long dauer = 0;
long entfernung = 12;

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Adafruit_DCMotor *myMotor1 = AFMS.getMotor(1);

Adafruit_DCMotor *myMotor2 = AFMS.getMotor(2);

void setup() 
{
  Serial.begin(9600);           
  //Serial.begin(38400);

  AFMS.begin();  // create with the default frequency 1.6KHz
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  myMotor1->setSpeed(50);
  myMotor1->run(FORWARD);
  myMotor1->run(RELEASE);

 myMotor2->setSpeed(50);
  myMotor2->run(FORWARD);
  myMotor2->run(RELEASE);

 pinMode (trigger, OUTPUT);
  pinMode (echo, INPUT);
}

void loop() {

int Status2=0; 
if(Serial.available()>0)
{
  Status2 = Serial.read();
}
Serial.println(entfernung);             //mesure the distance
digitalWrite(trigger, LOW);           //v
 delay(5);
 digitalWrite(trigger, HIGH);
 delay(10);
 digitalWrite(trigger, LOW);
 dauer= pulseIn(echo,HIGH);        //^
 entfernung= (dauer/2)/29,1;       // mesure the distance


if (Status2 =='0')
{                                       //automatic   V
 
  if (entfernung <= 30)
  {
  Stopp();
  delay(250);
  Links();
  delay(1000); 
  Stopp();
  delay(250);   
  }

  else 
 {
  Vorwarts();
  }
                                               //automatic ^
}
else
{
  Stopp();                                  // drive with Smartphone V

 while(Status2=='2')
 {
   Vorwarts ();
   Status2 = Serial.read();
 }
 while(Status2=='3')
 {
    Ruckwarts ();
   Status2 = Serial.read();
 }
 while(Status2=='4')
 {
   Rechts ();
   Status2 = Serial.read();
 }
 while(Status2=='5')
 {
   Links ();
   Status2 = Serial.read();
  }
 }                                               //drive with smartphone ^
}


void Stopp ()
{
   myMotor1->setSpeed(0);
   myMotor2->setSpeed(0);
   myMotor1->run(RELEASE);
   myMotor2->run(RELEASE);
   
}
void Links ()
{
   myMotor1->setSpeed(50);
   myMotor2->setSpeed(50);
   myMotor1->run(FORWARD);
   myMotor2->run(BACKWARD);
   
}

void Rechts ()
{
   myMotor1->setSpeed(50);
   myMotor2->setSpeed(50);
   myMotor1->run(BACKWARD);
   myMotor2->run(FORWARD);
   
}
void Vorwarts ()
{
   myMotor1->setSpeed(150);
   myMotor2->setSpeed(150);
   myMotor1->run(FORWARD);
   myMotor2->run(FORWARD);
}   

void Ruckwarts ()
{
   myMotor1->setSpeed(110);
   myMotor2->setSpeed(110);
   myMotor1->run(BACKWARD);
   myMotor2->run(BACKWARD);
}   
Last edited by mannphde on Wed Dec 07, 2016 2:55 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: MotorShield breaks Serial communication?

Post by adafruit_support_bill »

DC motors generate a lot of brush noise. This can cause all sorts of interference. Many times this noise can be suppressed at the source by adding some capacitors to the motor terminals. See the motor shield FAQ for details. https://learn.adafruit.com/adafruit-mot ... all#faq-17

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”