EasyDriver too Seeed

Hi to all. This is my first post, and like most I'm only doing this cause I'm not very smart Have managed to copy and post a sketch that will suit my needs to stepper drive a small milling mechine. With Arduino uno and an EasyDriver, this works ok. But would like to use the seeed motor shield V2 as this seems to run the stepper much "smother". The working code was from the easydriver page and the other from a seeed demo. The code are nothing like each other Thanks

here is how it works

you post links to what you have not all motors work with all drivers not all motor can power your machine. not all power supplies work to power your stepper for your application.

you go here : http://forum.arduino.cc/index.php/topic,148850.0.html

pay close attention to 4, 6 and 7. 7 is very important.

post the code that does work. that you are not happy with.

post the code that does not work.

what we will do is to post links to things you already know about, like how to drive a stepper and such.

I would be very surprised if a motor shield would be better than an Easydriver.

Have you tried using microstepping with the Easydriver ?

Post a link to the datasheet for motor shield.

Post the code you are using with your Easydriver.

Give details of the power supply you are using for the motor (volts and amps).

...R Stepper Motor Basics

const int buttonPin = 12; // Jog button clockwise
const int buttonPin1 = 11;// Jog button Counter Clockwise
int buttonState = 0;
#include <AccelStepper.h>

// Define the stepper and the pins it will use
AccelStepper stepper1(1, 9, 8); // 9 = step, 8 = direction
//AccelStepper stepper2(1, 9, 8); // 9 = step, 8 = direction
// Define our three input button pins
#define LEFT_PIN 4
#define STOP_PIN 3
#define RIGHT_PIN 2

// Define our analog pot input pin
#define SPEED_PIN 0

#define MAX_SPEED 5000
#define MIN_SPEED .01

void setup() {
  // The only AccelStepper value we have to set here is the max speed
  stepper1.setMaxSpeed(10000.0);

  //Set up the three button inputs, with pullups
  pinMode(LEFT_PIN, INPUT_PULLUP);
  pinMode(STOP_PIN, INPUT_PULLUP);
  pinMode(RIGHT_PIN, INPUT_PULLUP);
  pinMode(buttonPin, INPUT);
  pinMode(buttonPin1, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  static float current_speed = 0.0;          //Holds current motor speed in steps seconds
  static int analog_read_counter = 1000;// Counts down to 1000 to fire anlog read/
  static char sign = 0;                       //Holds 1 or - 1
  static int analog_value = 0;                // Holds raw analog


  // If a switch is pushed down (low)......
  if (digitalRead(LEFT_PIN) == 0) {
    sign = 1;
  }
  else if (digitalRead(RIGHT_PIN) == 0) {
    sign = -1;
  }
  else if (digitalRead(STOP_PIN) == 0) {
    sign = 0;
  }

  //We only want to read the pot
  // want to do it every time through the main loop).
  if (analog_read_counter > 0) {
    analog_read_counter --;
  }
  else {
    analog_read_counter = 6000;
    // Now read the pot (from 0 to 1023)
    analog_value = analogRead(SPEED_PIN);
    // Give the stepper a chance
    stepper1.runSpeed();
    // And scale the pot from min to max speed
    current_speed = sign * ((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED;
    // Update the stepper to run at this new speed
    stepper1.setSpeed(current_speed);
  }
  stepper1.runSpeed();


  //Jog button clockwise
  if (digitalRead(buttonPin) == HIGH) {
    current_speed = ((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED;
    stepper1.setSpeed(-current_speed);
    stepper1.runSpeed();
  }

  //   Jog button Counter clockwise
  if (digitalRead(buttonPin1) == HIGH) {
    current_speed = ((analog_value / 1023.0) * (MAX_SPEED - MIN_SPEED)) + MIN_SPEED;
    stepper1.setSpeed(current_speed);
    stepper1.runSpeed();
  }

}
//  Demo function:The application method to drive the stepper motor.
//  Hareware:Stepper motor - 24BYJ48,Seeed's Motor Shield v2.0
//  Author:Frankie.Chu
//  Date:20 November, 2012
#define MOTOR_CLOCKWISE      0
#define MOTOR_ANTICLOCKWISE  1
/******Pins definitions*************/
#define MOTORSHIELD_IN1	8
#define MOTORSHIELD_IN2	11
#define MOTORSHIELD_IN3	12
#define MOTORSHIELD_IN4	13
#define CTRLPIN_A		9
#define CTRLPIN_B		10

const unsigned char stepper_ctrl[]={0x27,0x36,0x1e,0x0f};
struct MotorStruct
{
	int8_t speed;
	uint8_t direction;
};
MotorStruct stepperMotor;
unsigned int number_of_steps = 200;
/**********************************************************************/
/*Function: Get the stepper motor rotate                               */
/*Parameter:-int steps,the total steps and the direction the motor rotates.*/
/*			if steps > 0,rotates anticlockwise,			   			   */
/*			if steps < 0,rotates clockwise.           				   */
/*Return:	void                      							      */
void step(int steps)
{
	int steps_left = abs(steps)*4;
	int step_number;
	int millis_delay = 60L * 1000L /number_of_steps/(stepperMotor.speed + 50);
	if (steps > 0) 
	{
		stepperMotor.direction= MOTOR_ANTICLOCKWISE;
		step_number = 0; 
	}
    else if (steps < 0) 
	{
		stepperMotor.direction= MOTOR_CLOCKWISE;
		step_number = number_of_steps;
	}
	else return;
	while(steps_left > 0) 
	{
		PORTB = stepper_ctrl[step_number%4];
		delay(millis_delay);
		if(stepperMotor.direction== MOTOR_ANTICLOCKWISE)
		{
			step_number++;
		    if (step_number == number_of_steps)
		    	step_number = 0;
		}
		else 
		{
			step_number--;
		    if (step_number == 0)
		    	step_number = number_of_steps;
		}
		steps_left --;
		
	}
}
void initialize()
{
	pinMode(MOTORSHIELD_IN1,OUTPUT);
	pinMode(MOTORSHIELD_IN2,OUTPUT);
	pinMode(MOTORSHIELD_IN3,OUTPUT);
	pinMode(MOTORSHIELD_IN4,OUTPUT);
	pinMode(CTRLPIN_A,OUTPUT);
	pinMode(CTRLPIN_B,OUTPUT);
	stop();
	stepperMotor.speed = 25;
	stepperMotor.direction = MOTOR_CLOCKWISE;
}
/*******************************************/
void stop()
{
	/*Unenble the pin, to stop the motor. */
	digitalWrite(CTRLPIN_A,LOW);
    digitalWrite(CTRLPIN_B,LOW);
}

void setup()
{
	initialize();//Initialization for the stepper motor.
}

void loop()
{
	step(200);//Stepper motors rotate anticlockwise 200 steps.
	delay(1000);
	step(-200);//Stepper motors rotate clockwise 200 steps.
	delay(1000);
}

You have posted two pieces of code in Replies #3 and #4 without any explanation.

You have not responded to the points made in earlier Replies to you.

What are we expected to do now ?

...R

What are we expected to do now ?

Check to see if this thread gets moved to Bar Sport?

Thank you for the reply As you can see I have the great number of 3 posts and yours are counted in the 1000 Easy when you know how I will figure it out, just thought this was the place to come for help Sorry to have wasted your time.

Sorry to have wasted your time.

My comment was directed at Robin2. He knows why.
Since you didn’t quote anything, we have no idea who your comment is aimed at.

You posted some code, without explaining what each one actually does.

You want to change some optimal hardware hardware for some less-than-optimal hardware.

You don’t want to explain why. Instead, you want to get offended when we ask questions.

I don’t get it.

Vernon_Carter: Easy when you know how

I don't think the comments I made have anything to do with our relative numbers of posts - just some obvious common sense and a little bit of thought about the situation.

You are looking for free help. You know all about your problem. We don't know anything about your problem. The only person who can tell us about your problem is you. Putting a lot of data in front of us without any explanation is not helping us to help you.

...R

Hi Robin2 and PaulS Let me try again. I was given the arduino uno and the seeed motor shield V2 by my step son. After he saw the micky mouse cordless drill hack that I had driving the mill table. So started my quest to make use of my present, lots of google and dead ends. Came across the easy driver site via a utube vido. Then bought the EasyDriver and typed in code that some kind gent had sorted out to work his own mill with five push buttons for direction and "jog" and stop with a pot for speed. This worked great That is all in my posting of the first code. I really wanted to show him my appreciation of his gift and use the seeed shield, so back to google and all I could find driving a stepper motor with the seeed was the motor demo in the second code. This works fine aswell This has no external hardware buttons or pots. And I don't have the know how of making the seeed do what the easy driver does. So some code example to fit a pot for speed and a couple of buttons would be great Thank you

Vernon_Carter:
So some code example to fit a pot for speed and a couple of buttons would be great
Thank you

Have you read stepper motor basics that I linked to in Reply #2 ?
It includes a link to this simple stepper code

You posted code in Replies #3 and #4 but you have not told us what each of them actually does and what you would like them to do.

The code in both several things at a time and planning and implementing a program includes potentiometers and switches.

There are also examples with the Arduino IDE

…R