Controlling a bipolar stepper motor with motorshield v2 and Arduino Mega 2560

Thread Starter

AdhesiveLamb

Joined Feb 16, 2019
19
Hello, I have been attempting to control this stepper motor all morning. I started by determining which pins from the motor are on the same poles using a continuity test. I connected similar port pins to M3 and M4 ports on the motorshield. I connected the SCL on the Arduino to the SCL pin on the motorshield via jumper cables. Likewise for the SDA pin. 5V and ground are connected through the headers. Some of the other header pins are not connected, because they are not used as far as I am aware. I am supplying 12V to the motor through the power input on the motorshield. The program I am attempting to run is the Stepper Test example released by adafruit. The only thing I changed is the steps per revolution to match the motor I am using.

Some troubleshooting I have done: confirmed Arduino code is being uploaded successfully by testing an LED on a digital pin, confirmed 12V across the power pins, confirmed 5V across the power from Arduino, spun the motor shaft and watched the power LED light up on the motorshield.

Does anyone see anything wrong with my setup or have some other troubleshooting ideas?

20200714_134539.jpg.
20200714_134547.jpg

Code:
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
*/


#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(24, 2);


void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(10); // 10 rpm
}

void loop() {
Serial.println("Single coil steps");
myMotor->step(100, FORWARD, SINGLE);
myMotor->step(100, BACKWARD, SINGLE);

Serial.println("Double coil steps");
myMotor->step(100, FORWARD, DOUBLE);
myMotor->step(100, BACKWARD, DOUBLE);

Serial.println("Interleave coil steps");
myMotor->step(100, FORWARD, INTERLEAVE);
myMotor->step(100, BACKWARD, INTERLEAVE);

Serial.println("Microstep steps");
myMotor->step(50, FORWARD, MICROSTEP);
myMotor->step(50, BACKWARD, MICROSTEP);
}
 

Thread Starter

AdhesiveLamb

Joined Feb 16, 2019
19
I should also add: the power LED on the Arduino lights up, the power on the LED on the motorshield also lights up. The issue is the stepper motor does not spin.
 

KeithWalker

Joined Jul 10, 2017
1,043
A continuity test will not tell you which windings are which. The motor has two center tapped phase windings with both center taps connected to common. You need to find out which windings belong together in the same phase and which winding is the + winding and which is the -.
The two phase A windings + and - should be connected to M3 + and - and the two phase B windings to M4. The common wire goes to ground. If you reverse the connections on either phase winding or interchange a phase A winding with a phase B winding the motor will probably just vibrate and not rotate.
Regards,
Keith
 

Thread Starter

AdhesiveLamb

Joined Feb 16, 2019
19
A continuity test will not tell you which windings are which. The motor has two center tapped phase windings with both center taps connected to common. You need to find out which windings belong together in the same phase and which winding is the + winding and which is the -.
The two phase A windings + and - should be connected to M3 + and - and the two phase B windings to M4. The common wire goes to ground. If you reverse the connections on either phase winding or interchange a phase A winding with a phase B winding the motor will probably just vibrate and not rotate.
Regards,
Keith
I have tried every combination of wires on different phases. The motor doesn't budge. The motor only has 4 wires so I'm not sure what I would connect to ground.
 

KeithWalker

Joined Jul 10, 2017
1,043
Which version of the Adafruit Motorshield library are you using? To use the motorshield-V2 on an Arduino, you'll need to install the Adafruit Motorshield v2 library. The motorshield-V2 is not compatible with the older AF-Motor library used for v1 shields.
Keith
 

Thread Starter

AdhesiveLamb

Joined Feb 16, 2019
19
Which version of the Adafruit Motorshield library are you using? To use the motorshield-V2 on an Arduino, you'll need to install the Adafruit Motorshield v2 library. The motorshield-V2 is not compatible with the older AF-Motor library used for v1 shields.
Keith
I just checked and I am using the motorshield v2 library.
 
Only 4 wires 4 wire means it is a bipolar stepper motor. Sort wires into pairs, you should get same ohm reading (say 100ohms) on any pair. Connect each pair to the M1 and M2 drier outputs (Or M3 and M4). If the motor stands still, try reversing the order of ONE of the pair of wires (e.g. Red,White, Yellow, Black would be White, Red, Yellow,Black. If the ere is an "enable" pin on the driver board, you might to need to connect it to high or low to engage/disengage the driver. You might be better with the Generic stepper library examples on the Arduino site for testing
 

KeithWalker

Joined Jul 10, 2017
1,043
Is the Motor Shield working? A quick way to tell is to connect a multimeter across one of the windings, set to AC volts. Although the signal is a square wave, you should get an AC voltage reading when the program is running. Check across each winding in turn. If you don't measure a reasonable voltage, the shield is not working correctly or the program is not running.
NOTE: The V2 can be set to any of five different interface addresses. Are you sure the software is using the correct address?
Regards,
Keith
 
Top