Have I fried a chip on the Motorshield?

I'm trying to get a DC motor moving in forward and reverse using the Arduino Motor Shield.

I started off to reproduce the schematic for Karl Soederby's tutorial.https://docs.arduino.cc/tutorials/motor-shield-rev3/msr3-controlling-dc-motor.

At that point I was using a Project Board, and had failed to notice that it's recommended to spilt the VIN Connect link on the motor shield if you are powering the barrel jack connector (as I was). I noticed things were getting warm, so I powered everything down. I then split the VIN connector on the Motor Shield (which I used my meter to check), and rebuilt the test rig with a battery pack for the high power side of the motor and Laptop USB power for the Uno/Motor Shield Logic Side.

Rerunning the Software I initially got nothing but increasing the pwm value from 30 to 150 or 200 I get rotation in forward but not reverse.

I've now cut the code down to this fragment:

//
//  
//
// Test script for Arduino Motor Shield Rev 3 single motor attached to A channel
//
// Adapted from Karl Soederby by JIT
// https://docs.arduino.cc/tutorials/motor-shield-rev3/msr3-controlling-dc-motor
//
// Reverse
// Comments improved at aargh 's suggestion.
//

void setup() {
  Serial.begin(9600);
 
//define pins
  pinMode(3, OUTPUT); // Power A
  pinMode(12, OUTPUT); // Dir A
  pinMode(9, OUTPUT); //Brake A
  Serial.println("Simple Single Motor Test REverse Starting");

}

void loop() {
 
  digitalWrite(12, LOW); // Pin 12 in Channel A Direction LOW == Reverse
  digitalWrite(9, HIGH);  // Pin 9 Channel A - Brake off
  analogWrite(3, 250);   // Pin 3 Channel A Power: Run at 200
  Serial.println("Started");

  delay(2000);
 

//set work duty for the motor to 0 (off)
  analogWrite(3, 0);  // Pin 3 Channel A Power: reduce to 0
  Serial.println("Motor off");
  delay(2000);
}

which appears to do nothing to the motor (I get the relevant stuff on the Serial Monitor). Constant 0V on the motor terminals with 9.7V on the VIN screw terminals. (If I flip the first write to PIN 12 to HIGH, as expected I get the motor running forward for 2s then stopping; around 4.8V on the Channel A terminals when running).

Have I fried a chip on the Motor Shield, or is something else wrong?

Thanks for reading this far, and any help you can offer.

[Post edited to include better commenting in the code fragment at @anon57585045 's suggestion. To be clear the code fragment is complete sketch which has been tested @sloopjohnt 29/12/23]

Please post Your actual wiring here.

1 Like

Note the Lithium batteries are replaced with 8*NiMH 1.2V batteries, and as per original post I've checked they are charged and producing a good voltage for the application.

Also note this is not the short which caused the damage (if that's what's wrong).

Where is the wiring to the controller?

Do you mean the wiring between the Arduino Uno Rev 3 and the Ardenui Motor Shield Rev 3?

I guess its documented somewhere, but it's just standard pin to pin connections. All standard, unmodified Arduino products.

@Railroader You realize this is not a rail road application, don't you? I'm just trying to learn about controlling DC motors using Arduino and the IDE.

I understand that it's a shield so all the connections are fixed. But, showing the shield documentation here, is helpful in confirming the pin numbers and pin functions in the sketch you posted.

Have you tested the motor, connected in both directions to a raw battery, to make sure it is fully functional in both directions?

1 Like

OK.

Is this what you are looking for?

The Shield uses the following Pins:

Function Channel A Channel B
Direction Digital 12 Digital 13
Speed (PWM) Digital 3 Digital 11
Brake Digital 9 Digital 8
Current Sensing Analog 0 Analog 1

It also appears to have the two Ground PINs and 5V in the power block connected.
The other Digital Pins appear wired through - I have a bank of LEDs with resistor based voltage dividers and an HC-06 which I've used to check this, although I can't pretend its exhaustive.

Does that help?

Yes. Double checked. All fine!!

Are you saying there is more than just the shield connected? If so, please provide an overall wiring diagram.

You say you "cut the code down to a fragment". That sounds potentially error prone. Is there no example or test code that you can load, that is known to work?

No.

I've disconnected everything else and tried to produce a minimal useful script to help diagnose the problem.

So the pic in the post represents everything I'm working with right now.

There are no "scripts" in the Arduino environment.

It is hard to decipher your code because you didn't give identifiers to the pins, e.g.

//define pins
const int PowerApin = 3;
...
  pinMode(PowerApin, OUTPUT); // Power A

That makes it a puzzle to follow.

There's clearly more You need to learn. Good luck.

Apologies: sketches (for "scripts")

So I have not reliably seen a sketch which operated the motor in reverse. I thought it briefly went into reverse when I was running the script in Karl Soederby's Tutorial (see original post), just before I noticed things were heating up - probably because of a short caused by having an unbroken VIN Connect on the Motor Shield.

Personally I find it harder to understand the scripts with the Pins defined by constants or macros, simply because of the length, but I'll post a sketch written that way (but not this morning because I've got a demo of something else, I need my only currently available Arduino board for that). I don't want to mislead you by posting untested code.

I hoped the comments helped solve the problems posed by not using pins with symbolic names as I would do in production code. May be I'm wrong.

I'm used to the idea (based on 50 years! experience of programming) that the best way to report a bug or issue is to cut the code and hardware down to the minimum which illustrates the bug/issue. I accept there is a degree of unreliablity in that process, but hey, most of engineering is taking components with verified behavior and putting them together to produce complete systems.

Thanks for your help.

Thank you.

As noted in the original post the Uno board is powered by the USB cable from a laptop running the IDE.

Is that what you meant by "controller".

@anon57585045 Incidentally, this code fragment works in the sense that it drives the motor forward.

(Forgive scruffy comments again).

void loop() {
 
  digitalWrite(12, HIGH); // direction reverse HIGH (forwrd) works
  digitalWrite(9, LOW);  // Brake off
  analogWrite(3, 200);   // Run at 200
  Serial.println("Started");

  delay(2000);
 

//set work duty for the motor to 0 (off)
  analogWrite(3, 0);  
  Serial.println("Motor off");
  delay(2000);
}

I response to @anon57585045 's suggestion, I cleaned up the comments on this code fragment, which "works". It drives the motor forward then stops it with suitable delays.

I'll update the original post to include a non-working "Reverse" example once I've checked that (or report otherwise).

void loop() {
 
  digitalWrite(12, HIGH); // Pin 12 in Channel A Direction HIGH == Forward
  digitalWrite(9, LOW);  // Pin 9 Channel A - Brake off
  analogWrite(3, 200);   // Pin 3 Channel A Power: Run at 200
  Serial.println("Started");

  delay(2000);
 

//set work duty for the motor to 0 (off)
  analogWrite(3, 0);  // Pin 3 Channel A Power: reduce to 0
  Serial.println("Motor off");
  delay(2000);
}

If you go back in the thread you will see that I did not suggest any improvements to your comments. But it never hurts. You might have completely missed the point of reply #13, so I did it for you.

At this point it is quite likely that you made a wiring mistake, so you should post clear close up images of all your connections. You never posted a schematic of your system. Instead, you only posted a schematic of the shield board. You are posting snippets, not complete sketches. You are not providing the specific kinds of feedback that the forum guidelines prescribe. That makes people not want to help.

Here is the result of following my suggestion:

  //define pins
const int PowerA = 3;
const int DirA = 12;
const int BrakeA = 9;

void setup() {
  Serial.begin(9600);
  pinMode(PowerA, OUTPUT); // Power A
  pinMode(DirA, OUTPUT); // Dir A
  pinMode(BrakeA, OUTPUT); //Brake A
  Serial.println("Simple Single Motor Test REverse Starting");
}

void loop() {
  digitalWrite(DirA, HIGH); //Channel A Direction HIGH == Forward
  digitalWrite(BrakeA, LOW);  //Channel A - Brake off
  analogWrite(PowerA, 200);   //Channel A Power: Run at 200
  Serial.println("Started");

  delay(2000);

  //set work duty for the motor to 0 (off)
  analogWrite(PowerA, 0);  //Channel A Power: reduce to 0
  Serial.println("Motor off");
  delay(2000);
}

@aargh Thank you for your patience.

[@aarg Sorry for previous misreading of your comment re Reply 13 - erroneous comment by me removed]

I'll generate a good quality pic. as soon as I can.

Can you point me to a good quality example schematic which matches the community expectations please. Right now all I am aiming to do is to reproduce the circuit illustrated in the tutorial referenced in the original post.

I accept that that excludes:

  1. The USB connection to the Arduino UNO;
  2. The fact that the VIN Connect Link on the Arduino Motor Shield Rev 3 has been broken.

However, I'm not sure how I would Illustrate either of those. Would people expect me hand annotate the schematic provided with the shield?

Thanks again for your input and support.