Go Down

Topic: Controlling a big stepper motor (Read 4962 times) previous topic - next topic

outsider

How is the driver wired to the Arduino?

Robin2

#16
Feb 27, 2018, 01:32 pm Last Edit: Feb 27, 2018, 01:37 pm by Robin2
Using both parameters you have in your code:
Code: [Select]
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps

I wasn't able to move the motor.
I can't understand why the changes you made improved matters.

You made two changes. Which of them was the important one?

When you are trying to debug a problem NEVER change more than 1 thing at a time.


I have just noticed (prompted by @outsider's question) that the code in Reply #8 uses pins 5 and 6 whereas the code in Reply #12 uses pins 9 and 8. Both can't be right unless you have been messing with the wiring.

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

zeus2kx

How is the driver wired to the Arduino?
Exactly like this.
Only the pins are different.
Code on this page works but ONLY when DIP switches are set to 1/32th.
If I change the DIP settings, I hear tones.

zeus2kx

You made two changes. Which of them was the important one?

Actually both.
This evening I retest and post some parametric results.

outsider

You're using HIGH true code with a LOW true connection.

zeus2kx

You're using HIGH true code with a LOW true connection.
Kindly elaborate.

outsider

If  PUL+, ENA+ and DIR+ are connected to +5V and PUL-, ENA- and DIR- are wired to the output pins, that's LOW true, the input to the drive is active when the pin is pulled LOW, try changing your program logic to match. I'm not sure how ENA works, just leave it disconnected for now, set microsteps to 1 (200) and try.

zeus2kx

Do you mean this:

Code: [Select]
int PUL=7; //define Pulse pin
int DIR=6; //define Direction pin
void setup() {
  pinMode (PUL, OUTPUT);
  pinMode (DIR, OUTPUT);

}

void loop() {
  for (int i=0; i<6400; i++)    //Forward 5000 steps
  {
    digitalWrite(DIR,LOW);
    digitalWrite(PUL,LOW);
    delayMicroseconds(50);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(50);
  }
  for (int i=0; i<6400; i++)   //Backward 5000 steps
  {
    digitalWrite(DIR,HIGH);
    digitalWrite(PUL,LOW);
    delayMicroseconds(50);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(50);
  }
}

outsider

Does that make the motor step?

zeus2kx

I can't check now, only in the evening when I get back home.

outsider

#25
Feb 27, 2018, 03:01 pm Last Edit: Feb 27, 2018, 03:19 pm by outsider
If that works, leave ENA disconnected and try this (make sure pin connections are correct):
Code: [Select]

byte pulWidth = 20;
uint32_t intervalFwd = 15000,
         intervalRev = 300;

int PUL=7; //define Pulse pin
int DIR=6; //define Direction pin
//int ENA=5; //define Enable Pin
void setup() {
  pinMode (PUL, OUTPUT);
  pinMode (DIR, OUTPUT);
  //pinMode (ENA, OUTPUT);

}

void loop() {
  for (int i=0; i<200; i++)    //Forward 200 steps
  {
    digitalWrite(DIR,LOW);
    //digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(pulWidth);
    digitalWrite(PUL,LOW);
    delayMicroseconds(intervalFwd);
  }
  for (int i=0; i<200; i++)   //Backward 200 steps
  {
    digitalWrite(DIR,HIGH);
    //digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(pulWidth);
    digitalWrite(PUL,LOW);
    delayMicroseconds(intervalRev);
  }
}

Then work on microsteps, etc.
EDIT: Just remembered max delayMicroseconds is 16383, changed intervalFwd from 300000 to 15000.  :P

zeus2kx

Great, thanks.
I will do that and get back to this thread in the evening.

If this doesn't work, I am going to dump this driver and use ST-M5045.


zeus2kx

I hope so  :smiley-confuse:
Once this works, i will figure out how to enable/disable.
Motor wire gets hotter when powered.

Then add some buttons and pot.

Long way to go.

outsider

There ARE drives that reduce standstill current to prevent that and I think the TB6600 chip has that feature, don't know if that drive brings it out though.

Go Up