SparkFun Forums 

Where electronics enthusiasts find answers.

By mayankvanani
#202078
Hi,

I am new to this community.
So, I am using L6470 stepper driver for my project.
I wanted to ask that in the, does the `run` command in SparkFunAutoDriverCommands.cpp use ACC/DEC registers (use acc/dec curves) to get to the specified speed or it gets to the specified speed with indefinite acceleration/deceleration ?
Code: Select all
// RUN sets the motor spinning in a direction (defined by the constants
//  FWD and REV). Maximum speed and minimum speed are defined
//  by the MAX_SPEED and MIN_SPEED registers; exceeding the FS_SPD value
//  will switch the device into full-step mode.
// The spdCalc() function is provided to convert steps/s values into
//  appropriate integer values for this function.
void AutoDriver::run(byte dir, float stepsPerSec)
{
  SPIXfer(RUN | dir);
  unsigned long integerSpeed = spdCalc(stepsPerSec);
  if (integerSpeed > 0xFFFFF) integerSpeed = 0xFFFFF;
  
  // Now we need to push this value out to the dSPIN. The 32-bit value is
  //  stored in memory in little-endian format, but the dSPIN expects a
  //  big-endian output, so we need to reverse the byte-order of the
  //  data as we're sending it out. Note that only 3 of the 4 bytes are
  //  valid here.
  
  // We begin by pointing bytePointer at the first byte in integerSpeed.
  byte* bytePointer = (byte*)&integerSpeed;
  // Next, we'll iterate through a for loop, indexing across the bytes in
  //  integerSpeed starting with byte 2 and ending with byte 0.
  for (int8_t i = 2; i >= 0; i--)
  {
    SPIXfer(bytePointer[i]);
  }
}