XScript 手册 · Chapter 11

CYL — 气缸控制

CYL["名称"] 代表一个气缸。名称是在气缸编辑器中注册的气缸名称, 通过编辑器中指定的 A · B 动作的输出(Sol)IO 驱动气缸,并通过传感器(Sensor)IO 确认动作完成。

示例

xscript
if( CYL["Cyl_InStopper"].Push(true) == false )
{
   // ERROR
}
else
{
   // SUCCESS
}
 
if( CYL["Cyl_InStopper"].Pull(true) == false )
{
   // ERROR
}
else
{
   // SUCCESS
}

实战示例 — 面板夹紧顺序

按 Post Pin 下降 → 面板夹紧 → 真空吸附 → Fix 气缸后退的顺序动作,失败时弹出错误窗口的示例。

xscript
// 面板夹紧 : Post Pin 下降 → 夹紧 → 真空吸附 → Fix 气缸后退
// ( DeviceClampCompleteFlag 是模块变量,SS.ClampAfterDelay · SS.UseStageVac 是 System Setup 参数 )
FUNCTION bool PanelClamp()
{
   // 已经夹紧则直接通过
   if( IO["I_PanelClampL"] && IO["I_PanelClampR"]
      && IO["I_PostPinDownF"] && IO["I_PostPinDownR"] )
   {
      DeviceClampCompleteFlag = true;
      return true;
   }
 
   if( CYL["Cyl_PostPin"].Down(true) == false )
   {
      CYL["Cyl_PostPin"].ShowCylinderError(ModuleName);
      return false;
   }
   Sleep(100);
 
   if( CYL["Cyl_PanelClamp"].Clamp(true) == false )
   {
      CYL["Cyl_PanelClamp"].ShowCylinderError(ModuleName);
      return false;
   }
   Sleep(SS.ClampAfterDelay);
 
   if( SS.UseStageVac )
   {
      if( CYL["Cyl_StageVac"].Suck(true) == false )
      {
         CYL["Cyl_StageVac"].Off();
         CYL["Cyl_PanelClamp"].UnClamp(true);
         ShowError(EB_Reset, 208, "");
         return false;
      }
   }
 
   // Fix 气缸后退
   if( CYL["Cyl_SpindleFix"].Backward(true) == false )
   {
      CYL["Cyl_SpindleFix"].ShowCylinderError(ModuleName);
      return false;
   }
 
   DeviceClampCompleteFlag = true;
   return true;
}

方法

气缸动作函数分为 Action A 系列和 Action B 系列,只是名称不同,动作方式相同。 请根据气缸类型(Type)选择相应名称——即使调用与类型不符的名称,A 系列执行 A 动作,B 系列执行 B 动作。

Action A 系列Action B 系列气缸类型(Type)
Open(bool wait)Close(bool wait)OpenClose
Up(bool wait)Down(bool wait)UpDown
Left(bool wait)Right(bool wait)LeftRight
Forward(bool wait)Backward(bool wait)ForwardBackward
Lock(bool wait)Unlock(bool wait)LockUnlock
Suck(bool wait)Eject(bool wait)SuckEject
Stop(bool wait)Pass(bool wait)StopPass
Turn(bool wait)Return(bool wait)TurnReturn
Push(bool wait)Pull(bool wait)PushPull
Clamp(bool wait)UnClamp(bool wait)ClampUnclamp

所有动作函数都遵循以下规则(B 动作时将 A · B 互换理解)。

  • 打开 A 动作的输出 Sol,关闭 B 动作的 Sol。
  • wait 为 true 时,在 TimeOutA 时间内等待 B 传感器关闭且所有 A 传感器打开,然后再多等待 DelayA。 若在时间内传感器没有变化则返回 false。未指定传感器的一侧不等待。
  • wait 为 false 时,只更改输出并立即返回(不确认传感器、无 Delay)。
方法说明
bool <ActionA/ActionB>(bool wait)上表中的所有动作函数。wait:动作之后是否等待动作完成(传感器确认)
bool Toggle(bool wait)执行与当前相反的动作——第一个 A 输出(SolIndexA1)关闭则执行 A 动作,打开则执行 B 动作(没有 A 输出时,以同样的方式根据第一个 B 输出判断)。wait 规则相同
bool ReadSensorA(void)SensorIndexA1 ~ A4 中指定的输入全部为 ON 时返回 true(只要有一个为 OFF,或没有指定的传感器,则返回 false)
bool ReadSensorB(void)以同样的方式检查 SensorIndexB1 ~ B4
bool Off(void)关闭所有输出(Sol A · B)。若为 SuckEject 类型且 Suck 输出为 ON,则先输出 Eject 约 0.1 秒再关闭。输出写入失败则返回 false
int ShowCylinderError(string moduleName) · int ShowCylinderError(string moduleName, bool wait)以最近一次动作的错误代码(气缸编辑器的 ErrorCodeA · ErrorCodeB)和消息(例:CYL'说明' 'Push' Error)弹出错误窗口(Reset 按钮)。moduleName 是发生错误的模块名称(通常是内置变量 ModuleName)。wait 为 true 时,等待操作员按下按钮,并返回所按按钮的值(ER_Reset 等)

属性

属性类型说明
Name · Description · GroupNamestring气缸名称 · 说明(也用于错误消息)· 组名称
TimeOutA · TimeOutBintA · B 动作之后等待传感器的超时时间(ms)
DelayA · DelayBintA · B 动作的传感器确认结束后再多等待的时间(ms)。wait 为 false 时不使用
SubModelstring使用该气缸的设备的子型号信息
SolIndexA1 ~ SolIndexA4 · SolIndexB1 ~ SolIndexB4stringA · B 动作时要打开的输出 IO 名称(可设置)
SensorIndexA1 ~ SensorIndexA4 · SensorIndexB1 ~ SensorIndexB4string用于确认 A · B 动作完成的输入 IO 名称(可设置)
SolListA · SolListB · SensorListA · SensorListBstring将 A · B 的全部输出 · 输入 IO 用逗号连接成的字符串(只读)
Infostring返回气缸说明(Description)(只读)
ActionA · ActionBstring与气缸类型对应的 A · B 动作名称(例:UpDown → Up · Down,只读)

参考

  • 在气缸编辑器中关闭使用的气缸,其动作函数、Off() 不更改输出而是返回 true。
  • 设置值的含义见气缸编辑器,手动动作确认见气缸测试。
订阅申请