Arduino - Actuador con retroalimentación

En un tutorial anterior, aprendimos sobre el actuador lineal sin retroalimentación. En este tutorial, vamos a aprender sobre el actuador lineal con retroalimentación (también llamado actuador lineal de retroalimentación). La retroalimentación del actuador lineal da la información para identificar la posición de su vástago y luego controlar esa posición. En detalle, vamos a aprender:

Acerca del actuador lineal con retroalimentación

Un actuador lineal con retroalimentación es un actuador lineal que tiene una señal de retroalimentación que permite identificar su posición y controlarla. La retroalimentación es un potenciómetro que entrega un valor de voltaje proporcional a la posición del vástago.

Pinout del actuador lineal con retroalimentación

Un actuador lineal con retroalimentación tiene 5 cables:

  • Cable positivo del actuador: este cable se usa para controlar el actuador lineal con un voltaje alto (12V, 24V, 48V...).
  • Cable negativo del actuador: este cable se usa para controlar el actuador lineal con un voltaje alto (12V, 24V, 48V...).
  • Cable de 5V: este cable se usa para el potenciómetro de retroalimentación. Conecta este cable a 5V o 3.3V
  • Cable GND: este cable se usa para el potenciómetro de retroalimentación. Conecta este cable a GND
  • Cable del potenciómetro: (también llamado cable de retroalimentación o cable de salida) este cable entrega un valor de voltaje proporcional a la posición del vástago.
Pinout del actuador lineal con retroalimentación

Cómo funciona

Si aplicamos un voltaje alto a los cables positivo y negativo, el vástago del actuador se extenderá o se retraerá. En detalle, si conectamos:

  • 12V (12V, 24V, 48V...) y GND al cable positivo y al cable negativo, respectivamente: el actuador lineal se extiende a toda velocidad hasta llegar al límite.
  • 12V (12V, 24V, 48V...) y GND al cable negativo y al cable positivo, respectivamente: el actuador lineal se retrae a toda velocidad hasta llegar al límite.
  • Mientras se extiende o se retrae, si dejamos de alimentar el actuador (GND en los dos cables, positivo y negativo), el actuador deja de extenderse/retraerse

※ Nota:

  • El valor de voltaje para controlar el actuador depende de las especificaciones del actuador. Lee la hoja de datos o el manual para conocer el valor de voltaje correspondiente.
  • El actuador puede mantener la posición incluso cuando deja de recibir energía mientras lleva una carga.

El valor de voltaje en el cable del potenciómetro es proporcional a la posición del vástago del actuador. Al medir este voltaje, podemos saber la posición del vástago.

Diagrama de cableado

Los dos cables de potencia del actuador los maneja un módulo BTS7960. Este controlador tiene un puente H potente. RPWM hace salir el vástago, LPWM lo hace entrar, y R_EN y L_EN deben estar en HIGH para encender el controlador. Los 12V para el actuador entran por los terminales de tornillo B+ y B-, y los cables del actuador van a M+ y M-. Los tres cables pequeños del potenciómetro van directamente a Arduino.

Pinout del controlador BTS7960
Diagrama de cableado de Arduino, actuador lineal con retroalimentación y controlador BTS7960

This image is created using Fritzing. Click to enlarge image

Desde Hacia
RPWM del BTS7960 Pin 9 de Arduino
LPWM del BTS7960 Pin 10 de Arduino
R_EN del BTS7960 Pin 12 de Arduino
L_EN del BTS7960 Pin 11 de Arduino
VCC del BTS7960 5V de Arduino
GND del BTS7960 GND de Arduino
B+, B- del BTS7960 + y - del adaptador de corriente de 12V (a través del conector de alimentación DC)
M+, M- del BTS7960 los cables positivo y negativo del actuador
Cable 5V del actuador 5V de Arduino
Cable GND del actuador GND de Arduino
Cable del potenciómetro del actuador Pin A0 de Arduino

Ahora el pin 5V y el pin GND de Arduino alimentan dos cables cada uno. Un Screw Shield V2 o un Proto Screw Terminal Block Shield sobre el Arduino Uno lo hace fácil: cada terminal de tornillo sujeta firmemente los cables de su pin. El cableado es el mismo que arriba.

Diagrama de cableado de Arduino, actuador lineal con retroalimentación y controlador BTS7960 con Screw Shield

This image is created using Fritzing. Click to enlarge image

Cómo controlar la extensión/retracción de un actuador lineal

Consulta el tutorial Arduino - Actuador

Cómo encontrar la posición del actuador lineal

A continuación se muestra cómo identificar la posición del vástago en un actuador lineal.

Calibración

  • Identifica la longitud del recorrido del actuador (en milímetros) midiéndola (con una regla) o leyendo la hoja de datos
  • Identifica los valores de salida cuando el actuador lineal está totalmente extendido y totalmente retraído, ejecutando el siguiente código
/* * Este código de Arduino fue desarrollado por es.newbiely.com * Este código de Arduino se proporciona al público sin ninguna restricción. * Para tutoriales completos y diagramas de cableado, visite: * https://es.newbiely.com/tutorials/arduino/arduino-actuator-with-feedback */ // the code for getting the feedback when the actuator fully extended and retracted #define RPWM_PIN 9 // the Arduino pin connected to the RPWM pin of BTS7960 (extend) #define LPWM_PIN 10 // the Arduino pin connected to the LPWM pin of BTS7960 (retract) #define R_EN_PIN 12 // the Arduino pin connected to the R_EN pin of BTS7960 #define L_EN_PIN 11 // the Arduino pin connected to the L_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // the Arduino 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); // no power to the actuator yet, then turn on the driver analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); digitalWrite(R_EN_PIN, HIGH); digitalWrite(L_EN_PIN, HIGH); } void loop() { // extend the actuator 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 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); }
  • Verás el registro en el Monitor Serie como en el siguiente ejemplo
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
POTENTIOMETER_MAX = 987 POTENTIOMETER_MIN = 13
Ln 11, Col 1
Arduino Uno on COM15
2
  • Anota estos valores
  • Si los valores mínimo y máximo están invertidos, intercambia RPWM_PIN y LPWM_PIN en el código (o intercambia los cables M+ y M-)
  • Actualiza los tres valores en el siguiente código
  • Código de Arduino que calcula la posición del actuador

    /* * Este código de Arduino fue desarrollado por es.newbiely.com * Este código de Arduino se proporciona al público sin ninguna restricción. * Para tutoriales completos y diagramas de cableado, visite: * https://es.newbiely.com/tutorials/arduino/arduino-actuator-with-feedback */ #define RPWM_PIN 9 // the Arduino pin connected to the RPWM pin of BTS7960 (extend) #define LPWM_PIN 10 // the Arduino pin connected to the LPWM pin of BTS7960 (retract) #define R_EN_PIN 12 // the Arduino pin connected to the R_EN pin of BTS7960 #define L_EN_PIN 11 // the Arduino pin connected to the L_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // the Arduino 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); // no power to the actuator yet, then turn on the driver analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); digitalWrite(R_EN_PIN, HIGH); digitalWrite(L_EN_PIN, HIGH); } void loop() { // extend the actuator 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"); }
    • Actualiza los tres valores calibrados en el código
    • Sube el código a Arduino
    • Mira el resultado en el Monitor Serie
    ∞
    Newbiely | Arduino IDE 2.3.8
    ──
    ☐
    ✕
    File
    Edit
    Sketch
    Tools
    Help
    Arduino Uno
    Newbiely.ino
    ···
    8 Serial.println("Hello World!");
    Output
    Serial Monitor
    Message (Enter to send message to 'Arduino Uno' 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 Uno on COM15
    2

    Cómo controlar un actuador lineal para llevarlo a una posición específica

    /* * Este código de Arduino fue desarrollado por es.newbiely.com * Este código de Arduino se proporciona al público sin ninguna restricción. * Para tutoriales completos y diagramas de cableado, visite: * https://es.newbiely.com/tutorials/arduino/arduino-actuator-with-feedback */ #define RPWM_PIN 9 // the Arduino pin connected to the RPWM pin of BTS7960 (extend) #define LPWM_PIN 10 // the Arduino pin connected to the LPWM pin of BTS7960 (retract) #define R_EN_PIN 12 // the Arduino pin connected to the R_EN pin of BTS7960 #define L_EN_PIN 11 // the Arduino pin connected to the L_EN pin of BTS7960 #define POTENTIOMETER_PIN A0 // the Arduino 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); // no power to the actuator yet, then turn on the driver ACTUATOR_stop(); 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: PWM on RPWM, LPWM is 0 void ACTUATOR_extend() { analogWrite(LPWM_PIN, 0); analogWrite(RPWM_PIN, 255); } // retract: PWM on LPWM, RPWM is 0 void ACTUATOR_retract() { analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 255); } // stop (brake): RPWM and LPWM are 0 void ACTUATOR_stop() { analogWrite(RPWM_PIN, 0); analogWrite(LPWM_PIN, 0); }

    Video Tutorial

    Estamos considerando crear tutoriales en video. Si considera que los tutoriales en video son importantes, suscríbase a nuestro canal de YouTube para motivarnos a crear los videos.

    Referencias de funciones

    Tutoriales Relacionados

    ※ NUESTROS MENSAJES

    • No dude en compartir el enlace de este tutorial. Sin embargo, por favor no use nuestro contenido en otros sitios web. Hemos invertido mucho esfuerzo y tiempo en crear el contenido, ¡por favor respete nuestro trabajo!