Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Motors, Mechanics, and Power / Re: Is Sanyo SH1603-5240 stepper motor working with Pololu DRV8825 ? on: May 22, 2013, 04:58:23 am
Thank so much for all your answer. yes that makes sense. the motor kinda worked first few times, and after that it stopped or struggled to work.
ok, I will try to find motor driver with like 5A.
17  Using Arduino / Motors, Mechanics, and Power / Re: stepper is unstable when starting. on: May 20, 2013, 10:18:25 am
I am using pololu drv8825 with an adjustable power supplier and no any load yet.
it works fine in very lower speed. but if i speed it up a little bit it just stops before it finish the turns that supposed to do.
I linked the video below


18  Using Arduino / Motors, Mechanics, and Power / Re: stepper is unstable when starting. on: May 20, 2013, 07:45:27 am
it is a bipolar motor(datasheet=http://www.farnell.com/datasheets/356741.pdf )
19  Using Arduino / Motors, Mechanics, and Power / stepper is unstable when starting. on: May 20, 2013, 05:15:10 am
I am trying to run stepper high speed.
but when it starts to run or run in slower speed , it looks oscillating randomly.
and I can really find what it's problem is.
any help would be really helpful

thanks.


i am using basic code of accelstepper library. with DRV8825 driver and Sanyo high toque motor.

Code:
#include <AccelStepper.h>

#define dMOTOR_PIN1 5
#define dMOTOR_PIN2 6


AccelStepper stepper(1,dMOTOR_PIN1,dMOTOR_PIN2); // step pin = 7 dir pin = 8

void setup()

   stepper.setMaxSpeed(5000);
    stepper.setAcceleration(500);
   stepper.setSpeed(1000);
}

void loop()

  stepper.moveTo(100000);
    stepper.runToPosition();
     stepper.moveTo(0);
    stepper.runToPosition();
}
20  Using Arduino / Programming Questions / speed up stepper motor on: May 15, 2013, 07:28:35 am
Hello I am struggling to make my two stepper motor speed up.
it has to run 3600 RPM.
here is my code two run two stepper motor with two push button.
it seems only run up to .setSpeed(200);
any advise would be really helpful




Code:
#include <Stepper.h>

#define motorSteps 200     // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 6
#define motorPin2 5
#define motorPin3 8
#define motorPin4 9

int switchPin = 2;              // switch is connected to pin 2
int switchPin2 = 3;


int led1Pin = 13;
int lightMode = 0;

int currentSwitch1State;
int beforeSwitch1State;


int stepper_curState = 0;
int stepper_bfState = 0;
int stepper_idx = 0;


bool isArrive = false;
enum
{
STEPPER_STATE_STOP = 0,
STEPPER_STATE_RUN,
STEPPER_STATE_BACK,
};


Stepper myStepper(motorSteps, motorPin1,motorPin2);
Stepper myStepper2(motorSteps, motorPin3,motorPin4);



void setup()
{
myStepper.setSpeed(200);
myStepper2.setSpeed(200);
pinMode(switchPin, INPUT);    // Set the switch pin as input

pinMode(led1Pin, OUTPUT);

Serial.begin(9600);                // Set up serial communication at 9600bps

stepper_idx = 0;
stepper_bfState = STEPPER_STATE_STOP;
stepper_curState = STEPPER_STATE_STOP;
}

void switchPinHigh()
{
if(currentSwitch1State == HIGH)
return;
beforeSwitch1State = currentSwitch1State;
currentSwitch1State = HIGH;
}
void switchPinLow()
{
if(currentSwitch1State == LOW)
return;
beforeSwitch1State = currentSwitch1State;
currentSwitch1State = LOW;

if( beforeSwitch1State != currentSwitch1State )
{
if( stepper_idx == 0)
{
stepper_bfState = stepper_curState;
stepper_curState = STEPPER_STATE_RUN;
}
else if ( stepper_idx > 0 && ( (stepper_curState == STEPPER_STATE_RUN) || (stepper_curState == STEPPER_STATE_BACK) ))
{
stepper_bfState = stepper_curState;
stepper_curState = STEPPER_STATE_STOP;
}
else if( stepper_idx > 0 &&  stepper_curState == STEPPER_STATE_STOP)
{
if(isArrive == true && (stepper_bfState == STEPPER_STATE_BACK || stepper_bfState == STEPPER_STATE_RUN))
{
stepper_bfState = stepper_curState;
stepper_curState = STEPPER_STATE_RUN;
}
else
{
stepper_bfState = stepper_curState;
stepper_curState = STEPPER_STATE_BACK;
}
}
}
}

void loop(){

if(digitalRead(switchPin) == HIGH || digitalRead(switchPin2) == HIGH)
{
switchPinHigh();
}
else if(digitalRead(switchPin) == LOW || digitalRead(switchPin2) == LOW)
{
switchPinLow();
}


if(stepper_curState == STEPPER_STATE_RUN && stepper_idx < 10000)
{
stepper_idx ++;
myStepper.step(1);
myStepper2.step(1);
}
else if(stepper_curState == STEPPER_STATE_BACK && stepper_idx > 0 )
{
stepper_idx --;
myStepper.step(-1);
myStepper2.step(-1);
}
else if(stepper_curState == STEPPER_STATE_STOP || stepper_idx == 10000 || stepper_idx == 0 )
{

if(stepper_idx == 10000)
isArrive = true;
else if(stepper_idx == 0)
isArrive = false;
stepper_curState = STEPPER_STATE_STOP;
}
}
21  Using Arduino / Programming Questions / Re: help for if statement on: May 08, 2013, 09:42:04 am
thank you for quick reply again.

so now my code is like this. I just add the code you wrote in the beginning of loop.
but what it does now is just move 1 step in the middle of 1000 steps and it carries on the 1000 stepes in stead of just stop.
what did i wrong?

Code:
/*
 Stepper Motor Controller
 language: Wiring/Arduino
 
 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.
 
 The motor moves 100 steps in one direction, then 100 in the other.
 
 Created 11 Mar. 2007
 Modified 7 Apr. 2007
 by Tom Igoe
 
 */

// define the pins that the motor is attached to. You can use
// any digital I/O pins.

#include <Stepper.h>

#define motorSteps 200     // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 6
#define motorPin2 5
#define ledPin 13

int switchPin = 2;              // switch is connected to pin 2
int led1Pin = 13;

int val;                        // variable for reading the pin status
int val2;                       // variable for reading the delayed status
int buttonState;                // variable to hold the button state

int lightMode = 0;  






// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);



void setup() {
  // set the motor speed at 60 RPMS:
  myStepper.setSpeed(60);

  // Initialize the Serial port:
  Serial.begin(9600);

  // set up the LED pin:
  pinMode(ledPin, OUTPUT);
 
  // blink the LED:
  
  
 
}




void loop(){
  
   for(int i=0; i<1000; i++)
{
   myStepper.step(1);
   if(digitalRead(switchPin) == HIGH)
      break;
}
  
  val = digitalRead(switchPin);      // read input value and store it in val
  delay(10);                         // 10 milliseconds is a good amount of time
  val2 = digitalRead(switchPin);     // read the input again to check for bounces
  if (val == val2) {                 // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (lightMode == 0) {          // if its off
          lightMode = 1;               // turn lights on!
        } else {
          if (lightMode == 1) {        // if its all-on
            lightMode = 2;             // make it blink!
          } else {
            if (lightMode == 2) {      // if its blinking
              lightMode = 3;           // make it wave!
            } else {
 if (lightMode == 3) { //  if its waving,
                lightMode = 0;           // turn light off!
              }
}
          }
        }
      }
    }
    buttonState = val;                 // save the new state in our variable
  }

  // Now do whatever the lightMode indicates
  if (lightMode == 0) { // all-off
    digitalWrite(led1Pin, LOW);
  }

  if (lightMode == 1) { // all-on
    digitalWrite(led1Pin, HIGH);
  myStepper.step(1000);
  }

  if (lightMode == 2) { // blinking
    digitalWrite(led1Pin, LOW);
  myStepper.step(0);
    
  }
  if (lightMode == 3)  { // "wave"

    digitalWrite(led1Pin, HIGH);
   myStepper.step(1000);

  }    
}


22  Using Arduino / Programming Questions / Re: help for if statement on: May 08, 2013, 09:16:18 am
Thanks you for your reply.
I am struggling to write the loop.
so I thinking of using "Digitalwrite" instead of "steps".
so defined steps before setup.
and when the button is pressed when Digitalwrite(motor) is HIGH the motor is stops
and when the button is pressed when   Digitalwrite is LOW the motor is revered the step to go back to original place.
but I am so new to this. so i am not sure i am thinking in a right way

would you be give me a little tip or help?
23  Using Arduino / Programming Questions / help for if statement on: May 08, 2013, 08:41:49 am
I wanna write code like below.

when you press a push button, a stepper motor is moving 1000 steps

and if you press the button after motor moves 1000steps, it back to -1000steps.

but it you press the button when motor is performing the 1000 steps it stops.


and this is code I've done so far.




Code:
/*
 Stepper Motor Controller
 language: Wiring/Arduino
 
 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.
 
 The motor moves 100 steps in one direction, then 100 in the other.
 
 Created 11 Mar. 2007
 Modified 7 Apr. 2007
 by Tom Igoe
 
 */

// define the pins that the motor is attached to. You can use
// any digital I/O pins.

#include <Stepper.h>

#define motorSteps 200     // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 6
#define motorPin2 5
#define ledPin 13

int switchPin = 2;              // switch is connected to pin 2
int led1Pin = 13;

int val;                        // variable for reading the pin status
int val2;                       // variable for reading the delayed status
int buttonState;                // variable to hold the button state

int lightMode = 0; 






// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);



void setup() {
  // set the motor speed at 60 RPMS:
  myStepper.setSpeed(60);

  // Initialize the Serial port:
  Serial.begin(9600);

  // set up the LED pin:
  pinMode(ledPin, OUTPUT);
  // blink the LED:
}

void loop(){
  val = digitalRead(switchPin);      // read input value and store it in val
  delay(10);                         // 10 milliseconds is a good amount of time
  val2 = digitalRead(switchPin);     // read the input again to check for bounces
  if (val == val2) {                 // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (lightMode == 0) {          // if its off
          lightMode = 1;               // turn lights on!
        } else {
          if (lightMode == 1) {        // if its all-on
            lightMode = 2;             // make it blink!
          } else {
            if (lightMode == 2) {      // if its blinking
              lightMode = 3;           // make it wave!
            } else {
  if (lightMode == 3) { //  if its waving,
                lightMode = 0;           // turn light off!
              }
}
          }
        }
      }
    }
    buttonState = val;                 // save the new state in our variable
  }



  // Now do whatever the lightMode indicates
  if (lightMode == 0) { // all-off
    digitalWrite(led1Pin, LOW);
  }

  if (lightMode == 1) { // all-on
    digitalWrite(led1Pin, HIGH);
  Serial.println("Forward");
  myStepper.step(1000);
  delay(50);

  }

  if (lightMode == 2) { // blinking
    digitalWrite(led1Pin, LOW);

   
  }
  if (lightMode == 3)  { // "wave"

    digitalWrite(led1Pin, HIGH);
 Serial.println("Backward");
  myStepper.step(-1000);
  delay(50);

  }   
}
24  Using Arduino / Motors, Mechanics, and Power / Is Sanyo SH1603-5240 stepper motor working with Pololu DRV8825 ? on: May 08, 2013, 03:56:04 am
Hello I've got Sanyo SH1603-5240 stepper motor and Pololu DRV8825
but I am not really sure I bought right stuff to work together ?
I connected them with Arduino. and the motor is not turning just shaking.
but when i using a smaller motor it works fine.

datasheet for motor.
http://www.farnell.com/datasheets/356741.pdf
25  Using Arduino / Motors, Mechanics, and Power / Re: I am trying to control direction of 2 motors with a push button on: May 07, 2013, 10:10:04 am
Sorry about that i haven't mentioned enough information earlier.

I am using Arduino mega and pololu drv 8825 motor drive for two stepper motors.

Somehow I managed to work the push button working to change the direction of two motors.
but the motors are getting really hot when i am running them. and one of my colleague says it is because of wrong coding. but i am not sure what it is problem.
Also I need to find out the way to stop a motor when they are running.
So senario will be like below.


1.when i press the button first time they are stepping 2000 to right and they stop. and if i press the button again, they go back to original place reversing direction.

2. when i press the button first time they are stepping 2000 to right. and if i press the button again before they finish the steps they just stop. and when I press the button again they go back to original position.

the code below is the code i've wrote so far.

Code:
int switchPin = 2;     
int led1Pin = 13;
int dirPin = 6;
int stepperPin = 5;


int dirPin1 = 8;
int stepperPin1 = 9;

int val;                        // variable for reading the pin status
int val2;                       // variable for reading the delayed/debounced status
int buttonState;                // variable to hold the button state

int lightMode = 0; 

void setup() {
 pinMode(switchPin, INPUT);
 pinMode(dirPin, OUTPUT);
 pinMode(stepperPin, OUTPUT);
  pinMode(dirPin1, OUTPUT);
 pinMode(stepperPin1, OUTPUT);
 
  Serial.begin(9600);                // Set up serial communication at 9600bps
  buttonState = digitalRead(switchPin); 
}
 


void step(boolean dir,int steps){
 digitalWrite(dirPin,dir);
  digitalWrite(dirPin1,dir);
 for(int i=0;i<steps;i++){
   digitalWrite(stepperPin, HIGH);
   delayMicroseconds(1000);
   digitalWrite(stepperPin, LOW);
   delayMicroseconds(1000);
      digitalWrite(stepperPin1, HIGH);
   delayMicroseconds(1000);
   digitalWrite(stepperPin1, LOW);
   delayMicroseconds(1000);}
   
}

 
 
void loop(){
  val = digitalRead(switchPin);      // read input value and store it in val
  delay(10);                         // 10 milliseconds is a good amount of time
  val2 = digitalRead(switchPin);     // read the input again to check for bounces
  if (val == val2) {                 // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (lightMode == 0) {          // is the light off?
          lightMode = 1;               // turn light on!
          digitalWrite(led1Pin, HIGH);
     
         step(true,2000);   // <----- true-direcrtion, number of steps
   
 


    } else {
          lightMode = 0;               // turn light off!
      digitalWrite(led1Pin, LOW);
      step(false,2000);  // <----- false-reverse direcrtion, number of steps
     
        }
      }
    }
    buttonState = val;                 // save the new state in our variable
  }
}
26  Using Arduino / Motors, Mechanics, and Power / I am trying to control direction of 2 motors with a push button on: May 07, 2013, 07:34:20 am
Hello, I am very new to this, so any help or advise would be really helpful.

what I am trying to do is controlling direction of 2 motors with a push button.

So when you press the button first time  the two motors moves certain steps to right, and then when you press the button again, they change the direction to left and comes back to original position.

the code below make motors moving 500steps when i press the button first time. but when i press the button again, the motors move another 500 steps to same direction rather then change to opposite way.

Code:
int dirPin = 7;
int stepperPin = 6;

int dirPin1 = 8;
int stepperPin1 = 9;


int button = 2;
int val = 0;


void setup() {
    pinMode(button, INPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(stepperPin, OUTPUT);
    pinMode(dirPin1, OUTPUT);
  pinMode(stepperPin1, OUTPUT);
}
void step(boolean dir,int steps){
 digitalWrite(dirPin,dir);
 delay(50);
 for(int i=0;i<steps;i++){
   digitalWrite(stepperPin, HIGH);
   delayMicroseconds(800);
   digitalWrite(stepperPin, LOW);
   delayMicroseconds(800);
      digitalWrite(stepperPin1, HIGH);
   delayMicroseconds(800);
   digitalWrite(stepperPin1, LOW);
   delayMicroseconds(800);
 }
}

void loop()
{

 val = digitalRead(button);

  if (val == HIGH)
  {
    int i;

    digitalWrite(dirPin, HIGH);   
   for (i = 0; i<1; i++)
    {
      digitalWrite(stepperPin, HIGH);
      step(true,500);
      digitalWrite(stepperPin, LOW);
      delay(500);
    }
  }

}
 
27  Development / Other Software Development / Re: PWM frequency library on: August 21, 2012, 03:35:03 am
Thanks for your reply runnerup, although I will have to call for your help once again as I am new to Arduino but the deadline for my project is fast approaching!! I am trying my best but am still getting compile errors, so I was hoping you could take a look at the source code I have written and with the knowledge that I am using an Arduino Uno and possibly you could spot what is going wrong!

Code:
# include "PWM.h"

//Initialize Motor 1
int InA1 = 8;
int InB1 = 12;
int PWM1 = 10;
int32_t frequency = 20000;

void setup()


 
   InitTimersSafe();
   bool success = SetPinFrequencySafe(PWM1, frequency);
 
   if(success){
   pinMode (InA1, OUTPUT);
   pinMode (InB1, OUTPUT);
   pinMode (PWM1, OUTPUT);}
 
}
 
void loop ()
{
 
 
  {//Motor Start Delay
       delay(1000);
       
   //Motor Direction
       digitalWrite(InA1, HIGH);
       digitalWrite(InB1, LOW); }
     
   
   //Motor Acceleration Control
       {for(int fadeValue = 0 ; fadeValue <= 76; fadeValue +=5){
         pwmWrite(PWM1, fadeValue);
       
         delay(100000); }
       }
       
   //Motor Run Time       
       delay(10000);
       
   //Motor Decceleration Control
       {for(int fadeValue = 76; fadeValue >= 0; fadeValue -=5){
          pwmWrite(PWM1, fadeValue);
         
          delay(100000);
       }
       } 
         
   //Motor Stop Time
       delay(10000);
 
}
 

Here is the error I am now getting. I have installed v4.0.



Many thanks!
28  Development / Other Software Development / Re: PWM frequency library on: August 20, 2012, 10:40:34 am
I mean, I tried using the psalt and then it says that prescaler_alt hasn't been declared either? Am I modifying it incorrectly by just simply deleting ps_... values and the line of code in the previous reply?
29  Development / Other Software Development / Re: PWM frequency library on: August 20, 2012, 10:10:32 am
Wait, I can't verify my sketch as it says 'prescaler' has not been declared in the following line:

Code:
extern void SetPrescaler_8(const int16_t timerOffset, prescaler psc);

What should I do?

Many thanks
30  Development / Other Software Development / Re: PWM frequency library on: August 20, 2012, 09:08:59 am
Awesome library runnerup!
Pages: 1 [2] 3 4