Go Down

Topic: Troubleshooting help getting speed up on a Nema 34 (Read 339 times) previous topic - next topic

suade907

May 19, 2017, 12:37 am Last Edit: May 19, 2017, 01:21 am by suade907
Hi Guys, i was hoping someone on here could help me work out a issue I'm having.

I have a ESAB waterjet machine. It has 3 heads the first two have failed. This is a very expensive yet older machine, so rather than pay to fly in a tech, put him up in a hotel, pay for $1000's servo drives to be replaced. I decided to replace the first head AC servo motor with a nema 34 stepper motor controlled by an arduino. I have it installed and all my code and buttons work, I'm using a very primitive coding system to pulse the microstepper 1 step every time the button is pressed. It takes 1400 steps to do a revolution. If I hold the button it will just turn until I let go. I control the speed by changing the delay. The lower the delay the faster the rotation. The longer the delay the slower. So to get my speed up to a usable speed I had to set it to 90 microseconds.

I'm using a SainSmart CNC Micro-Stepping Stepper Motor Driver 2M542 Bi-polar 2phase 4.2A Switch.
I'm using a 960 oz-in NEMA 34 Motor capable of 7 amps of current.
I'm using a NEWSTYLE 24V 15A Dc Universal Regulated Switching Power Supply 360W.
I'm using a Arduino Nano as well.

Now I know my microstepper is only capable of 4.5 amps of current but that is plenty to lift and lower my head. I was actually going to use a Nema 23 but the nema 34 was a direct replacement. I also know the Nema 34 and microstepper would be better suited to a 48v power supply but for now the 24v should be fine.

So the Problem. The way I set it up is 4 buttons, one slow up/one slow down and one fast up/one fast down. It does work, but I can't get my speeds as fast as i want. Also I know the machine is not moving with the torque I feel it should. If I try to change my delay down to say 10-75 microseconds the motor makes a noise and doesn't move. It's not missing steps and it's nowhere near using much in the terms of current. Maybe 1.6 amps at 600 microsecond delay and 1.2 amps at 90 microsecond delay. I'm sure there is a better way to code this using the accelstepper function library but i haven't got that far yet and this would work fine for me if I could get the speed up. I've seen this motor do 1400 ipm rapids on a cnc router so I know it's capable.

I'm wondering if by pulsing every 90 microseconds am I pushing too much code through the arduino causing it to stall out. Or is it possible my power supply is just to small. Regardless i do have a larger one on order. But meanwhile I was just curious what the experts thought. And also this code might help some people get a microstepper working in the simplest possible way IMO.

Thanks for any help in advance. I'm very new to the Arduino so take it easy on me. I'm trying.

As for my code here it is:


Code: [Select]


#define DISTANCE 1 //Set the amount steps per button press, if set to 1 and held it will rotate forever at one step increments, if set to 1600 it will do one revolution per press//


int StepCounter = 0;
int Stepping = false;
int SteppingFast = false;

void setup() {
 pinMode(8, OUTPUT); //direction on microstepper//
 pinMode(9, OUTPUT); //pul on microstepper//
 digitalWrite(8, LOW);
 digitalWrite(9, LOW);

 pinMode(2, INPUT); //button slow up, not positive on these//
 pinMode(3, INPUT); //button slow down, machine is at work//
 pinMode(4, INPUT); //button fast down, will check later//
 pinMode(5, INPUT); //button fast up//
}

void loop() {
 if (digitalRead(3) == LOW && Stepping == false)
 {
   digitalWrite(8, LOW);
   Stepping = true;
 }
 if (digitalRead(2) == LOW && Stepping == false)
 {
   digitalWrite(8, HIGH);
   Stepping = true;
 }
 
 if (Stepping == true)
 {
   digitalWrite(9, HIGH);
   delayMicroseconds(600); //changing to delaymicroseconds allows the loop to run faster acting like a faster rpm//
   digitalWrite(9, LOW);
   delayMicroseconds(600);

   StepCounter = StepCounter + 1;
 }
 if (StepCounter == DISTANCE)
 {
   StepCounter = 0;
   Stepping = false;
 }

 if (digitalRead(4) == LOW && SteppingFast == false)
 {
   digitalWrite(8, LOW);
   SteppingFast = true;
 }
 if (digitalRead(5) == LOW && SteppingFast == false)
 {
   digitalWrite(8, HIGH);
   SteppingFast = true;
 }
 if (SteppingFast == true)
 {
   digitalWrite(9, HIGH);
   delayMicroseconds(90); //changing to delaymicroseconds allows the loop to run faster acting like a faster rpm//
   digitalWrite(9, LOW);
   delayMicroseconds(90);

   StepCounter = StepCounter + 1;
 }
 if (StepCounter == DISTANCE)
 {
   StepCounter = 0;
   SteppingFast = false;
 }
}




My schematic is similar to this with 4 buttons instead of two.

AWOL

If you want anyone to understand your code, consider what all those magic numbers on your code mean. What are those pins connected to?
Also why couldn't you be bothered to read the guidelines about forum posts?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

suade907

Is that better? I think I covered everything.

suade907

Hi guys, I think I found my problem. I've found that the arduino processor is only capable of computing approx 4000 steps per second then it bottle necks. I've found a trick using accelstepper to make it work but I'm not sure it will work for my application. Oh well, My setup works just slower than i wanted but i can deal. Thanks and i hope anyone that reads this might learn something.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

edgemoron

Have you tried full steps for rapid traverse and microstepping for slow, higher resolution moves?

Robin2

I've found that the arduino processor is only capable of computing approx 4000 steps per second then it bottle necks.
What gave you that idea?

In your program your steps are done like this
Code: [Select]
 digitalWrite(9, HIGH);
   delayMicroseconds(90); //changing to delaymicroseconds allows the loop to run faster acting like a faster rpm//
   digitalWrite(9, LOW);
   delayMicroseconds(90);

There is no need for the pulse to be as long as the interval between pulses. With most stepper drivers you can create a perfectly good pulse with

Code: [Select]
digitalWrite(9, HIGH);
   digitalWrite(9, LOW);
   delayMicroseconds(180);

because digitalWrite() is quite slow. 10 µsecs is usually enough for the pulse. Some drivers don't even need that.

If you need pulses faster than can be generated with digitalWrite() and using micros() for timing you can use port manipulation to write directly to the I/O pins and/or  you can use one of the HardwareTimers to manage the timing or generate the pulses.

...R
Stepper Motor Basics
Simple Stepper Code
Two or three hours spent thinking and reading documentation solves most programming problems.

MarkT

With a large motor you must ramp up the step rate if you want it to work at any sort of speed, there is a
lot of momentum you have to provide.  AccelStepper library does proper ramp calculations in floating point
so its slow on an integer-only 8-bit microcontroller.  Someone will have written a library that does basic
ramping a lot faster I suspect.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

suade907

What gave you that idea?

In your program your steps are done like this
Code: [Select]
digitalWrite(9, HIGH);
   delayMicroseconds(90); //changing to delaymicroseconds allows the loop to run faster acting like a faster rpm//
   digitalWrite(9, LOW);
   delayMicroseconds(90);

There is no need for the pulse to be as long as the interval between pulses. With most stepper drivers you can create a perfectly good pulse with

Code: [Select]
digitalWrite(9, HIGH);
   digitalWrite(9, LOW);
   delayMicroseconds(180);

because digitalWrite() is quite slow. 10 µsecs is usually enough for the pulse. Some drivers don't even need that.

If you need pulses faster than can be generated with digitalWrite() and using micros() for timing you can use port manipulation to write directly to the I/O pins and/or  you can use one of the HardwareTimers to manage the timing or generate the pulses.

...R
Stepper Motor Basics
Simple Stepper Code

Thanks for the tips, I'll give it a try but I found the 4000 step comment directly on the accelstepper.h file line 294

Also, AWOL if you tell me what my post is missing I'd be happy to fix it. I seriously don't understand what is wrong with it?

AWOL

Quote
Also, AWOL if you tell me what my post is missing I'd be happy to fix it. I seriously don't understand what is wrong with it?
All the magic numbers
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Robin2

Thanks for the tips, I'll give it a try but I found the 4000 step comment directly on the accelstepper.h file line 294
That is a limitation of that library, not a limitation of an Arduino.

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

jpk

Just stumbled here, this could be your solution: with that code I ramp up my steppers up to 3000 RPM.

MarkT

That is a limitation of that library, not a limitation of an Arduino.

...R
Its a limitation of the Arduino being 8 bit without floating point unit...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Robin2

Its a limitation of the Arduino being 8 bit without floating point unit...
I'm sure it would be possible to produce a perfectly adequate equivalent to AccelStepper without using floating point maths.

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

Go Up