Call us Now - 0034 938 760 191

Servomotor con PLC basado en Arduino

18 de octubre de 2024 por
Servomotor con PLC basado en Arduino
Bernat Garcia

Introducción

En este post controlaremos la velocidad de un servomotor 57HSE2N-D25. Para ello también necesitaremos un controlador, HSS57 Hybrid Servo Driver,para el servomotor que se conectará a nuestro PLC basado en Arduino para la automatización del control de velocidad. Para el software, se implementa una libreria pulses.h (el software sin usar la libreria pulses.h también está conectado).

Requisitos

Conexiones


Servo Motor - Driver connections:

Red     ->       A+
Green      ->       A-
Yellow   ->       B+
Blue  ->       B-

Ethernet PLC - Driver connections: 

PIN 3   ->  PUL - (pulses)      
PIN2    ->  DIR- (rotational direction)
PIN 50 (MISO)  ->  ENA- (enable)                     
GND    -> PUL- , DIR - , ENA -

* Signals = 5Vdc

Servo Motor with Arduino based PLC Connections


*Recuerde alimentar el PLC entre 12 y 24V.

*En este caso estamos utilizando señal de 5V, por lo que, no se necesitan resistencias entre PUL+,ENA+, DIR+ y PIN2, PIN3, PIN50.

*El controlador es M-Duino 21+

*Codificador en no utilizado en este post


Software

Con este codigo puedes controlar la velocidad del paso a paso, la dirección y el número de revoluciones.

Cambie PIN2 para controlar la dirección, cambie NUM_REVOLUTIONS para decidir cuántas revoluciones necesita y cambie FREQ para cambiar la frecuencia(velocidad de rotación).

A continuación se muestra el código:

/*
   Copyright (c) 2018 Boot&Work Corp., S.L. All rights reserved
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.
   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <Pulses.h>

#define PIN_STEPPER_PUL 3
#define PIN_STEPPER_DIR 2
#define PIN_STEPPER_ENA 50
#define STEPPER_PULSES_PER_REV 1600UL
#define FREQ (2000UL) // Hz
#define NUM_REVOLUTIONS 10
#define STEPPER_STEPS ((NUM_REVOLUTIONS) * (STEPPER_PULSES_PER_REV))
 
volatile uint32_t stepsCnt = STEPPER_STEPS;
ISR(TIMER3_COMPA_vect) {
  if (stepsCnt) {
    --stepsCnt;
    if (stepsCnt == 0UL) {
      stopPulses(PIN_STEPPER_PUL);
    }
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  pinMode(PIN_STEPPER_DIR, OUTPUT);
  pinMode(PIN_STEPPER_PUL, OUTPUT);
  pinMode(PIN_STEPPER_ENA, OUTPUT);
  digitalWrite(PIN_STEPPER_DIR, HIGH);
  digitalWrite(PIN_STEPPER_ENA, HIGH);
  // It depends on the PIN_STEPPER_PUL
  TIMSK3 |= 1 << OCIE3A;
  startPulses(PIN_STEPPER_PUL, FREQ, 3);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
}

 
 


Consulta nuestros casos de estudio:

Estudios de casos de automatización >>>                                             

Buscar en nuestro blog

Servomotor con PLC basado en Arduino
Bernat Garcia 18 de octubre de 2024
Compartir
Categorías

¿Estás buscando tu Controlador Lógico Programable ideal?

Echa un vistazo a esta comparativa de producto de varios controladores industriales basados en Arduino.

Comparamos entradas, salidas, comunicaciones y otras especificaciones con las de los equipos de otras marcas destacadas.


Comparación de PLCs industriales >>>