Go Down

Topic: TB6560 needs warmup phase (Read 1 time) previous topic - next topic

Cluoiset

Hello there,

I'm facing an interesting problem(at least for me).
I am controlling a stepper motor with a single axis TB6560 stepper controller.

It is controlling a small turntable, and when I power it up, it runs noisy and skips steps.
After a short period of time it gets more and more accurate and not so loud and after around 5 minutes, noise is gone and steps are not skipped.
So workaround is that I implemented a small warm-up phase, which turns the stepper back and forth until noise is gone.

Does anyone have any idea what can be the problem?

I think wiring is okay, because it works, after 5 minutes turning accuracy is below 0.1 mm with a diameter of around 300 mm, so that is okay for me.

The code is posted below:
I use a rotary encoder to navigate.

Code: [Select]

#include <TimerOne.h>
#include <LiquidCrystal.h>
//  Cables
//  Pin 10 -  Grey  -  Enable
//  Pin 9  -  Lila  -  Dir
//  Pin 8  -  Blue  -  Step 

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
           
// Motor setup           
int StepperEnable = 10;
int StepperDir = 9;
int StepperStep = 8;
int StepperOneTurn = 800;

long CNCTurn = 96000;
static long StepCounterL = 0;
static int StepCounter = 0;
static boolean StepState= false;
static int StepEnable=0;
float DesiredDegree;
int Division;
// Buttons
static int Button3State = 0;
int Button1 = 1;
int Button2 = 2;
int Button3 = 3;

// Encoder pin
int IntPin = 2;
int RefPin = A1;
static volatile unsigned int CounterValue;
static volatile unsigned int TempValue = 5;
// Analog
int val = 0;
int i = 0;
int menu = 0;
void setup()
{
 
  pinMode(IntPin, INPUT);
  pinMode(RefPin, INPUT);
  pinMode(Button3, INPUT);
  attachInterrupt(0, count, RISING);
  // Motor warmup
  pinMode(StepperEnable, OUTPUT);
  pinMode(StepperDir, OUTPUT);
  pinMode(StepperStep, OUTPUT);
  lcd.begin(16, 2);
  while (Button3State == 0)
  { 
  lcd.setCursor(0, 0);
  lcd.print("1:Warm,2:Work"); 
  lcd.setCursor(0, 1);
  lcd.print(CounterValue);
  Button3State = digitalRead(Button3);
  }
  Button3State = 0;
  StepEnable=1;
  digitalWrite(StepperEnable , StepEnable);
  digitalWrite(StepperDir , 1);
  delay(1000);
  while (CounterValue==1)
  {   
    for (i=0; i<5000; i++)
    {
      digitalWrite(StepperDir , 1);
      StepState = !StepState;
      digitalWrite (StepperStep, StepState);
      delayMicroseconds(500);
      Button3State = digitalRead(Button3);
      if (Button3State)
      {
        CounterValue = 0;
      }
    }
    delay(1000);
    digitalWrite(StepperDir , 0);
    for (i=0; i<5000; i++)
    {
      StepState = !StepState;
      digitalWrite (StepperStep, StepState);
      delayMicroseconds(500);   
      Button3State = digitalRead(Button3);
      if (Button3State)
      {
        CounterValue = 0;
 
      }
    }
   
    delay(1000);
  }

  Button3State = 0;
  CounterValue = 0;
  delay(2000);
  //lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0); 
  lcd.print("Choose div");
  lcd.setCursor(0, 1);
  // calculating division
  while (Button3State == 0)
  {
 
  Division = round(val/4);
  lcd.setCursor(0, 1);
  lcd.print("       ");
  lcd.setCursor(0, 1);
  lcd.print(CounterValue);
  delay(100);
  Button3State = digitalRead(Button3);
  }
  DesiredDegree = 360.0/CounterValue;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Division: "); lcd.print(CounterValue);
  delay(3000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Deg/Steps =");
  lcd.setCursor(0,1);
  lcd.print(DesiredDegree,10);
 
  DesiredDegree = DesiredDegree * 1000.0;
  CNCTurn = (long)(DesiredDegree / 3.75);
 
  delay(3000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Step "); lcd.print(CNCTurn);
  delay(3000);
 
  pinMode(StepperEnable, OUTPUT);
  pinMode(StepperDir, OUTPUT);
  pinMode(StepperStep, OUTPUT);
  StepEnable=1;
  digitalWrite(StepperEnable , StepEnable);
  digitalWrite(StepperDir , 0);
  digitalWrite(StepperStep, StepState);
  Timer1.initialize(600);
  Timer1.attachInterrupt( timerIsr ); 
}
 
void loop()
{

  Button3State = digitalRead(Button3);
  if ((StepEnable == 0) && (Button3State == 1))
  {
    delay(1000);
    noInterrupts();
    StepCounterL=0;
    interrupts();

     
  }
 
}
 
/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
    if (StepCounterL == CNCTurn)
    {
      StepCounter++;
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Division: ");
      lcd.setCursor(0,1);
      lcd.print(StepCounter);
      StepCounterL++;
      StepEnable = 0;
    }
    else if (StepCounterL < CNCTurn)
    {
      StepState = !StepState;
      digitalWrite (StepperStep, StepState);
      StepCounterL++;
    }
    else
    {
     
    }
}

void count()

  if (digitalRead(RefPin)==HIGH)
  {
    TempValue++;     
  }
  else
  {
    TempValue--;
  }
  if (TempValue>=7)
  {
    CounterValue++;
    TempValue = 5;
  }
  else if (TempValue<=3)
  {
    CounterValue--;
    TempValue = 5;
  }
  if (CounterValue >= 360)
  {
    CounterValue=0; 
  }

}




Robin2

Why have you LCD.print statements in an ISR ?    Don't.  Print staments need interrupts which are disabled within an ISR. They are also very slow.  Put as little as possible inside an ISR.

You seem to have chosen a very complicated way to get your motor to move. How is it supposed to work?

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

Cluoiset

Hi Robin,

thank you for looking at my code.
You are right about the interrupts. There are a lot of improvement opportunities in the code.
And findings are always welcome, I will tidy the code up.

Do you think this has any effect on the "warm up" phenomenon I described above?
Because if they would be then I think the problem would not go away within minutes. I think this is either a problem of the motor or I have a defect stepper controller.

And yes it is overcomplicated :) This little code should drive a turntable for a milling machine for my father. He wants to use it to divide up the perimiter of a disk, where he has to drill holes.
For example a disc with a diameter of 300 mm-s has to have 101 holes along its diameter.

The effect I observe is that it basically works, it just needs time, to "warm-up". So at the beginning I turn the table back and forth until it is quiet enough and then do the milling.

It might be an ESD issue, now that I think about it.     

Robin2

Do you think this has any effect on the "warm up" phenomenon I described above?
As I don't know how it works, and you did not respond to my suggestion that you explain it, I don't have any idea.

You could perhaps try this simple stepper code and see if that works better.

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

Cluoiset

:) I can explain the code if you want, but as I said, if it works after 5 minutes correctly, I do not think it has to do anything with the code...

But of course the working theory is as follows: every time a timer trigger comes I invert the Clk input of the driver, that way at every second trigger the motor steps one.

I think this is more a mechanical/ESD/hardware issue.

Robin2

I don't have your hardware and I don't know what the problem is. However it would be completely unacceptable to me.

If it was my project I would try different code to see if that made any difference - that would only take 10 or 15 minutes.

I have heard of a lot of complaints about the quality of TB6560s so that might be another avenue of enquiry.

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

yaafm

Whilst the TB6560 chip itself is supposed to be not a bad chip, unfortunately the same can't apparently be said for the majority of Chinese boards that utilize it. As I've said before on this forum, the main CNC sites have just about given up trying to troubleshoot systems that use these Chinese boards.

If you do a search you'll find that common issues revolve around things such as:

Abusing the chip by overshooting its max specs in an attempt to make it look more capable than it actually is.
Poor design not starting up the chip properly. (motor power before logic).
Using questionable quality components. (poor step waveforms)

Some industrious souls have even published fixes for some of these issues but as one "TB6560" driver board may be quite different to the next it can apparently be a bit of a challenge to say the least.

TBH yours could be worse. A common issue is letting the smoke out soon as you power it.

TomGeorge

HI,
What are you using to power the stepper and driver?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Also a picture of the project would help.

Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

MarkT

Motors don't have a warm-up time, something is wrong somewhere.  Perhaps you have
a misaligned bearing and the shaft is rubbing until thermal expansion?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Cluoiset

Thank you for replies. I will make some photos and a circuit diagram and post it.

Go Up