Go Down

Topic: How to avoid jerks between steps when starting and stopping (Read 302 times) previous topic - next topic

movingforever

Oct 20, 2018, 03:58 pm Last Edit: Oct 20, 2018, 04:00 pm by movingforever Reason: edited title for better clarity on question
Hello,

I am a newbie and have made a hanging rotation gadget with Nema17, an Arduino uno and an easy driver 4988 for photographing jewelry products such as a necklace with pendant. I have never written code before, however just wrote one after reading and experimenting.

The issue -

1. The rotation needs to be very slow, so the hanging necklace does not swing too much between wait states


The motor needs to stop every 10 degrees moving clockwise (more or less depending the number of photographs needed each 360 degree turn)


The motor does it with the current code below, but I have an issue with jerks at start and stop between each step.


I will appreciate some help as I don't seem to be getting anywhere.


Thanks in advance!

Burt

here's the code -


Code: [Select]
// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
 
void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction
  // Makes pulses for making one full cycle rotation
  for(int x = 0; x < 6; x++)
  {
    analogWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(5000); // five second delay
}

groundFungus

Have you tried micostepping the motor?  Steps can be much smaller, that might reduce the swinging.

movingforever

Thanks. it is the motion between steps. Starts with a jerk that makes the product swing too much and photo becomes blurry

groundFungus

The AccelStepper library can use acceleration.  So the motion from start to speed and speed to stop is much smoother.  Not so much jerking.

Robin2

From the Original Post ...
Code: [Select]
analogWrite(stepPin,HIGH);

That should be digitalWrite()

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

MarkT

You almost certainly want acceleration/ramping with a NEMA17 motor, you always do with larger
steppers, I'd advise learning the AccelStepper library, its pretty flexible and does the tedious stuff
for you.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up