|
[id_[id_[]]]
当拆开快递包裹时,你是否想过精准抓取货物的机械臂是如何工作的呢?今天我们要探索的是利用三菱 FX5U PLC 构建智能分拣系统的核心技术。无需具备电子工程背景,只要跟随我的节奏,你便能够理解这个工业机器人背后的控制逻辑。你准备好让自己的第一个机械手项目运转起来了吗?
一、认识分拣系统三大金刚
传感器家族如同机械手的眼睛与皮肤。光电传感器能够检测物体的位置,压力传感器可以确保抓取时的力度,视觉传感器能够识别物品的特征。这些信号经由 PLC 的输入端子持续不断地传进来。
试试这个基础接线测试:
<p><pre style="font-size: inherit;color: inherit;line-height: inherit;margin: 0px;padding: 0px;"> <code style=" white-space:pre-wrap;overflow-wrap: break-word;margin: 0px 2px;background: rgb(248, 248, 248);font-family: 'courier new', Consolas, Inconsolata, monospace;border-radius: 8px;font-size: 9.5pt;line-height: 1.3;color: rgb(255, 255, 255);border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 20px; word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important; "><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">1</span></span><span leaf="">X0 X1 Y0</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">2</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">3</span></span><span leaf="">| |--| |-------( )</span><br /></code></pre></p>
X0(光电传感器)触发并且 X1(压力传感器)触发时,Y0(气动抓手)会动作。这是不是有点像电路版的“且”逻辑呢?
温馨提示:在调试时,要记得给电磁阀接上续流二极管,不要让反向电动势把输出模块烧毁。
二、让机械手跳起数字芭蕾
运动控制是分拣系统的关键所在。FX5U 所内置的定位模块具备同时控制 4 轴伺服电机的能力。我们利用相对定位指令使机械臂进行优雅的移动。
<p><pre style="font-size: inherit;color: inherit;line-height: inherit;margin: 0px;padding: 0px;"> <code style=" white-space:pre-wrap;overflow-wrap: break-word;margin: 0px 2px;background: rgb(248, 248, 248);font-family: 'courier new', Consolas, Inconsolata, monospace;border-radius: 8px;font-size: 9.5pt;line-height: 1.3;color: rgb(255, 255, 255);border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 20px; word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important; "><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">1</span></span><span leaf="">MOVP K5000 D0 // 设定脉冲量</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">2</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">3</span></span><span leaf="">Y0 会发出脉冲,同时 Y4 能够控制方向。</span><br /></code></pre></p>
这段代码能够使伺服电机旋转 5 圈,也就是 5000 个脉冲。设想一下为机械手编排舞蹈动作的情景,其中每一个定位点都如同舞步的标记一般。
常见坑点有:伺服电机的电子齿轮比设置错误的话,就会致使实际移动距离出现偏差,要记得去查看手册并核对相关参数!
三、物料分拣的智能决策
当不同颜色的物料通过时,我们的颜色传感器(连接在 X10 上)会发出信号。通过使用 CMP 比较指令并配合 MOV 传送指令,就能够达成智能分流的效果:
<p><pre style="font-size: inherit;color: inherit;line-height: inherit;margin: 0px;padding: 0px;"> <code style=" white-space:pre-wrap;overflow-wrap: break-word;margin: 0px 2px;background: rgb(248, 248, 248);font-family: 'courier new', Consolas, Inconsolata, monospace;border-radius: 8px;font-size: 9.5pt;line-height: 1.3;color: rgb(255, 255, 255);border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 20px; word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important; "><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">1</span></span><span leaf="">CMP D100 K50 // 对比计数值</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">2</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">3</span></span><span leaf="">MOV K1 Y20 // 合格品流向1号口</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">4</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">5</span></span><span leaf="">MOV K2 Y21 // 次品转向2号口</span><br /></code></pre></p>
给传送带不同段的电磁阀进行编号,这就如同给快递包裹分配不同的传送轨道。看到此处,是否会觉得自动分拣其实就像是智能快递员呢?
使用 FIFO 指令来实现队列管理,这样就能处理连续到来的物料而不会出现卡顿的情况。
四、异常处理保平安
急停按钮(X30)必须用优先回路设计:
<p><pre style="font-size: inherit;color: inherit;line-height: inherit;margin: 0px;padding: 0px;"> <code style=" white-space:pre-wrap;overflow-wrap: break-word;margin: 0px 2px;background: rgb(248, 248, 248);font-family: 'courier new', Consolas, Inconsolata, monospace;border-radius: 8px;font-size: 9.5pt;line-height: 1.3;color: rgb(255, 255, 255);border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 20px; word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important; "><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">1</span></span><span leaf="">X30 Y0</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">2</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">3</span></span><span leaf="">| |----|/|--</span><br /></code></pre></p>
任何时候进行急停的拍下操作,就会立刻切断所有的输出。这就如同给系统赋予了一个“一键冻结”的特殊能力。
建议在程序开头加心跳检测:
<p><pre style="font-size: inherit;color: inherit;line-height: inherit;margin: 0px;padding: 0px;"> <code style=" white-space:pre-wrap;overflow-wrap: break-word;margin: 0px 2px;background: rgb(248, 248, 248);font-family: 'courier new', Consolas, Inconsolata, monospace;border-radius: 8px;font-size: 9.5pt;line-height: 1.3;color: rgb(255, 255, 255);border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 20px; word-wrap: normal !important;word-break: normal !important;overflow: auto !important;display: -webkit-box !important; "><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">1</span></span><span leaf="">INC D200 // 每次扫描周期自增</span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">2</span></span><br /><span style="font-size: inherit;line-height: inherit;padding: 0px;color: rgb(131, 135, 250);padding-right: 8px;word-spacing: 0px;border-right: 1px solid yellowgreen;border-top-color: yellowgreen;border-bottom-color: yellowgreen;border-left-color: yellowgreen;margin: 0px 8px 0px 0px;display: inline-block;vertical-align: top;background-color: black;border-radius: 0px;word-wrap: inherit !important;word-break: inherit !important;"><span leaf="">3</span></span><span leaf="">CMP D200 K1000</span><br /></code></pre></p>
D200如果停止增长,那就意味着程序卡死了。此时要赶紧触发报警,这就如同给 PLC 戴上了一个智能手环来监测其健康状态。
五、实战调试三部曲
先调单个气缸动作(就像先练分解动作)
再试传感器联动(确认眼神交流正常)
最后全自动运行(来段)
碰到机械手抽风式乱动?查这三个点准没错:
• 原点传感器上有灰尘
• 气管接头漏气
• 脉冲当量计算错误
调试的秘诀在于,在关键的位置插入诸如 MOV K0 Y0 这样的急停指令,这就如同给程序装上了紧急刹车,这样一来,在排查故障时会更加安全。
现在试着完成这些挑战:
让机械手在20cm范围内精准抓取
实现三种物料分类存放
添加产量统计显示屏
调试时要备好万用表和泡面。因为你可能需要和 PLC 一起度过好几个漫长的夜晚。当第一个物料被准确分拣出来的时候,那种成就感是绝对值得你熬过那些夜晚的。 |
|