Cannot increase speed of stepper motor using PWM

Grumpy_Mike:
The data sheet of the driver can be found here

I know that. But I was trying to make a point to the OP.

...R

Yes sorry, I replied to the comments on the first page of the thread and didn't see the first three posts of the second page until I had finished my second post on this page.

Grumpy_Mike:
Yes sorry, I replied to the comments on the first page of the thread and didn't see the first three posts of the second page

No problem I have done the same myself.

...R

Hello, the code is very simple, the loop is exactly as posted but the full program is at work and will have to be posted tomorrow.

Yes you guys found the correct data sheet. The Gecko drive is very common for hobby CNC's and if you go to CNCzone.com its a well known drive system.

I am running with a 24v power supply (which is way low) at work and a 48v at home, but again with step pulses showing 400 hz on the DMM we are not close. 125 oz in stepper motors all have the same dimensions and ratings basically. I am not pushing anywhere near their general limits. You will get more RPM out of these than the 400 oz in motors.

Motor current setting is for 2.0 amps, and 2 uStep (1234 = green) providing the maximum rotation per step pulse.

The question is why the Arduino is only pulsing 400 hz. Problem #1.

I am now studying methods to 'hack' the step pin.

http://www.billporter.info/2010/08/18/ready-set-oscillate-the-fastest-way-to-change-arduino-pins/

Robin2:
How are we going to do that when you have not posted a link to its datasheet?
What is different about it? (Apart from handling higher currents and being more expensive)

...R

The Gecko is not unlike other industrial stepper drives in that it has really good mid and low band resonant frequency dampening. However easy step/big step/ whatever junk they sell for cheap for experimentation has no such circuitry, AFAIK just a 297/298 logic with MOSFETS. Hit the wrong frequency on these motors and you are in big trouble. You can go to automation direct probably to get similar quality drives to Gecko with resonant circuitry. I have bought many Gecko drives and there is also the benefit of being able to call and talk to the designer of the circuit.

Thanks for all of the input.

The question is why the Arduino is only pulsing 400 hz. Problem #1.

That is what is not happening, or there is something you are not telling us. Others have told you what frequency your code produces. So the discrepancy is caused by either you misunderstanding something, or us misunderstanding something because you haven't told us the "vital" bit.

How are you measuring this figure?

tog1:
Yes you guys found the correct data sheet. The Gecko drive is very common for hobby CNC's and if you go to CNCzone.com its a well known drive system.

I know they are widely used but that is not the same as being familiar with the details. And you are the person who wants help, why would you expect us to go anywhere?

The Gecko is not unlike other industrial stepper drives in that it has really good mid and low band resonant frequency dampening. However easy step/big step/ whatever junk they sell for cheap for experimentation has no such circuitry,

Those features may be very important for your application but they will not bother either the Arduino or your program code. As far as the Arduino is concerned it just needs to provide step and direction signals the same as for a Pololu A4988 stepper driver.

And here we are at Reply #25, no further on than we were at the start and still without having had sight of your program.

Are you the same person as @shs125 who started this Thread?

...R

Yes in reply #10 he said

(shs125, non-work account)

I've programmed with the Gecko a couple of years ago (great drivers), and was running four motors at 10kHz no problems.
This included speed ramping in software, so your code sounds like it may have an issue.

Grumpy_Mike:
Yes in reply #10 he said

Oops - now you point it out I did see that. Apologies for any confusion.

...R

#include <LiquidCrystal.h>
#include <time.h>
#include <Stepper.h>

const int dirPin = 6;
const int stepPin = 7;
int interval = 200;
int spd=1000;
int previousMillis = 0;

int displayInterval = 50;

int speedPot = 0;
int widthPot = 0;
int densityPot = 0;

int speedDisplay = 0;
int widthDisplay = 0;
int densityDisplay = 0;

//const int dirPin = 6;
//  const int stepPin = 7;
  
  
// Initialize the library with the pins we're using.
// (Note that you can use different pins if needed.)
// See http://arduino.cc/en/Reference/LiquidCrystal
// for more information:

LiquidCrystal lcd(12,11,5,4,3,2);

void setup()
{
  //pinMode()
  // The LiquidCrystal library can be used with many different
  // LCD sizes. We're using one that's 2 lines of 16 characters,
  // so we'll inform the library of that:
  pinMode(dirPin,OUTPUT);
  pinMode(stepPin,OUTPUT);
  pinMode(9,OUTPUT);
  lcd.begin(16, 2);
  // Data sent to the display will stay there until it's
  // overwritten or power is removed. This can be a problem
  // when you upload a new sketch to the Arduino but old data
  // remains on the display. Let's clear the LCD using the
  // clear() command from the LiquidCrystal library:
  lcd.clear();
  digitalWrite(9,HIGH);
  // Now we'll display a message on the LCD!
  

  // Just as with the Arduino IDE, there's a cursor that
  // determines where the data you type will appear. By default,
  // this cursor is invisible, though you can make it visible
  // with other library commands if you wish.

  // When the display powers up, the invisible cursor starts 
  // on the top row and first column.

  // Adjusting the contrast (IMPORTANT!)

  // When you run the sketch for the first time, there's a
  // very good chance you won't see anything on the LCD display.
  // This is because the contrast likely won't be set correctly.
  // Don't worry, it's easy to set, and once you set it you won't
  // need to change it again.

  // Run the sketch, then turn the potentiometer until you can
  // clearly see the "hello, world!" text. If you still can't
  // see anything, check all of your connections, and ensure that
  // the sketch was successfully uploaded to the Arduino.
}

void loop()
{
  //time = micros();
  
  // enable
  
  
  speedDisplay=analogRead(speedPot);
  //unsigned long currentMillis = micros();
  //unsigned long currentMillis = micros();
  unsigned long currentMillis = millis();
  
  interval = 100-speedDisplay;
  if (interval <1) interval = 1;
  
    if (currentMillis - previousMillis > interval){
        previousMillis = currentMillis;
        // change state
        digitalWrite(stepPin,HIGH);
        digitalWrite(stepPin,LOW);
    //    lcd.print("Spd:");
    //    lcd.setCursor(5,0);
    //    lcd.print(interval);
    }
    
  }

I have removed some stuff like loops and LCD display that were slowing down the loop.

I had a good output frequency (>1000 hz) when everything but the digitalWrites were removed.

Now the problem is that after about 30 sec of running, the PWM output frequency suddenly jumps to thousands of HZ. Not sure why that is anybody know?

shs125:
Now the problem is that after about 30 sec of running, the PWM output frequency suddenly jumps to thousands of HZ. Not sure why that is anybody know?

That sounds like an integer overflow. The max value of an int is 32767 which is not far off the number of millisecs in 30 seconds.

Change the variables interval and speedDisplay to unsigned long (same as millis() uses).

Also the timing will be a little more accurate if you change this

previousMillis = currentMillis;

to this

previousMillis += interval;

...R

Thank you did the trick

So:-

the code is very simple, the loop is exactly as posted but the full program is at work and will have to be posted tomorrow.

Was not telling the truth then because you had other stuff in it, as you say:-

I have removed some stuff like loops and LCD display that were slowing down the loop.

Waiting for an apology.

I had a good output frequency (>1000 hz) when everything but the digitalWrites were removed.

You are at it again.
This is not a post truth forum.

Grumpy_Mike:
This is not a post truth forum.

I know it is off-topic but it is a great comfort to know that you can't get away with lying to the compiler (or to gravity).

...R

I'm sorry, didn't see it coming.

I don't fully understand what the Arduino is doing still, and am working thru a lot of bugs, which wouldn't bother me except I heard that it is only good for so many rewrites.

perhaps 100,000 ... keep you busy for a while.

Allan

I heard it was 1000 which is not a lot

shs125:
I heard it was 1000 which is not a lot

I suspect you are both wrong :slight_smile:

From the Atmega 328 datasheet

– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

Program code is stored in Flash memory.

...R

shs125:
I heard it was 1000 which is not a lot

You keep hearing a lot of rubbish, maybe you should update your friends.