Skip to main content
fixed capitalization, grammar
Source Link
agarza
  • 1.7k
  • 2
  • 16
  • 33

Calling all wizards ; Ramps What is wrong with my RAMPS X clone very bizarre problemmove/accel?

The ramps XRAMPS X Clone as X1 works beautifully But I am having a strange problem: If you look at the code  ,there there are two different parts. One is for a simple stepper move of a srepper, and the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While While X fulfills its command to move to the right side by a thousand steps  , X1 does not: It moves 300 steps to the left (approxapproximately) and then 700 steps to the right.!! Can

Can anyone find the bug? The code link is below. Thanks

The code link: https://gist.github.com/d333gs/dcf4f4124e640bd9d9b5ea50a662454d

Calling all wizards ; Ramps X clone very bizarre problem

The ramps X Clone as X1 works beautifully But I am having a strange problem: If you look at the code  ,there are two different parts. One is for simple move of a srepper the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While X fulfills its command to move to the right side by a thousand steps  , X1 does not: It moves 300 steps to the left (approx) and then 700 steps to the right.!! Can anyone find the bug? The code link is below. Thanks

https://gist.github.com/d333gs/dcf4f4124e640bd9d9b5ea50a662454d

What is wrong with my RAMPS X clone move/accel?

The RAMPS X Clone as X1 works beautifully But I am having a strange problem: If you look at the code, there are two different parts. One is for a simple stepper move, and the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not. While X fulfills its command to move to the right side by a thousand steps, X1 does not: It moves 300 steps to the left (approximately) and then 700 steps to the right!

Can anyone find the bug?

The code link: https://gist.github.com/d333gs/dcf4f4124e640bd9d9b5ea50a662454d

deleted 1854 characters in body
Source Link

The ramps X Clone as X1 works beautifully But I am having a strange problem: If you look at the code ,there are two different parts. One is for simple move of a srepper the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While X fulfills its command to move to the right side by a thousand steps , X1 does not: It moves 300 steps to the left (approx) and then 700 steps to the right.!! Can anyone find the bug?

Thanks

#include<Stepper.h>

#define X_DIR_PIN 55 #define X_STEP_PIN 54

#define X_ENABLE_PIN 38 #define X_MIN_PIN 3 #define X_MAX_PIN 2

#define X1_DRIVER_TYPE DR8825

#define X1_DIR 55 #define X1_STP 54

#ifndef X1_STEP_PIN #define X1_STEP_PIN 36 #endif #ifndef X1_DIR_PIN #define X1_DIR_PIN 34 #endif #ifndef X1_ENABLE_PIN #define X1_ENABLE_PIN 30 #endif #ifndef X1_CS_PIN #define X1_CS_PIN AUX1_07 #endif

void setup() {

pinMode(X_STEP_PIN, OUTPUT); pinMode(X_DIR_PIN, OUTPUT); pinMode(X_ENABLE_PIN, OUTPUT);

pinMode(X1_STEP_PIN, OUTPUT); pinMode(X1_DIR_PIN, OUTPUT); pinMode(X1_ENABLE_PIN, OUTPUT);

} void simpleMove(int steps) { int interval = 1000; for (int i = 0; i < steps; i++) { digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(interval);

} } void simpleAccel(int steps) { int lowSpeed = 3000; int highSpeed = 200; int change = 2;

int rampUpStop = (lowSpeed - highSpeed) / change; if ( rampUpStop > steps / 2 ) rampUpStop = steps / 2; int rampDownStart = steps - rampUpStop;

int d = lowSpeed;

for (int i = 0; i < steps; i++) { int interval = 100; digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(d);

if ( i < rampUpStop )
  d -= change;
else if ( i > rampDownStart )
  d += change;

} }

void loop() { digitalWrite(X_DIR_PIN, LOW); simpleMove(1000); digitalWrite(X1_DIR_PIN, LOW); simpleMove(1000); delay(10000); digitalWrite(X_DIR_PIN, HIGH); simpleAccel(1000); digitalWrite(X1_DIR_PIN, HIGH);The code link is below. simpleAccel(1000);Thanks

//while (true); delay(10000); }https://gist.github.com/d333gs/dcf4f4124e640bd9d9b5ea50a662454d

The ramps X Clone as X1 works beautifully But I am having a strange problem: If you look at the code ,there are two different parts. One is for simple move of a srepper the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While X fulfills its command to move to the right side by a thousand steps , X1 does not: It moves 300 steps to the left (approx) and then 700 steps to the right.!! Can anyone find the bug?

Thanks

#include<Stepper.h>

#define X_DIR_PIN 55 #define X_STEP_PIN 54

#define X_ENABLE_PIN 38 #define X_MIN_PIN 3 #define X_MAX_PIN 2

#define X1_DRIVER_TYPE DR8825

#define X1_DIR 55 #define X1_STP 54

#ifndef X1_STEP_PIN #define X1_STEP_PIN 36 #endif #ifndef X1_DIR_PIN #define X1_DIR_PIN 34 #endif #ifndef X1_ENABLE_PIN #define X1_ENABLE_PIN 30 #endif #ifndef X1_CS_PIN #define X1_CS_PIN AUX1_07 #endif

void setup() {

pinMode(X_STEP_PIN, OUTPUT); pinMode(X_DIR_PIN, OUTPUT); pinMode(X_ENABLE_PIN, OUTPUT);

pinMode(X1_STEP_PIN, OUTPUT); pinMode(X1_DIR_PIN, OUTPUT); pinMode(X1_ENABLE_PIN, OUTPUT);

} void simpleMove(int steps) { int interval = 1000; for (int i = 0; i < steps; i++) { digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(interval);

} } void simpleAccel(int steps) { int lowSpeed = 3000; int highSpeed = 200; int change = 2;

int rampUpStop = (lowSpeed - highSpeed) / change; if ( rampUpStop > steps / 2 ) rampUpStop = steps / 2; int rampDownStart = steps - rampUpStop;

int d = lowSpeed;

for (int i = 0; i < steps; i++) { int interval = 100; digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(d);

if ( i < rampUpStop )
  d -= change;
else if ( i > rampDownStart )
  d += change;

} }

void loop() { digitalWrite(X_DIR_PIN, LOW); simpleMove(1000); digitalWrite(X1_DIR_PIN, LOW); simpleMove(1000); delay(10000); digitalWrite(X_DIR_PIN, HIGH); simpleAccel(1000); digitalWrite(X1_DIR_PIN, HIGH); simpleAccel(1000);

//while (true); delay(10000); }

The ramps X Clone as X1 works beautifully But I am having a strange problem: If you look at the code ,there are two different parts. One is for simple move of a srepper the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While X fulfills its command to move to the right side by a thousand steps , X1 does not: It moves 300 steps to the left (approx) and then 700 steps to the right.!! Can anyone find the bug? The code link is below. Thanks

https://gist.github.com/d333gs/dcf4f4124e640bd9d9b5ea50a662454d

Source Link

Calling all wizards ; Ramps X clone very bizarre problem

The ramps X Clone as X1 works beautifully But I am having a strange problem: If you look at the code ,there are two different parts. One is for simple move of a srepper the other is for a simple acceleration. The simple move with X and clone X1 work. Simple Accel clone X1 does not.While X fulfills its command to move to the right side by a thousand steps , X1 does not: It moves 300 steps to the left (approx) and then 700 steps to the right.!! Can anyone find the bug?

Thanks

#include<Stepper.h>

#define X_DIR_PIN 55 #define X_STEP_PIN 54

#define X_ENABLE_PIN 38 #define X_MIN_PIN 3 #define X_MAX_PIN 2

#define X1_DRIVER_TYPE DR8825

#define X1_DIR 55 #define X1_STP 54

#ifndef X1_STEP_PIN #define X1_STEP_PIN 36 #endif #ifndef X1_DIR_PIN #define X1_DIR_PIN 34 #endif #ifndef X1_ENABLE_PIN #define X1_ENABLE_PIN 30 #endif #ifndef X1_CS_PIN #define X1_CS_PIN AUX1_07 #endif

void setup() {

pinMode(X_STEP_PIN, OUTPUT); pinMode(X_DIR_PIN, OUTPUT); pinMode(X_ENABLE_PIN, OUTPUT);

pinMode(X1_STEP_PIN, OUTPUT); pinMode(X1_DIR_PIN, OUTPUT); pinMode(X1_ENABLE_PIN, OUTPUT);

} void simpleMove(int steps) { int interval = 1000; for (int i = 0; i < steps; i++) { digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(interval);

} } void simpleAccel(int steps) { int lowSpeed = 3000; int highSpeed = 200; int change = 2;

int rampUpStop = (lowSpeed - highSpeed) / change; if ( rampUpStop > steps / 2 ) rampUpStop = steps / 2; int rampDownStart = steps - rampUpStop;

int d = lowSpeed;

for (int i = 0; i < steps; i++) { int interval = 100; digitalWrite(X_STEP_PIN, HIGH); digitalWrite(X_STEP_PIN, LOW);

digitalWrite(X1_STEP_PIN, HIGH);
digitalWrite(X1_STEP_PIN, LOW);
delayMicroseconds(d);

if ( i < rampUpStop )
  d -= change;
else if ( i > rampDownStart )
  d += change;

} }

void loop() { digitalWrite(X_DIR_PIN, LOW); simpleMove(1000); digitalWrite(X1_DIR_PIN, LOW); simpleMove(1000); delay(10000); digitalWrite(X_DIR_PIN, HIGH); simpleAccel(1000); digitalWrite(X1_DIR_PIN, HIGH); simpleAccel(1000);

//while (true); delay(10000); }