防摇摆控制算法 antisway

已锁定

benben777

  • 帖子

    5
  • 精华

    0
  • 被关注

    11

论坛等级:游民

注册时间:2016-10-07

普通 普通 如何晋级?

防摇摆控制算法 antisway

6704

10

2016-10-17 14:50:17

来源: www.proview.se 开源控制系统 里面有瑞典钢板开发的防摇摆控制功能块,C编写的。

如需要S7-SCL或AB SCL版本可和我联系。


/* 

 * Proview   Open Source Process Control.

 * Copyright (C) 2005-2016 SSAB EMEA AB.

 *

 * This file is part of Proview.

 *

 * This program is free software; you can redistribute it and/or 

 * modify it under the terms of the GNU General Public License as 

 * published by the Free Software Foundation, either version 2 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 General Public License for more details.

 *

 * You should have received a copy of the GNU General Public License 

 * along with Proview. If not, see <http://www.gnu.org/licenses/>

 *

 * Linking Proview statically or dynamically with other modules is

 * making a combined work based on Proview. Thus, the terms and 

 * conditions of the GNU General Public License cover the whole 

 * combination.

 *

 * In addition, as a special exception, the copyright holders of

 * Proview give you permission to, from the build function in the

 * Proview Configurator, combine Proview with modules generated by the

 * Proview PLC Editor to a PLC program, regardless of the license

 * terms of these modules. You may copy and distribute the resulting

 * combined work under the terms of your choice, provided that every 

 * copy of the combined work is accompanied by a complete copy of 

 * the source code of Proview (the version used to produce the 

 * combined work), being distributed under the terms of the GNU 

 * General Public License plus this exception.

 **/


/*********************************************************************

**********************************************************************

*

*       S S A B  O X E L ?S U N D

*       = = = =  = = = = = = = = =

**********************************************************************

*

* Filename      : 

*

* Description   : Contains main functions for anti-sway control,

*               : called from plc

*                 

*               Date    Sign           Action

* Revision      050213  jonas_h        First edition

*               050721  jonas_h        Improved error handling: Errors are written to an internal buffer instead of being printed with printf(..). From the buffer, errors are stored in a String80 output, that can be connected e.g. to a DSup.

*                                      Extended functionality for automatic object: The soft maximum velocity, umaxS, can be changed while in travel (if e.g. in a low-speed area).

*                                      Transfer of set to manual object when disabling, allowing for continued anti-sway, and smooth travel.

*

*

**********************************************************************

**********************************************************************/


#include "ssabox_plc_antisway.h"



/*_*

  @aref ssab_antisway Ssab_AntiSway

*/

void Ssab_AntiSway_init(object)

     pwr_sClass_Ssab_AntiSway *object;

{

  int i;

  AS_OBJ_SETP->N = 0;

  AS_OBJ_SETP->extSum = 0.0;

  AS_OBJ_SETP->ph = NULL;

  object->other=NULL;

  for (i=0; i<2; i++) {

    object->messageQ[i] = 0;

//    AS_OBJ_MESSAGEQP(i) = NULL;

    (object->message[i])[79]='';

  }

}



void Ssab_AntiSway_exec(plc_sThread *tp, pwr_sClass_Ssab_AntiSway *object)

{

  int hoisting = FALSE;

  int newCall = FALSE;

  int hoisted = FALSE;

  int i;

  char *mstr;

  double omega, dt;

  const AS_shaper *shp;


  dt = tp->PlcThread->ScanTime; /* Constant scan time (the ideal value, not the measuremen of last cycle time) */

  object->done = TRUE;



  /***********************************************

   *  Step 1. Check current error status. 

   *          Reset if enable has been switched.

   ***********************************************/


  if (object->errstatus > AS_ERR_MINOR) { /* crucial error has occured since last reset. */


    if (!(object->errstatus & AS_ERR_DISABLED)) { /* Not already disabled */

      object->errstatus |= AS_ERR_DISABLED; /* set disabled flag */

      if (object->enable) /* the object was enabled when the crucial error occured */

  object->errstatus |= AS_ERR_WASENABLED; /* set wasenabled flag */

      if (object->verbose >= AS_VERB_DISABLED)/* Print disabled message if verbose */

printf(" AntiSway object disabled. Error status=%d ",object->errstatus);

      AS_ADDMESSAGE(AS_ALARMTYPE_DISABLED, &mstr,"AntiSway object stopped. Error status=%d",object->errstatus);

    }

    else if (object->errstatus & AS_ERR_WASENABLED) {/* already disabled, from enable mode. Reset errstatus if enable is switched off */

      if (!object->enable) 

object->errstatus=0;

    }

    else if (object->enable)/* already disabled, from not enable mode. Reset errstatus if enable is switched on */

      object->errstatus=0;


    newCall = TRUE;  //why? needed if errstatus is reset. in which case this will be an ordinary execution cycle. 

  }


   


  /************************************************

   *  Step 2. Receive input and check its validity

   ************************************************/

 

  /* 2.1 Determine if new call and get new input */


  object->enable = *object->enableP; 

  object->xc = *object->xcP;

  object->DLc = *object->DLcP;

  object->mode = *object->modeP;

  object->manual = *object->manualP;



  /* Get a pointer to the shaper corresponding to the current mode. */

  shp = AS_SetupIST(object->mode); 

  if (shp == NULL) { /* Non-valid mode - disable! */

    if (!(object->errstatus & AS_ERR_MODE)) { /* Error flag not already set. */

      object->errstatus |= AS_ERR_MODE; /* Set error flag */

      if (object->verbose >= AS_VERB_DISABLED) /* Print error message if verbose */

printf(" AntiSway: No shaper for current mode! Mode=%d ",object->mode);

      AS_ADDMESSAGE(AS_ALARMTYPE_DISABLED, &mstr,"AS: No shaper for current mode! Mode=%d",object->mode);  

    }

  }



  if ( object->manual && (object->autostatus & AS_AUTO_ON) ) { //switched from auto to manual

    AS_collapseSet(AS_OBJ_SETP, shp, AS_OBJ_AMAXSM);

    object->autostatus &= (~AS_AUTO_ON);

    newCall = TRUE;

  }

  else if ( !object->manual && !((object->autostatus & AS_AUTO_ON)) ) { //switched from manual to auto. 

    AS_collapseSet(AS_OBJ_SETP, shp, AS_OBJ_AMAXSA);

    object->autostatus |= AS_AUTO_ON;

    newCall = TRUE;

  }


  

  /* Fetch command velocity and command position and check its validity. This is done independently of mode */

  if (object->uCommand != *object->uCommandP) {

    object->uCommand = *object->uCommandP;

    /* Check command velocity */

    if (fabs(object->uCommand) > AS_OBJ_UMAXSM) { /* Non-valid command velocity - disable! */

    

antisway.rar


防摇摆控制算法 antisway 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

谈天说地

共有13706条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。