Sine wave trajectory stepper motor with Pololu Tic T825

Dear Forum,

I am trying to achieve a sine position movement with the Pololu Tic T825 stepper motor driver.
Which is the best way to achieve this? Now i am talking to the driver with an Arduino Mega 2560 via Serial Communication.

Should I loop over positions (with the Arduino) the stepper motor has to achieve? Therefore I think I should change to Teensy, because I does not get a smooth movement.

Or should I change the acceleration and speed within an while loop to get the desired maximal distance?

Or is the serial communication not the right choice and I should communicate via Step/Dir or else?

Thank you,
husneck

What have You achieved so far?

Please post your entire sketch, in code tags please.

Yes.
However, with a sin wave motion you have two choices:-

  1. To send the pulses at regular intervals and change the number of pulses you send in each interval.
  2. To send a single pulses but to vary the interval at which the pulse is sent.

Either way you should probably use a look up table of pre calculated settings rather than trying to calculate them on the fly.

In general if you have position as a function of time you can convert this to step pulses by repeatedly calculating the current intended number of steps and comparing to actual step position:

void loop ()
{
  static int current_position = 0 ;
  int intended_position = int (round (40 * sin (millis() / 1000.0)) ;  // or whatever function you want
  while (intended_position != current_position)  // check if a step is due
  {
    bool direction = intended_position > current_position ;  // determine direction
    digitalWrite (direction_pin, direction) ;
    digitalWrite (step_pin, HIGH) ;  // pulse one step
    delayMicroseconds (10) ;
    digitalWrite (step_pin, LOW) ;
    current_position += direction ? +1 : -1 ;  // update current position
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.