# Driving Linear Actuator

**URL:** <https://forum.arduino.cc/t/driving-linear-actuator/1149918>\
**Category:** Programming\
**Created:** [July 20, 2023, 7:36am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918 "2023-07-20T07:36:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 7:36am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/1 "2023-07-20T07:36:40Z")

</div>

I am trying to drive a linear actuator using an Arduino Uno and DFRobot Motor Shield, [TMC260\_Stepper\_Motor\_Driver\_Shield\_SKU\_\_DRI0035-DFRobot](https://wiki.dfrobot.com/TMC260_Stepper_Motor_Driver_Shield_SKU__DRI0035#target_4) , and when i run the programme, the StallGuard LED on the board turns on and the linear actuator pulses and gets hot very quickly. Does anyone have any suggestions to make this work?

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/4/a/6/4a65cee53fca2d62c6138b82ca7177d94a088334.png)

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/5/0/d/50db49b759049ec97aa593a903e57f7bff533808.png)

This is trialling the 2 sample programmes on the motor shield website.

Thank you.

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [July 20, 2023, 7:37am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/2 "2023-07-20T07:37:55Z")

</div>

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'  
  
Use **code tags** (the \< CODE/ \> icon above the compose window)&nbsp;to make it easier to read and copy for examination   
  
[https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum)

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 7:45am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/3 "2023-07-20T07:45:39Z")

</div>

```arduino
#include <SPI.h>
#include <TMC26XStepper.h>

//we have a stepper motor with 20 steps per rotation,CS pin 6, dir pin 4, step pin 5 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(20,6,4,5,800);
void setup() 
{
    Serial.begin(9600);
    Serial.println("==============================");
    Serial.println("TMC26X Stepper Driver Demo App");
    Serial.println("==============================");
    //set this according to you stepper
    Serial.println("Configuring stepper driver");
    //char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement
    tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
    tmc26XStepper.setRandomOffTime(0);
    tmc26XStepper.SPI_setCoilCurrent(500);
    tmc26XStepper.setMicrosteps(128);
    tmc26XStepper.setStallGuardThreshold(100,0);
    Serial.println("config finished, starting");
    Serial.println("started");

      tmc26XStepper.SPI_setSpeed(50); //Set speed at 80 RPM
      tmc26XStepper.SPI_step(20); //set step at -200 steps, that is to say stepper will turn a circle reverse
      tmc26XStepper.spi_start() ; //start stepper
      delay(4000); //delay 2s

      tmc26XStepper.SPI_step(20); // set step at 200 steps, stepper will turn a circle forward
      tmc26XStepper.spi_start() ;
      delay(4000);

      tmc26XStepper.SPI_setSpeed(50); // Set speed at 100 RPM
   tmc26XStepper.SPI_step(-40); // stepper will turn 1.5 circles reverse
      tmc26XStepper.spi_start() ;
      delay(4000);

     tmc26XStepper.SPI_setSpeed(120); // Set speed at 120 RPM
     tmc26XStepper.SPI_step(40); // stepper will turn 2 circles forward
     tmc26XStepper.spi_start() ;
     delay(4000);
}

void loop() {
  // put your main code here, to run repeatedly:

}

```

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 7:46am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/4 "2023-07-20T07:46:26Z")

</div>

```arduino
#include <SPI.h>
#include <TMC26XStepper.h>

//we have a stepper motor with 20 steps per rotation, CS pin 2, dir pin 6, step pin 7 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(20,6,4,5,800);
int curr_step;
int speed = 0;
int speedDirection = -100;
int maxSpeed = 1000;

void setup() {
  Serial.begin(9600);
  Serial.println("==============================");
  Serial.println("TMC26X Stepper Driver Demo App");
  Serial.println("==============================");
  //set this according to you stepper
  Serial.println("Configuring stepper driver");
  //char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement
  tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
  tmc26XStepper.setRandomOffTime(0);

  tmc26XStepper.setMicrosteps(128);
  tmc26XStepper.setStallGuardThreshold(60,0);
  Serial.println("config finished, starting");
  Serial.println("started");

}

void loop() {
  if (!tmc26XStepper.isMoving()) {
    speed+=speedDirection;
    if (speed>maxSpeed) {
      speed = maxSpeed;
      speedDirection = -speedDirection;
    } else if (speed<0) {
      speedDirection = -speedDirection;
      speed=speedDirection;
    }
    //setting the speed
    Serial.print("setting speed to ");
    Serial.println(speed);
    tmc26XStepper.setSpeed(speed);
    //we want some kind of constant running time - so the length is just a product of speed
    Serial.print("Going ");
    Serial.print(10*speed);
    Serial.println(" steps");
    tmc26XStepper.step(10*speed);
  } else {
    //we put out the status every 100 steps
    if (tmc26XStepper.getStepsLeft()%100==0) {
      Serial.print("Stall Guard: ");
      Serial.println(tmc26XStepper.getCurrentStallGuardReading());
    }
  }
  tmc26XStepper.move();
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [July 20, 2023, 7:47am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/5 "2023-07-20T07:47:27Z")

</div>

Thank you

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [July 20, 2023, 8:45am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/6 "2023-07-20T08:45:17Z")

</div>

> [@con2309](#):
>
> Does anyone have any suggestions to make this work?

No.

Please give a link to your specific actuator (data sheet).

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 9:09am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/7 "2023-07-20T09:09:04Z")

</div>

![image](https://europe1.discourse-cdn.com/arduino/original/4X/c/c/1/cc13b3cfcf892c0c2f2033730ac20956db2d2bc2.png)

These are the only details I have.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [July 20, 2023, 9:23am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/8 "2023-07-20T09:23:31Z")

</div>

why are there 2 different programs posted in post #3 and #4?

> [@con2309](#):
>
> and the linear actuator pulses and gets hot very quickly.

is it being driven past its endpoint instead of being stopped?

is the motor being driven with the correct voltage? what is that voltage?

> [@con2309](#):
>
> Does anyone have any suggestions to make this work?

what do you expect it to do? what does it do?

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [July 20, 2023, 10:03am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/9 "2023-07-20T10:03:39Z")

</div>

> [@con2309](#):
>
> These are the only details I have.

A stepper motor is **not** a linear actuator.

If it is that stepper motor then configure your driver to the indicated phase current of 500mA. This will give a motor power consumption of 10W and consequential heat.

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 10:16am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/10 "2023-07-20T10:16:39Z")

</div>

Thank you, I have got the shaft moving now however as the shaft is moving the stallguard LED is flashing still when it couldnt have stalled due to being able to move and not at its end. Is this something to do with the stallguard threshold?

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [July 20, 2023, 10:23am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/11 "2023-07-20T10:23:52Z")

</div>

> [@con2309](#):
>
> however as the shaft is moving the stallguard LED is flashing still when it couldnt have stalled due to being able to move and not at its end.

is the voltage too low to move the actuator?

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 10:51am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/12 "2023-07-20T10:51:31Z")

</div>

It shouldn't be as it is actually driving.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [July 20, 2023, 10:54am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/13 "2023-07-20T10:54:01Z")

</div>

> [@con2309](#):
>
> It shouldn't be as it is actually driving.

are you saying that just because it moves it must be sufficient voltage?

didn't you say ...

> [@con2309](#):
>
> however as the shaft is moving the stallguard LED is flashing still when it couldnt have stalled due to being able to move and not at its end.

what is the required votlage?

what is the actuator model # so we can look it up? (not the driver board)

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [July 20, 2023, 11:17am UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/14 "2023-07-20T11:17:27Z")

</div>

> [@con2309](#):
>
> the stallguard LED is flashing

That's normal with more than 5V PSU.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [July 20, 2023, 12:26pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/15 "2023-07-20T12:26:55Z")

</div>

> [@DrDiettrich](#):
>
> 5V PSU

what is PSU?

what does the "stall" like mean?

why would it be active above some voltage?

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [July 20, 2023, 12:31pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/16 "2023-07-20T12:31:13Z")

</div>

> [@gcjr](#):
>
> what is PSU?

Power Supply Unit

> [@gcjr](#):
>
> what does the "stall" like mean?

Maximum current exceeded, typically because a DC motor is blocked from turning freely.

> [@gcjr](#):
>
> active above some voltage

Higher voltage would cause more current on the given coil resistance.

---

<div class="post-metadata">

**Author:** ![con2309](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@con2309](https://forum.arduino.cc/u/con2309)\
**Post date:** [July 20, 2023, 1:18pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/17 "2023-07-20T13:18:01Z")

</div>

why is this? I dont understand the stall guard threshold either?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [July 20, 2023, 1:47pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/18 "2023-07-20T13:47:27Z")

</div>

> [@con2309](#):
>
> I dont understand the stall guard threshold either?

It is difficult to detect stall conditions with stepper motors, and the threshold usually needs to be tuned for a specific motor. Perhaps the driver is not a good match for the motor you have chosen.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [July 20, 2023, 5:21pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/19 "2023-07-20T17:21:04Z")

</div>

i'm curious, how would you detect stall on a stepper motor?

on a DC motor, the max current is the supply voltage divided by the winding resistance. this should never occur unless the motor stops turning because BEMF would reduce the effect voltage across the winding

wouldn't the max current on a stepper motor be the voltage divided by the coil resistance. there is no BEMF except while it stepping. that current wouldn't be any greater if it hasn't reached the target position, would it?

so what does the stall light mean?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 16, 2024, 5:21pm UTC](https://forum.arduino.cc/t/driving-linear-actuator/1149918/20 "2024-01-16T17:21:34Z")

</div>

Closed on January 16, 2024, 5:21pm UTC

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