Stepper Jump Problem

Hello there,
Code works fine,
It's just bouncing when the engine changes direction. What can we do to make it not jump?

How to change the code to avoid jumping.

https://forum.arduino.cc/index.php?topic=484884.0

#include <lib_dmx.h>  // comment/uncomment #define USE_UARTx in lib_dmx.h as needed
#include <AccelStepper.h>

#define    DMX512     (0)    // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512

// Define a stepper and the pins it will use

AccelStepper stepper (AccelStepper::FULL4WIRE, 8, 9, 10, 11);

void setup()

{  
  ArduinoDmx0.set_control_pin(2);     // Arduino output pin for MAX485 input/output control (connect to MAX485 pins 2-3) 
  ArduinoDmx0.set_rx_address(1);      // set rx0 dmx start address
  ArduinoDmx0.set_rx_channels(3);     // number of rx channels
  ArduinoDmx0.init_rx(DMX512);        // starts universe 0 as rx, NEW Parameter DMX mode 
  
  stepper.setMaxSpeed(1000);
  
}

void loop()
{

  unsigned int posicion = ArduinoDmx0.RxBuffer[0] << 8;
  posicion |= ArduinoDmx0.RxBuffer[1];
  posicion = map(posicion, 0, 65535, 0, 4000);
  stepper.moveTo(posicion);
  
  unsigned int velocidad;
  velocidad = map(ArduinoDmx0.RxBuffer[2], 0, 255, 0, 900);
  stepper.setSpeed(velocidad);
  stepper.runSpeedToPosition();

}

Did not study your code, but easier to ask! Did you STOP the motor before reversing directions?

Paul

Paul_KD7HB:
Did not study your code, but easier to ask! Did you STOP the motor before reversing directions?

Paul

Paul hi,

No, I'm changing the faders in the opposite direction without stopping the engine. It's jumping when I do.

When I want the engine to move in the opposite direction, I want it to slow down without jumping.

Okaliptus:
I want it to slow down without jumping.

You are using runSpeedToPosition() which does not use acceleration.

I'm changing the faders in the opposite direction without stopping the engine.

Are you changing the direction before the motor gets to the intended position?

If you use the run() function with a large number of steps and then call stop() before it gets to its destination it will slow to a stop with deceleration in the shortest time possible depending on your chosen acceleration rate.

...R

Robin2:
You are using runSpeedToPosition() which does not use acceleration.
Are you changing the direction before the motor gets to the intended position?

If you use the run() function with a large number of steps and then call stop() before it gets to its destination it will slow to a stop with deceleration in the shortest time possible depending on your chosen acceleration rate.

...R

Yes, I change the motor before it reaches the desired position.

I don't know how to do that, please, can you teach me on the code?

Thanks

Okaliptus:
I don't know how to do that, please, can you teach me on the code?

Start by studying the AccelStepper examples that use the run() function. Note how run() has to be called very frequently.

...R

Robin2:
Start by studying the AccelStepper examples that use the run() function. Note how run() has to be called very frequently.

...R

Thanks for the attention,
Can you give me an example on my code. I'm not good at programming.

Okaliptus:
Can you give me an example on my code. I'm not good at programming.

Have you tried the AccelStepper examples like I suggested?

Or do you just plan to sit on your hands and expect me to do all the work?

If there is something about the examples that you don't understand then tell us exactly what it is and we will try to help.

...R

Call setSpeed before calling moveTo.