Go Down

Topic: steeper motor & tb-6560 & arduino  (Read 2439 times) previous topic - next topic

KMomtaz

Feb 06, 2016, 02:39 am Last Edit: Feb 06, 2016, 02:44 am by KMomtaz
Hi all ,


any one can tell me how can i control the rotate of stepper motor by make it rotate 24 step every one have 15 angle and return or by 90 degree and return ?

plz i need it in project so fast :)

Robin2

#1
Feb 06, 2016, 12:20 pm Last Edit: Feb 06, 2016, 12:21 pm by Robin2
This Simple Stepper Code should get you started.

Please post a link to the datasheet for your motor and tell us what motor power supply you are using (volts and amps).

...R
Stepper Motor Basics

Two or three hours spent thinking and reading documentation solves most programming problems.

KMomtaz

#2
Feb 06, 2016, 06:21 pm Last Edit: Feb 06, 2016, 06:26 pm by KMomtaz
the stepper motor is : 57HZ54-09
the driver is : BL-TB6560-V2.5 D305
the arduino is : mega 2560
the power supply: S-60-12


the link for motor :
http://ram-e-shop.com/oscmax/catalog/product_info.php?products_id=241&utm_source=yaoota&utm_medium=cpc&utm_campaign=yaoota


rotate a tray have 24 parts each part have 15 degree when i choose specific part the tray rotate to reach this and stop 2 sec then return to origin


thanks a lot for your help

Robin2

thanks a lot for your help
I suspect the TB6560 will be hard pressed to drive that motor at 3 amps. I would feel much happier with a 4 amp or 5 amp driver.

The power supply should work, but if you want high speeds a higher voltage would be better.

Did you try the example code in my link?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

KMomtaz

i tried ur code but it didn't work with my driver

Robin2

i tried ur code but it didn't work with my driver
You need to tell us exactly what happened.

Post the code you actually used.
Make a pencil drawing showing how everything is connected and post a photo of the drawing.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

KMomtaz

this code make motor rotate in 16 step per 360 degree CW and CCW in infinite loop 
i need to make it start from fixed point every time and return to it after finish  
( control on the number of steps by enter the variable number to move steps then return to zero )
and start when i enter the number and stop after finish  

the code : 

int steps = 0; // Record the number of steps we've taken 
int flag=0;
void setup() {

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

}

void step_move()
{
  for (int j=0;j<100;j++)
  {
    digitalWrite(9, HIGH);
    delayMicroseconds(100);
    digitalWrite(9, LOW);
    delayMicroseconds(100);
  }
}

void loop() 
{
  if(flag ==0)
  {
    for(int i=0;i<16;i++)
    {
      step_move();
      delay(500);
    }
    flag=1;
    digitalWrite(8,HIGH);
  }
  if(flag ==1)
  {
    
    for(int i=0;i<16;i++)
    {
      step_move();
      delay(500);
    }
    flag=0;
    digitalWrite(8,LOW);
  }
}

Robin2

Please use the code button </> so your code looks like this and is easy to copy to a text editor
Code: [Select]
int steps = 0; // Record the number of steps we've taken
int flag=0;
void setup() {

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

}

void step_move()
{
  for (int j=0;j<100;j++)
  {
    digitalWrite(9, HIGH);
    delayMicroseconds(100);
    digitalWrite(9, LOW);
    delayMicroseconds(100);
  }
}

void loop()
{
  if(flag ==0)
  {
    for(int i=0;i<16;i++)
    {
      step_move();
      delay(500);
    }
    flag=1;
    digitalWrite(8,HIGH);
  }
  if(flag ==1)
  {
   
    for(int i=0;i<16;i++)
    {
      step_move();
      delay(500);
    }
    flag=0;
    digitalWrite(8,LOW);
  }
}


If I understand your question properly it may be sufficient to use a variable to hold the number that is '16' in your example and then you can easily change the number of steps. Something like
for (int i = 0 ; i < numSteps; i++)

However it seems that your function step_move() moves the motor 100 steps each time it is called. If it was my project that function would only do a single step.

The second example in Simple Stepper Code does not use delay(). The delay() function should only be used for quick and dirty tests.


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

KMomtaz

the circuit photo

Robin2

Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up