Arduino Nano - Feedback Actuator

In a prior tutorial, we discussed the linear actuator without feedback. Now, we will be exploring the feedback linear actuator (also known as the feedback linear actuator). This type of actuator provides information to determine the position of its stroke and then control it. Specifically, we will be looking at:

Arduino Nano controls a 12V feedback linear actuator with the BTS7960 motor driver

Hardware Preparation

1×Official Arduino Nano
1×Alternatively, DIYables Nano V3.0 Development Board
1×USB A to Mini-B USB cable
1×12V Linear Feedback Actuator
1×BTS7960 Motor Driver Module
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Breadboard
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Feedback Linear Actuator

A linear actuator with feedback is available, which provides a signal to identify its position and control it. This feedback is in the form of a potentiometer that outputs a voltage value that is proportional to the stroke's position.

Feedback Linear Actuator Pinout

A Feedback Linear Actuator has 5 wires:

  • Actuator Positive wire: This wire is used to control the linear actuator by utilizing high voltage (12V, 24V, 48V...).
  • Actuator Negative wire: This wire is used to control the linear actuator by utilizing high voltage (12V, 24V, 48V...).
  • 5V wire: this wire is used for the feedback potentiometer. Connect this wire to 5V or 3.3V
  • GND wire: this wire is used for the feedback potentiometer. Connect this wire to GND
  • Potentiometer wire: (also called feedback wire, or output wire) this wire outputs the voltage value in proportion to the stroke's position.
Feedback Linear Actuator pinout

How It Works

If we supply high voltage to the positive and negative wires, the stroke of the actuator will be extended or retracted. Specifically:

  • If 12V (12V, 24V, 48V...) is connected to the positive wire and GND to the negative wire, the linear actuator will extend at full speed until it reaches the limit.
  • If 12V (12V, 24V, 48V...) is connected to the negative wire and GND to the positive wire, the linear actuator will retract at full speed until it reaches the limit.
  • If power is stopped to the actuator (GND to both positive and negative wire), the actuator will cease extending/retracting.

※ NOTE THAT:

  • The voltage necessary for operating the actuator is determined by its specifications. To find out the exact voltage value, consult the datasheet or manual.
  • Even when power is cut off, the actuator can maintain its position while carrying a load.

The voltage in the potentiometer wire is related to the stroke's position on the actuator. By measuring this voltage, we can determine the stroke's position.

Wiring Diagram

The two power wires of the actuator go to a BTS7960 motor driver. This driver has one strong H-bridge, works with 5.5V to 27V on its B+ / B- terminals and can take up to 43A at the peak. That matters, because an actuator draws a big current when it starts and when it stops at the end of its stroke. The three small feedback wires go straight to the Arduino Nano.

BTS7960 Motor Driver Pinout

Keep the 12V adapter unplugged while you connect the wires.

The wiring diagram between Arduino Nano and Feedback Linear Actuator BTS7960 Driver

This image is created using Fritzing. Click to enlarge image

From Connect To
BTS7960 RPWM Arduino Nano D9
BTS7960 LPWM Arduino Nano D10
BTS7960 R_EN Arduino Nano D12
BTS7960 L_EN Arduino Nano D11
BTS7960 VCC Arduino Nano 5V
BTS7960 GND Arduino Nano GND
BTS7960 B+, B- + and - of the 12V power adapter (via the DC power jack)
BTS7960 M+, M- actuator positive and negative wires
Actuator 5V wire Arduino Nano 5V
Actuator GND wire Arduino Nano GND
Actuator potentiometer wire Arduino Nano A0

You can also mount the Arduino Nano on a Screw Terminal Expansion Board for Arduino Nano. Each wire then sits under its own screw, which is safer than a jumper wire on a moving machine. The drawing below shows how:

The wiring diagram between Arduino Nano and Feedback Linear Actuator BTS7960 Driver Screw Terminal

This image is created using Fritzing. Click to enlarge image

See The best way to supply power to the Arduino Nano and other components.

How to control extend/retract a linear actuator

Check out the tutorial on Arduino Nano - Actuator.

In short, with R_EN and L_EN HIGH: a PWM value on RPWM (and 0 on LPWM) extends the actuator, a PWM value on LPWM (and 0 on RPWM) retracts it, and 0 on both stops it.

How to find the position of the linear actuator

This is an example of how to locate the stroke on a linear actuator. It provides an illustration of the process.

Calibration

  • Determine the length of the actuator's stroke (in millimeters) by either measuring it with a ruler or consulting the datasheet.
  • Run the following code to determine the output values when the linear actuator is fully extended and fully retracted.
/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-feedback-actuator */ // The code for getting the feedback when the actuator fully extended and retracted #define RPWM_PIN 9 // The Arduino Nano pin connected to the RPWM pin of BTS7960 #define LPWM_PIN 10 // The Arduino Nano pin connected to the LPWM pin of BTS7960 #define L_EN_PIN 11 // The Arduino Nano pin connected to the L_EN pin of BTS7960 #define R_EN_PIN 12 // The Arduino Nano pin connected to the R_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // The Arduino Nano pin connected to the potentiometer of the actuator void setup() { Serial.begin(9600); // initialize digital pins as outputs. pinMode(RPWM_PIN, OUTPUT); pinMode(LPWM_PIN, OUTPUT); pinMode(R_EN_PIN, OUTPUT); pinMode(L_EN_PIN, OUTPUT); // both PWM pins at 0, then turn the driver on analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); digitalWrite(R_EN_PIN, HIGH); digitalWrite(L_EN_PIN, HIGH); } void loop() { // extend the actuator at full speed analogWrite(LPWM_PIN, 0); analogWrite(RPWM_PIN, 255); delay(20000); // wait for actuator fully extends. It will stop extending automatically when reaching the limit // read the analog in value: int POTENTIOMETER_MAX = analogRead(POTENTIOMETER_PIN); Serial.print("POTENTIOMETER_MAX = "); Serial.println(POTENTIOMETER_MAX); // retract the actuator at full speed analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 255); delay(20000); // wait for actuator fully retracts. It will stop retracting automatically when reaching the limit int POTENTIOMETER_MIN = analogRead(POTENTIOMETER_PIN); Serial.print("POTENTIOMETER_MIN = "); Serial.println(POTENTIOMETER_MIN); }
  • Observe the log on the Serial Monitor as demonstrated in the example below.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Nano
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano' on 'COM15')
New Line
9600 baud
POTENTIOMETER_MAX = 987 POTENTIOMETER_MIN = 13
Ln 11, Col 1
Arduino Nano on COM15
2

Make a note of the following three values and update them in the code below: the minimum value, the maximum value, and RPWM_PIN and LPWM_PIN. If the minimum and maximum values are swapped, also swap RPWM_PIN and LPWM_PIN.

Arduino Nano code that calculate the position of the actuator

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-feedback-actuator */ #define RPWM_PIN 9 // The Arduino Nano pin connected to the RPWM pin of BTS7960 #define LPWM_PIN 10 // The Arduino Nano pin connected to the LPWM pin of BTS7960 #define L_EN_PIN 11 // The Arduino Nano pin connected to the L_EN pin of BTS7960 #define R_EN_PIN 12 // The Arduino Nano pin connected to the R_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // The Arduino Nano pin connected to the potentiometer of the actuator #define STROKE_LENGTH 102 // PLEASE UPDATE THIS VALUE (in millimeter) #define POTENTIOMETER_MAX 987 // PLEASE UPDATE THIS VALUE #define POTENTIOMETER_MIN 13 // PLEASE UPDATE THIS VALUE void setup() { Serial.begin(9600); // initialize digital pins as outputs. pinMode(RPWM_PIN, OUTPUT); pinMode(LPWM_PIN, OUTPUT); pinMode(R_EN_PIN, OUTPUT); pinMode(L_EN_PIN, OUTPUT); // both PWM pins at 0, then turn the driver on analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); digitalWrite(R_EN_PIN, HIGH); digitalWrite(L_EN_PIN, HIGH); } void loop() { // extend the actuator at full speed analogWrite(LPWM_PIN, 0); analogWrite(RPWM_PIN, 255); int potentiometer_value = analogRead(POTENTIOMETER_PIN); int stroke_pos = map(potentiometer_value, POTENTIOMETER_MIN, POTENTIOMETER_MAX, 0, STROKE_LENGTH); Serial.print("The stroke's position = "); Serial.print(stroke_pos); Serial.println(" mm"); }
  • Refresh the three calibrated values in the code
  • Transfer the code to Arduino Nano
  • Check the outcome on Serial Monitor
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Nano
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano' on 'COM15')
New Line
9600 baud
The stroke's position = 2 mm The stroke's position = 35 mm The stroke's position = 43 mm The stroke's position = 60 mm The stroke's position = 68 mm The stroke's position = 79 mm The stroke's position = 83 mm The stroke's position = 96 mm The stroke's position = 100 mm
Ln 11, Col 1
Arduino Nano on COM15
2

How to control a linear actuator to a specific position

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-feedback-actuator */ #define RPWM_PIN 9 // The Arduino Nano pin connected to the RPWM pin of BTS7960 #define LPWM_PIN 10 // The Arduino Nano pin connected to the LPWM pin of BTS7960 #define L_EN_PIN 11 // The Arduino Nano pin connected to the L_EN pin of BTS7960 #define R_EN_PIN 12 // The Arduino Nano pin connected to the R_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // The Arduino Nano pin connected to the potentiometer of the actuator #define STROKE_LENGTH 102 // PLEASE UPDATE THIS VALUE (in millimeter) #define POTENTIOMETER_MAX 987 // PLEASE UPDATE THIS VALUE #define POTENTIOMETER_MIN 13 // PLEASE UPDATE THIS VALUE #define TOLERANCE 5 // in millimeter int targetPosition_mm = 50; // in millimeter void setup() { Serial.begin(9600); // initialize digital pins as outputs. pinMode(RPWM_PIN, OUTPUT); pinMode(LPWM_PIN, OUTPUT); pinMode(R_EN_PIN, OUTPUT); pinMode(L_EN_PIN, OUTPUT); // both PWM pins at 0, then turn the driver on analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); digitalWrite(R_EN_PIN, HIGH); digitalWrite(L_EN_PIN, HIGH); } void loop() { int potentiometer_value = analogRead(POTENTIOMETER_PIN); int stroke_pos = map(potentiometer_value, POTENTIOMETER_MIN, POTENTIOMETER_MAX, 0, STROKE_LENGTH); Serial.print("The stroke's position = "); Serial.print(stroke_pos); Serial.println(" mm"); if (stroke_pos < (targetPosition_mm - TOLERANCE)) ACTUATOR_extend(); else if (stroke_pos > (targetPosition_mm + TOLERANCE)) ACTUATOR_retract(); else ACTUATOR_stop(); } // extend: LPWM = 0, PWM on RPWM void ACTUATOR_extend() { analogWrite(LPWM_PIN, 0); analogWrite(RPWM_PIN, 255); } // retract: RPWM = 0, PWM on LPWM void ACTUATOR_retract() { analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 255); } // stop (brake): both PWM pins = 0 void ACTUATOR_stop() { analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); }

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!