Ardumoto shield using as stepper driver

Hi guys,

I see mixed answers when it comes to using this shield https://www.sparkfun.com/products/9815 as a stepper driver
I googled inside and outside the forum but did not came to a satisfying answer to use the shield.
According to this link it should work.
RE: New Comer, Ardumoto + Stepper Tutorials - SparkFun Electronics
But an other forum member there says the step sequence is not correct but only says he changed two lines in the library but not exactly explains what he did where in the cpp or h file.

His words

I get it working! but in a half: the sequence produced by stepper library isn’t correct.
Now is doin 3-4-2-1
What I need to correctly move the motor is 3-1-4-2 (so B-A-B’-A’).

This is my current code but the motor only humms and not rotate.

Any help to sort this out would be appriciated.

Thanks Paco

#include <HX711.h>
#include <Stepper.h>

// HX711.DOUT	- pin #A1
// HX711.PD_SCK	- pin #A0

HX711 scale(A1, A0);		// parameter "gain" is ommited; the default value 128 is used by the library

const int stepsPerRevolution = 200;  // Stepper has 200 revolutions for CNC motor
Stepper myStepper(stepsPerRevolution, 3,11,12,13); // See reference for ARDUMOTO - it uses pins 3,11,12,13

boolean LeftTurn = 0;
boolean RightTurn = 0;
int incomingByte = 0;   // for incoming serial data
int StepCounter = 5000;
int Analog2 = 16; // Use analog port on shield for button push to control movement and direction
int Analog3 = 17; // Use analog port on shield for button push to control movement and direction
int ledPin = 8; //used for debug purpose only

void setup() 
{
  Serial.begin(9600);
  
  pinMode(ledPin, OUTPUT);  //used for debug purpose only
  pinMode(Analog2,INPUT);   // set the A2 pin to input
  pinMode(Analog3,INPUT);   // set the A3 pin to input
  
  myStepper.setSpeed(70);  // set the speed at 70 rpm:
  // 70 is a nice fluid move  60-70 rpm, and a nice slow rotation could be 20
}

void loop() 
{
  LeftTurn = digitalRead(Analog2);
  RightTurn = digitalRead(Analog3);
    
  Serial.print ("A,"); 
  Serial.println (StepCounter); // keeps score of the steps done to calulate the movement in mm + or -
  Serial.print ("B,");
  Serial.println(scale.read()/100); //raw loadcell data devided by 100

  
  if (Serial.available() > 0) 
  {
  incomingByte = Serial.read();
    {
    if (incomingByte = 0)
    {
      LeftTurn = 1;
    } 
    if (incomingByte = 1)
    {
      RightTurn = 1;
    } 
  }
  }

     
if (LeftTurn == 1)
{
  myStepper.step(stepsPerRevolution); // Do a full left turn of 200 steps
  delay(50);
  StepCounter = StepCounter + 1;
  digitalWrite(ledPin, HIGH); //used for debug purpose only
}
  else if (RightTurn == 1)
{
  myStepper.step(stepsPerRevolution * -1); // Do a full right turn of 200 steps
  delay(50);
  StepCounter = StepCounter - 1;
  digitalWrite(ledPin, HIGH); //used for debug purpose only
}
  else
{
digitalWrite(ledPin, LOW); //used for debug purpose only
}  

//  According to sparkfun forum to correctly move the motor correctly is 3-1-4-2 (so B-A-B'-A') for one direction so change standard libary step sequence.

}

The stepper is a 4 wire with two coils of 3,8 ohm with 200 steps where one coil is conencted to 1/2 and the other connected to 3/4
.

Can you not rewire the windings to the board?

Note that you should never disconnect the wires to a stepper that is powered-up, this
usually trashes the motor controller completely. Remove power first, then reconnect,
then test.

Hi Mark,

Rewiring the shield is not possible as the lines to the L298 chip are to small and it will be come a mess or will destroy the board for next projects.
If people say they got it to work I really need to try it too, just for the feeling it CAN work. :slight_smile:
Ohters will have bought the board too and also stopped trying it to use as a stepper board.

I am new to stepper motors and eager to learn even the long way.

I know about the problem to powerless change the wires otherwise the chip will fail.

I looked again into the .cpp and .h file but cant find the way to change the sequence to the stepping as was proposed as the solution.

I also started to build a simple code without the # stepper,h to see if I can get the board to work.
I have now I think the code that can produce one step either left or right but now it comes down to stepping through to the next step.

boolean LeftTurn = 0;
boolean RightTurn = 0;
int Analog2 = 16; // Use analog port on shield for push button to control movement and direction
int Analog3 = 17; // Use analog port on shield for push button to control movement and direction

int pwm_3  = 3;    //PWM control for coil outputs 1 and 2 is on digital pin 3
int pwm_11 = 11;  //PWM control for coil outputs 3 and 4 is on digital pin 11
int dir_12 = 12;  //direction control for coil current outputs 1 and 2 is on digital pin 12
int dir_13 = 13;  //direction control for coil current outputs 3 and 4 is on digital pin 13

void setup() 
{
  Serial.begin(9600);
  
  pinMode(Analog2,INPUT);   // set the A2 pin to input
  pinMode(Analog3,INPUT);   // set the A3 pin to input
  pinMode(pwm_3,  OUTPUT);
  pinMode(pwm_11, OUTPUT);
  pinMode(dir_12, OUTPUT);
  pinMode(dir_13, OUTPUT);
}

void loop() 
{
  LeftTurn = digitalRead(Analog2);
  RightTurn = digitalRead(Analog3);
  
if (LeftTurn == 1) // coil A
{
  StepCounter = StepCounter + 1;
  analogWrite(pwm_3, 255); // > activate coil
  digitalWrite(dir_12, HIGH);  // > left flow coil
}
  else if (RightTurn == 1) //coil B
{
  StepCounter = StepCounter - 1;
  analogWrite(pwm_11, 255); // > activate coil
  digitalWrite(dir_13, HIGH);  // > left flow coil
}
  else
{
analogWrite(pwm_3, 0); // > activate coil
digitalWrite(dir_12,LOW);  // > left flow coi 
analogWrite(pwm_11, 0); // > activate coil
digitalWrite(dir_13, LOW);  // > left flow coil
}  
}