我是靠谱客的博主 专一大白,最近开发中收集的这篇文章主要介绍完整的VAL3程序,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

start()

begin
  //延时10秒   
  delay(5)
  //初始化变量
  call init()
  //清空原有运动堆栈
  resetMotion()
  //建立上电任务
  taskCreate "robotpower",100,robotpower()
  wait(isPowered())
  //建立生产任务
  taskCreate "ProductionCycle",10,ProductionCycle()
  //建立安全区域检测任务
  taskCreate "CheckSafeArea",10,CheckSafeArea()
  //建立屏幕刷新任务
  taskCreate "HMI",80,HMI()
  //  //
end

init()

begin
  _bPartReverse=false
  _bPartRight=false
  _bCheckArrived=false
  _bStartCheck=false
  _bSyncErr=false
  doERobotDone=false
  doEhome=false
  doERobotError=false
  open(tGripper)
  _nDifY=0
  _nItem=0
  sState="已停止"
end

HMI()

begin
  userPage()//切换到用户屏幕
  cls()

  gotoxy(0,2)
  put("生产状态:")
  gotoxy(0,4)
  put("工件序号:")
  gotoxy(0,6)
  put("光电信号:")
  gotoxy(0,8)
  put("正反检测:")
  gotoxy(0,10)
  put("检测偏差:")
  while true
    //刷新生产状态
    gotoxy(10,2)
    put("                          ")
    gotoxy(10,2)
    put(sState)
    //刷新工件序号
    gotoxy(10,4)
    put("                          ")
    gotoxy(10,4)
    put(toString("",_nItem+1))
    //刷新激光传感器信号
    gotoxy(10,6)
    put("                          ")
    if diFCheckSensor==true
      gotoxy(10,6)
      put("ON")
    else
      gotoxy(10,6)
      put("OFF")
    endIf
    //刷新正反向判断
    gotoxy(10,8)
    put("                          ")
    if _bPartRight
      gotoxy(10,8)
      put("正向")
    elseIf _bPartReverse
      gotoxy(10,8)
      put("反向")
    endIf
    //刷新检测偏差
    gotoxy(10,10)
    put("                          ")
    gotoxy(10,10)
    put(toString("0.2",_nDifY)+"mm")
    delay(0)
  endWhile
end


robotpower()

begin
  while true
    //控制器在远程模式
    // if (workingMode()==4 or workingMode()==1)
    if workingMode()==4
      if !isPowered()
        enablePower()
        //控制器运行模式切换延时时间
        delay(1)
        wait(isPowered())
      endIf
    elseIf workingMode()==1
      enablePower()
      //wait(isPowered())
    elseIf workingMode()==2 or workingMode()==3
      disablePower()
      doERobotDone=false
    endIf
    delay(0)
  endWhile
end

ProductionCycle()

begin
  //开始回零
  //wait(diEPlcReady==true or (workingMode()==1 and isPowered()and delay(2)) or doEhome==true)
  wait(diEPlcReady==true or doEhome==true or diEManualStart==true)
  doERobotDone=false
  sState="回原点"
  l_pHome=jointToPoint(tGripper,world,jHome)
  l_pHere=here(tGripper,world)
  l_pHere.trsf.z=max(l_pHere.trsf.z,50)
  movel(l_pHere,tGripper,mSpeedL)
  movej(jHome,tGripper,mSpeedL)
  waitEndMove()
  open(tGripper)
  doEhome=true
  //循环生产
  while true
    call Pallet()
    delay(0)
  endWhile
end

CheckSafeArea()

begin
  while true
    l_pHere=here(tGripper,world)
    if l_pHere.trsf.x>nXLimitMax or l_pHere.trsf.x<nXLimitMin or l_pHere.trsf.y>nYLimitMax or l_pHere.trsf.y<nYLimitMin
      // disablePower()
      stopMove()
      resetMotion()
      l_bAlarm=true
    else
      l_bAlarm=false
    endIf
    if l_bAlarm and !l_bLastAlarm
      popUpMsg("机器人超出安全工作空间!")
      logMsg("机器人超出安全工作空间!")
    endIf
    l_bLastAlarm=l_bAlarm

    //判断机器人是否在home位
    l_pHome=jointToPoint(tGripper,world,jHome)
    if distance(l_pHere,l_pHome)<5
      doEhome=true
    else
      doEhome=false
    endIf
    delay(0)
  endWhile
end

Pallet()

begin
  //在进行开启/关闭阀门时
  //最好是使用waitendmove()等点到位以后再使用
  //wait(diEPlcDone==true)
  //doERobotDone=false
  wait(diEStart==true or diEManualStart==true)
  doERobotDone=false
  //if !isPowered() 
  //call start()
  //endIf

  //抓放循环,5次
  for _nItem=0 to 4
    //运动开始
    //wait(diEStart==true or workingMode()==1)
    //去取件
    sState="取件中"
    l_pPickAppro=appro(pPick[_nItem],{0,0,-nPickAppro,0,0,0})
    movej(l_pPickAppro,tGripper,mSpeedH)
    doEhome=false
    movel(pPick[_nItem],tGripper,mSpeedL)
    waitEndMove()
    close(tGripper)
    l_nMoveID=movel(l_pPickAppro,tGripper,mSpeedL)
    //去检测
    wait(getMoveId()>l_nMoveID+0.5)
    sState="检测中"
    movej(pCheckReady,tGripper,mSpeedH)
    movel(pCheckStart,tGripper,mSpeedL)
    l_nMoveID=movel(pCheckOver,tGripper,mSpeedLL)
    //开始检测激光传感器状态

    wait(getMoveId()>l_nMoveID)
    //        _bStartCheck=true
    //        wait(_bCheckArrived)
    //        _bCheckArrived=false
    //    do
    //    until (diFCheckSensor==false)
    //传感器感应到后,停止手臂运动,清除运动指令
    //检测导光条的边缘,若检测不到信号则报警
    if watch(diFCheckSensor==false,3)==false
      sState="无导光条"
      doERobotError=true
      stopMove()
      resetMotion()
      wait(diEReset==true)
      doERobotError=false
      //PLC复位后给出回原信号,机械手回原
      wait(diEPlcReady==true)
      doERobotDone=false
      doERobotError=false
      sState="回原点"
      l_pHome=jointToPoint(tGripper,world,jHome)
      l_pHere=here(tGripper,world)
      l_pHere.trsf.z=max(l_pHere.trsf.z,50)
      movel(l_pHere,tGripper,mSpeedL)
      movej(jHome,tGripper,mSpeedL)
      waitEndMove()
      open(tGripper)
      doEhome=true
      return
    endIf
    stopMove()
    resetMotion()
    //检测到导光条,外部绿灯亮
    doESensor=!diFCheckSensor
    //delay(0.5)
    //计算工件Y向位置偏差
    l_pHere=here(tGripper,world)
    _nDifY=l_pHere.trsf.y-pCheckMark.trsf.y
    //向上提起,判断正反向
    l_pCheckRight=l_pHere
    //向上提起到pCheckUp的高度
    l_pCheckRight.trsf.z=pCheckUp.trsf.z
    //向里伸入0.2mm
    l_pCheckRight.trsf.y=l_pHere.trsf.y+0.2
    movel(l_pCheckRight,tGripper,mSpeedL)
    waitEndMove()
    //延时检测
    delay(0.1)
    //如果光电感应不到,判断为正向,并计算调整后的放件位置
    if diFCheckSensor==true
      _bPartRight=true
      _bPartReverse=false
      //l_pPlace=compose(pPlace[0,_nItem],fPlacePallet,{0,_nDifY,0,0,0,0})
      l_pPlace=appro(pPlace[0,_nItem],{-_nDifY,0,0,0,0,0})
      //否则,为反向,并计算调整后的放件位置
    else
      _bPartRight=false
      _bPartReverse=true
      //l_pPlace=compose(pPlace[1,_nItem],fPlacePallet,{0,-_nDifY,0,0,0,0})
      l_pPlace=appro(pPlace[1,_nItem],{-_nDifY,0,0,0,0,0})
    endIf
    //向上提起,离开检测区
    l_pCheckAppro=appro(l_pCheckRight,{0,0,-20,0,0,0})
    movel(l_pCheckAppro,tGripper,mSpeedL)
    if _bPartRight
      l_nMoveID=movej(pCheckReady,tGripper,mSpeedH)
    else
      l_nMoveID=movej(jhomen,tGripper,mSpeedH)
    endIf
    waitEndMove()
    //去放件
    wait(getMoveId()>l_nMoveID+0.3)
    sState="放件中"
    //外部绿灯灭
    doESensor=false
    //去放件准备位
    l_pPlaceAppro=appro(l_pPlace,{0,0,-nPlaceAppro,0,0,0})
    movej(l_pPlaceAppro,tGripper,mSpeedH)

    //根据压入深度,计算压入点
    l_pPress=appro(l_pPlace,{0,0,nPressDeepth,0,0,0})
    //计算压入准备位,在压入点上方nPressAppro高,角度与放件位相同。
    l_pPressAppro=appro(l_pPress,{0,0,-nPressAppro,0,0,0})
    //到压入准备位,打开夹爪
    movel(l_pPressAppro,tGripper,mSpeedL)
    waitEndMove()
    open(tGripper)
    //延时nPressDelay s,保证夹爪已打开
    delay(nPressDelay)
    //压入卡槽
    movel(l_pPress,tGripper,mSpeedL)
    //回准备位
    l_nMoveID=movel(l_pPlaceAppro,tGripper,mSpeedL)
    wait(getMoveId()>l_nMoveID+0.5)
    _bPartReverse=false
    _bPartRight=false
    delay(0)
  endFor
  //放件完成,回原点,发送完成信号
  sState="回原点"
  movej(jHome,tGripper,mSpeedH)
  waitEndMove()
  doERobotDone=true
  //     
  delay(10)
end


最后

以上就是专一大白为你收集整理的完整的VAL3程序的全部内容,希望文章能够帮你解决完整的VAL3程序所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(30)

评论列表共有 0 条评论

立即
投稿
返回
顶部