ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Configuración de CODESYS Modbus TCP


Enviado por   •  3 de Noviembre de 2022  •  Tutoriales  •  1.953 Palabras (8 Páginas)  •  159 Visitas

Página 1 de 8

Configuración de CODESYS Modbus TCP (SP16 o posterior)

Requisitos

  • Modbus & OPC Edition o Ultimate Edition
  • CODESYS v3.5 SP16 o posterior (funciona con la versión demo). Si se trabaja con una versión anterior, el tutorial correspondiente se puede encontrar aquí.

Este tutorial muestra cómo conectar CODESYS a factory I/O a través de Modbus TCP. Siguiendo estas instrucciones, creará un nuevo proyecto CODESYS, lo configurará para que funcione con E/S de fábrica y programará CODESYS Control Win (SoftPlc) para controlar la escena de ordenación por altura (avanzada).

El código de ejemplo utilizado en este tutorial se basa en las soluciones que se encuentran en el libro Industrial Automation Practices.

Crear el proyecto

  1. Inicie CODESYS y cree un nuevo proyecto.
  2. Seleccione Proyecto estándar en la lista Plantillas y elija un nombre para el proyecto (por ejemplo, Tutorial). Haga clic en Aceptar.

[pic 1]

  1. En la ventana Proyecto estándar, seleccione Device CODESYS Control Win V3 (3S - Smart Software Solutions GmbH) y Structured Text (ST) para el PLC_PRG. Haga clic en Aceptar.

[pic 2]

  1. Haga clic con el botón derecho en Aplicación y seleccione Agregar objeto > Lista global de variables.... Escriba FIO como nombre de la lista y haga clic en Agregar.

[pic 3]

  1. Abra la lista FIO haciendo doble clic izquierdo sobre ella y copie y pegue las siguientes variables globales. Estas variables se utilizarán para intercambiar datos entre E/S de fábrica y CODESYS a través de Modbus TCP (estos son los puntos de E/S).
  2. VAR_GLOBAL
  3.     iAtEntry        : BOOL;
  4.     iLowBox         : BOOL;
  5.     iHighBox        : BOOL;
  6.     iAtTurnEntry    : BOOL;
  7.     iAtLoadPos      : BOOL;
  8.     iAtUnloadPos    : BOOL;
  9.     iAtFront        : BOOL;
  10.     iAtRightEntry   : BOOL;
  11.     iAtLeftEntry    : BOOL;
  12.     iAtRightExit    : BOOL;
  13.     iAtLeftExit     : BOOL;
  14.     oFeederConveyor : BOOL;
  15.     oEntryConveyor  : BOOL;
  16.     oLoad           : BOOL;
  17.     oUnload         : BOOL;
  18.     oTurn           : BOOL;
  19.     oLeftConveyor   : BOOL;
  20.     oRightConveyor  : BOOL;
  21. END_VAR

[pic 4]

  1. En el árbol de dispositivos, haga doble clic izquierdo en PLC_PRG (PRG) y copie y pegue las siguientes variables. Estas son las variables que utilizará en su programa.
  2. PROGRAM PLC_PRG
  3. VAR
  4.     F_AtEntry           : F_TRIG;
  5.     F_AtTurnEntry       : F_TRIG;
  6.     F_AtRightEntry      : F_TRIG;
  7.     F_AtLeftEntry       : F_TRIG;
  8.     F_AtRightExit       : F_TRIG;
  9.     F_AtLeftExit        : F_TRIG;
  10.     Pallet_on_left      : BOOL := FALSE;
  11.     Pallet_on_right     : BOOL := FALSE;
  12.     Idle                : BOOL := TRUE;
  13.     Charging            : BOOL := FALSE;
  14.     Turns_charged       : BOOL := FALSE;
  15.     Discharging         : BOOL := FALSE;
  16.     Turns_Discharged    : BOOL := FALSE;
  17.     Turntable_busy      : BOOL := FALSE;
  18.     Discharge_direction : BOOL := FALSE;
  19.     Entry_busy          : BOOL := FALSE;
  20.     Pallet_on_entry     : BOOL := FALSE;
  21.     Count               : WORD := 16#8000;
  22. END_VAR

[pic 5]

  1. Ahora, copie y pegue el código siguiente. Este es el programa que controlará la escena de Ordenación por altura (avanzada).
  2. F_AtEntry(CLK := FIO.iAtEntry);
  3. F_AtTurnEntry(CLK := FIO.iAtTurnEntry);
  4. F_AtRightEntry(CLK := FIO.iAtRightEntry);
  5. F_AtLeftEntry(CLK := FIO.iAtLeftEntry);     (* A pallet abandons the turntable, being charged onto the left exit conveyer *)
  6. F_AtRightExit(CLK := FIO.iAtRightExit);
  7. F_AtLeftExit(CLK := FIO.iAtLeftExit);       (* A pallet abandons the left exit conveyer *)
  8. (**** LEFT EXIT CONVEYER CONTROL ****)
  9. (* Pallet_on_left represents the state of the left exit conveyer: if it carries a pallet, then Pallet_on_left = TRUE *)
  10. IF F_AtLeftExit.Q THEN                      (* When a pallet abandons the conveyer *)
  11.     Pallet_on_left := FALSE;                (* Reset Pallet_on_left *)
  12. END_IF;
  13. IF FIO.iAtLeftEntry THEN                    (* When there’s a pallet at the entry of the conveyer *)
  14.     Pallet_on_left := TRUE;                 (* Set Pallet_on_left *)
  15. END_IF;
  16. FIO.oLeftConveyor := Pallet_on_left;        (* Left exit conveyer runs for Pallet_on_left = TRUE *)
  17. (**** RIGHT EXIT CONVEYER CONTROL ****)
  18. IF F_AtRightExit.Q THEN
  19.     Pallet_on_right := FALSE;
  20. END_IF;
  21. IF FIO.iAtRightEntry THEN
  22.     Pallet_on_right := TRUE;
  23. END_IF;
  24. FIO.oRightConveyor := Pallet_on_right;
  25. (**** TURNTABLE CONTROL ****)
  26. IF Idle AND FIO.iAtTurnEntry THEN
  27.     Idle := FALSE;
  28.     Charging := TRUE;
  29. END_IF;
  30. IF Charging AND FIO.iAtFront THEN
  31.     Charging := FALSE;
  32.     Turns_charged := TRUE;
  33. END_IF;
  34. IF Turns_charged AND FIO.iAtUnloadPos THEN
  35.     Turns_charged := FALSE;
  36.     Discharging := TRUE;
  37. END_IF;
  38. (* The turntable discharges now onto both conveyers. Thus: *)
  39. IF Discharging AND (F_AtRightEntry.Q OR F_AtLeftEntry.Q) THEN
  40.     Discharging := FALSE;
  41.     Turns_Discharged := TRUE;
  42. END_IF;
  43. IF Turns_Discharged AND FIO.iAtLoadPos THEN
  44.     Turns_Discharged := FALSE;
  45.     Idle := TRUE;
  46. END_IF;
  47. IF F_AtTurnEntry.Q THEN
  48.     Turntable_busy := TRUE;
  49. END_IF;
  50. IF Idle THEN
  51.     Turntable_busy := FALSE;
  52. END_IF;
  53. (* Computing control outputs according to the current state of the turntable and the direction of the discharge *)
  54. FIO.oLoad := Charging OR Discharging AND Discharge_direction;
  55. (* oUnload is TRUE if the discharge is onto the left conveyer *)
  56. FIO.oUnload := Discharging AND NOT Discharge_direction;
  57. (* oTurn is TRUE if the discharge is onto the right conveyer *)
  58. FIO.oTurn := Turns_charged OR Discharging;
  59. (**** ENTRY CONVEYER CONTROL ****)
  60. IF F_AtEntry.Q THEN
  61.     Count := ROL (Count,1);
  62.     IF (Count = WORD#16#2) THEN
  63.         Entry_busy := TRUE;
  64.     END_IF;
  65. END_IF;
  66. IF F_AtTurnEntry.Q THEN
  67.     (** Defining the direction of the discharge: the direction of the discharge changes every time a pallet is
  68.     discharged from the entry conveyer onto the turntable. If Discharge_direction = FALSE, then the discharge is onto the right conveyer **)
  69.     Discharge_direction := NOT Discharge_direction;
  70.     Entry_busy := FALSE;
  71.     Count := ROR(Count,1);
  72.     IF (Count = WORD#16#8000) THEN
  73.         Pallet_on_entry := FALSE;
  74.     END_IF;
  75. END_IF;
  76. IF FIO.iAtEntry THEN
  77.     Pallet_on_entry := TRUE;
  78. END_IF;
  79. FIO.oEntryConveyor := Pallet_on_entry AND (NOT Turntable_busy OR NOT FIO.iAtTurnEntry);
  80. (**** FEEDING CONVEYER CONTROL ****)
  81. FIO.oFeederConveyor := NOT Entry_busy OR NOT FIO.iAtEntry;

[pic 6]

  1. Iniciar CODESYS Control Win V3.

[pic 7]

  1. Volver a CODESYS y en el árbol del proyecto, haga doble clic izquierdo en dispositivo (CODESYS Control Win V3) y luego en configuración de comunicación. Ahora, haga clic en Scan network... y seleccione la ruta de red al controlador. Haga clic en Aceptar.

[pic 8]

  1. En la barra de herramientas, haga clic en Compilar > compilar (F11).
  2. Ahora, haga clic con el botón derecho en Aplicación y seleccione Agregar objeto > Configuración de símbolos. A continuación, haga clic en Agregar. Ahora, compruebe los símbolos fio y haga clic en Construir.

[pic 9]

  1. Haga clic con el botón derecho en Dispositivo (CODESYS Control Win V3) (1) y seleccione Agregar dispositivo.... A continuación, expanda Buss de campo > Adaptador Ethernet y haga clic en Ethernet (2). Haga clic en Agregar dispositivo.

[pic 10]

  1. Right-click on Ethernet (1) and select Add Device..., expand Fieldbusses > Modbus > Modbus TCP Slave Device and select Modbus TCP Slave Device (2). Next, click on Add Device.

[pic 11]

  1. Haga doble clic en Modbus TCP Slave Device (agregado en el paso anterior) y abra General. Marque la casilla Áreas de bits discretas e ingrese el número de bobinas y entradas discretas como se muestra a continuación.

[pic 12]

  1. Ahora, abra Modbus TCP Slave Device I/O Mapping (1) y asigne las variables globales (2) definidas en el paso 5 como se muestra en la imagen a continuación.

[pic 13]

  1. A continuación, haga clic en Inicio de sesión en línea > (Alt + F8). Cuando se le pida que descargue el programa en el PLC, haga clic en .
  2. Finalmente, haga clic en Depurar > Inicio (F5).

Configuración de E/S de fábrica

  1. Abra una escena en E/S de fábrica y haga clic en Controladores de > de archivos. Elija al cliente modbus TCP/IP de la lista desplegable. A continuación, haga clic en Configuración.

[pic 14]

  1. Establezca el ID de esclavo en 0 o 255. A continuación, establezca los puntos de E/S como se muestra en la imagen siguiente.

información

Cuando se trabaja con SP16, el IDENTIFICADOR de esclavo debe establecerse en 0 o 255. La especificación Modbus TCP seguida de CODESYS 3.5 SP16 establece que el servidor Modbus se direcciona utilizando su dirección IP, y por lo tanto el Identificador de Unidad Modbus es inútil.

[pic 15]

  1. Vuelva al menú Controlador y haga clic en CONECTAR. Una conexión correcta se indica mediante un icono verde junto al controlador seleccionado, así como junto al nombre del controlador que se muestra en la barra de estado.

[pic 16]

El PLC de Control CODESYS permite ejecutar código de programa con acceso a nivel de sistema en esta máquina. Esto puede suponer una amenaza para la seguridad a menos que se tomen las medidas adecuadas para limitar el acceso a la red a esta máquina.

...

Descargar como (para miembros actualizados)  txt (10.1 Kb)   pdf (1.4 Mb)   docx (1.4 Mb)  
Leer 7 páginas más »
Disponible sólo en Clubensayos.com