Skip to content

Resource Management and Drive Functions for acyclic communcation with DPV1 services.

License

Notifications You must be signed in to change notification settings

simatic-ax/lacyccom-procedural

Repository files navigation

@simatic-ax/lacyccom-procedural

Description

The LAcycCom (Acyclic Communication) library for SIMATIC S7-1200/S7-1500 provides a collision-free coordination of communication resources in the CPU for acyclic data exchange via DPV1 services.

In case of user programmed blocks it is strongly recommend to use the provided resource management blocks when using any acyclic communications such as WriteRecord or ReadRecord, to avoid timing and priority issues with multiple requests for one device.

The following drive functions are available for drives compliant to PROFIdrive:

  • Read/Write parameters in the drive system
  • Activate/Deactivate complete drive objects
  • Activate/Deactivate components of drive objects
  • Acknowledge errors of drive objects
  • Saving of volatile RAM data into the retentive ROM memory (RAM2ROM)
  • Time synchronization of CPU and drive system to achieve a chronological order of alarms and messages

Getting started

Install with Apax:

If not yet done login to the GitHub registry first. More information you'll find here

apax add @simatic-ax/lacyccom-procedural

Add the namespace in your ST code:

USING Simatic.Ax.LAcycCom.Procedural

Library functionality

The library is divided into the sections Resource Management where the allocation and handling of resources are centrally managed and Drive Functions which represents various functions to interact via acyclic communication with a SINAMICS drive system.

Resource Management

Function Blocks Description
LAcycCom_ResourceManager Function block to manage state of multiple arbitrary resources
LAcycCom_HandleResource Function block for user programmed blocks to request the state of a resource centrally managed in the resource manager

Drive Functions

Function Blocks Description
LAcycCom_AckDriveFaults Function block to acknowledge faults at a drive object
LAcycCom_DriveActDeact Function block to activate or deactivate drive objects in the SINAMICS control unit
LAcycCom_DriveComponentsActDeact Function block to activate or deactivate drive object components (power unit and encoders) in the SINAMICS control unit
LAcycCom_DriveRamToRom Function block to save the volatile RAM data of specified drive object to the retentive ROM
LAcycCom_ReadDriveMessagesDateTime Function block to read active messages (alarms, fault and SI messages), sorted by time from a drive object
LAcycCom_ReadDriveMessagesOperatingHours Function block to read active messages (alarms and faults), sorted by time from a G120 control unit
LAcycCom_ReadDriveParams Function block to read multiple parameters via a dataset from a SINAMICS drive object
LAcycCom_ReadDriveSingleParam Function block to read a single parameter from a SINAMICS drive object
LAcycCom_RTCSinamics Function block to synchronize the clock of a SINAMICS control unit with the clock of the SIMATIC controller (with ping compensation)
LAcycCom_RTCSinamicsAcyclic Function block to synchronize the clock of a SINAMICS control unit with the clock of the SIMATIC controller (with acyclic data exchange)
LAcycCom_WriteDriveParams Function block to write multiple parameters via a dataset from a SINAMICS drive object
LAcycCom_WriteDriveSingleParam Function block to write a single parameter from a SINAMICS drive object

Examples

Reading a single parameter from a S120 drive

USING Simatic.Ax.LAcycCom.Procedural;

PROGRAM SampleProgramS120
  VAR_INPUT
    readParam : BOOL;
  END_VAR

  VAR_OUTPUT
    value : REAL;
  END_VAR

  VAR_EXTERNAL
    DRIVE_BLUE_TEL105 : UINT;
  END_VAR
  
  VAR
    _resourceManagerConfig : LAcycCom_typeResourceManagerConfiguration;
    _requestBufferHeader : LAcycCom_typeRequestBufferHeader;
    _requestBuffer : ARRAY[1..10] OF LAcycCom_typeRequestBufferElement;
    _instResourceManager : LAcycCom_ResourceManager;
    _instReadDriveSingleParam : LAcycCom_ReadDriveSingleParam;
  END_VAR

  // call resource manager
  _instResourceManager(enable := TRUE, 
                        config := _resourceManagerConfig, 
                        requestBufferHeader := _requestBufferHeader, 
                        requestBuffer := _requestBuffer);

  // call read drive single param
  _instReadDriveSingleParam(hardwareId := DRIVE_BLUE_TEL105, 
                            parameterNumber := UINT#1082, // maximum speed 
                            requestBufferHeader := _requestBufferHeader, 
                            requestBuffer := _requestBuffer);

  // resource manager needs to be valid, before executing function blocks from Drive Functions
  IF _instResourceManager.valid THEN
    // execute read single parameter
    _instReadDriveSingleParam.execute := readParam;
    
    // reflect value to output
    value := _instReadDriveSingleParam.realValue;
  ELSE
    _instReadDriveSingleParam.execute := FALSE;
  END_IF;
END_PROGRAM

Writing multiple parameters to a S210 drive

USING Simatic.Ax.LAcycCom.Procedural;

PROGRAM SampleProgramS210
  VAR_INPUT
    writeParams : BOOL;
  END_VAR

  VAR_OUTPUT
    done: BOOL;
    error: BOOL;
  END_VAR

  VAR_EXTERNAL
    DRIVE_1_MAP : UINT;
  END_VAR
    
  VAR
    _resourceManagerConfig : LAcycCom_typeResourceManagerConfiguration;
    _requestBufferHeader : LAcycCom_typeRequestBufferHeader;
    _requestBuffer : ARRAY[1..10] OF LAcycCom_typeRequestBufferElement;
    _instResourceManager : LAcycCom_ResourceManager;
    _instWriteDriveParams : LAcycCom_WriteDriveParams;
    _dataset : ARRAY[1..3] OF LAcycCom_typeDriveDataset;
  END_VAR
    
  // call resource manager
  _instResourceManager(enable := TRUE, 
                        config := _resourceManagerConfig, 
                        requestBufferHeader := _requestBufferHeader, 
                        requestBuffer := _requestBuffer);

  // call write drive params
  _instWriteDriveParams(hardwareId := DRIVE_1_MAP,
                        parameterCount := -1,
                        dataset := _dataset,
                        requestBufferHeader := _requestBufferHeader,
                        requestBuffer := _requestBuffer);

  // resource manager needs to be valid, before executing function blocks from Drive Functions
  IF _instResourceManager.valid THEN

    // define parameters and their values
    _dataset[1].parameterNumber := UINT#1083; // positive speed limit
    _dataset[1].writeSelector := LAcycCom_DatatypeSelector#TYPE_REAL;
    _dataset[1].realValue := 6000;
    _dataset[2].parameterNumber := UINT#1086; // negative speed limit
    _dataset[2].writeSelector := LAcycCom_DatatypeSelector#TYPE_REAL;
    _dataset[2].realValue := -6000;
    _dataset[3].parameterNumber := UINT#1121; // ramp down time
    _dataset[3].writeSelector := LAcycCom_DatatypeSelector#TYPE_REAL;
    _dataset[3].realValue := REAL#1.5;

    // execute write drive parameters
    _instWriteDriveParams.execute := writeParams;

    // reflect state to outputs
    done := _instWriteDriveParams.done;
    error := _instWriteDriveParams.error;
  ELSE
    _instWriteDriveParams.execute := FALSE;

    done := FALSE;
    error := FALSE;
  END_IF;
END_PROGRAM

Contribution

Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using a pull request.

License and Legal information

Please read the Legal information

About

Resource Management and Drive Functions for acyclic communcation with DPV1 services.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages