Skip to main content

Controlar el movimiento de ejes individuales

Ver el PLCopenSingle.project proyecto de ejemplo en el directorio de instalación de CODESYS por debajo ..\CODESYS SoftMotion\Examples.

Este ejemplo demuestra cómo controlar un convertidor mediante bloques de función estandarizados PLCopen.

  1. Inserte una unidad virtual llamada Drive en el árbol de dispositivos a continuación Piscina SoftMotion General Axis.

  2. Crear un MOTION_PRG programa en ST.

    PROGRAM MOTION_PRG
    VAR
            iStatus: INT;
            Power: MC_Power;
            MoveAbsolute: MC_MoveAbsolute;
            p:REAL:=100;
    END_VAR
    
    CASE iStatus OF
    
    // initialization of the axis
    0:
            Power(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Drive);
            IF Power.Status THEN
                    iStatus := iStatus + 1;
            END_IF
    
    // Move the axis to position p by use of the MC_MoveAbsolute function block
    1:
            MoveAbsolute(Execute:=TRUE, Position:= p, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive);
            IF MoveAbsolute.Done THEN
                    MoveAbsolute(Execute:=FALSE, Axis:=Drive);
                    iStatus := iStatus + 1;
            END_IF
    
    // Move the axis back to position 0 by use of the MC_MoveAbsolute function block:
    2:
            MoveAbsolute(Execute:=TRUE, Position:= 0, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive);
            IF MoveAbsolute.Done THEN
                    MoveAbsolute(Execute:=FALSE, Axis:=Drive);
                    iStatus := 1;
            END_IF
  3. Agregue la llamada del programa MOTION_PRG a la tarea Tarea principal.

    Árbol de dispositivos:

    _sm_img_example_single_axis_2.png
  4. Descargue el proyecto al controlador e inícielo.

  5. Abre el Conducir eje virtual en el editor.

    En el En línea parte de General pestaña, verá el movimiento del eje.

    _sm_img_example_single_axis_1.png