返回列表 发布新帖

如何配置使用AX系列plc上的本体IO--输出篇

694 0
发表于 2024-7-10 18:16:53 | 查看全部 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
<p>本帖介绍如何使用配置使用英威腾AX系列PLC本体上的IO的使用方法</p><p>一、输出点配置</p><p>输出端口可以设置为 3 种功能,分别是:普通输出功能、高速脉冲输出功能和比较输出功能,可以通过配置Out0_Confguer来配置输出点,如下图所示,通过对对应变量赋值来对输出点的功能配置。</p><p>当端口配置为0时,做普通io使用;<span style="text-wrap: wrap;">当端口配置为1时,做输出做高速脉冲输出使用;<span style="text-wrap: wrap;">当端口配置为2时做比较输出功能使用。</span></span></p><p><br/></p><p><img src="/upload/article/20231123/1700718696228962.png" title="1700718696228962.png" alt="image.png"/>&nbsp;</p><p><img src="/upload/article/20231123/1700718644828346.png" title="1700718644828346.png" alt="image.png" width="655" height="493" style="width: 655px; height: 493px;"/></p><p><br/></p><p>二、功能块使用</p><p>&nbsp;&nbsp;&nbsp;&nbsp;以下时英威腾脉冲功能块的说明<br/></p><p><img src="/upload/article/20231123/1700720193444837.png" title="1700720193444837.png" alt="image.png"/></p><p><img src="/upload/article/20231123/1700720224703931.png" title="1700720224703931.png" alt="image.png"/></p><p>&nbsp;三、例程</p><p><span style="text-wrap: nowrap;">PROGRAM HSIO_shuchu</span></p><p><span style="text-wrap: nowrap;">VAR</span></p><p><span style="text-wrap: nowrap;">//功能块</span></p><p><span style="text-wrap: nowrap;">MC_InitSys_Invt_0&nbsp; &nbsp;: MC_InitSys_Invt;        //轴初始化定义</span></p><p><span style="text-wrap: nowrap;">MC_Axis_0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: MC_Axis;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //输出通道轴定义,轴名称</span></p><p><span style="text-wrap: nowrap;">MC_Power_Invt_0&nbsp; &nbsp; &nbsp;: MC_Power_Invt;&nbsp; &nbsp; //轴使能</span></p><p><span style="text-wrap: nowrap;">MC_MoveVelocity_Invt_0:MC_MoveVelocity_Invt;//轴运动</span></p><p><span style="text-wrap: nowrap;">MC_Stop_Invt_0&nbsp; &nbsp; &nbsp; : MC_Stop_Invt;&nbsp; &nbsp; &nbsp;//轴停止</span></p><p><span style="text-wrap: nowrap;">MC_Reset_Invt_0&nbsp; &nbsp; &nbsp;: MC_Reset_Invt;&nbsp; &nbsp; //轴复位</span></p><p><span style="text-wrap: nowrap;">MC_SendData_Invt_0&nbsp; : MC_SendData_Invt; //数据输出</span></p><p><span style="text-wrap: nowrap;">MC_ReadStatus_Invt_0: MC_ReadStatus_Invt;//轴状态</span></p><p><span style="text-wrap: nowrap;">//变量</span></p><p><span style="text-wrap: nowrap;">Enable_power&nbsp; &nbsp; &nbsp; &nbsp; : BOOL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴使能</span></p><p><span style="text-wrap: nowrap;">Enable_Move&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: BOOL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴运动</span></p><p><span style="text-wrap: nowrap;">Enable_stop&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: BOOL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴停止</span></p><p><span style="text-wrap: nowrap;">Enable_reset&nbsp; &nbsp; &nbsp; &nbsp; : BOOL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴复位</span></p><p><span style="text-wrap: nowrap;">Enable_Status&nbsp; &nbsp; &nbsp; &nbsp;: BOOL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴状态</span></p><p><span style="text-wrap: nowrap;">Pluse_velocity&nbsp; &nbsp; &nbsp; : UDINT;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //轴下发脉冲速度</span></p><p><span style="text-wrap: nowrap;">velocity1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: UDINT;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //下发转速</span></p><p><span style="text-wrap: nowrap;">END_VAR</span></p><p><span style="text-wrap: nowrap;">//输出通道配置完成后,库管理器调用 高速计数功能块库 CmpHSIO_C.library和 运动控制功能块库 CmpHSIO_M.library</span></p><p><span style="text-wrap: nowrap;"><br/></span></p><p><span style="text-wrap: nowrap;">//轴初始化定义</span></p><p><span style="text-wrap: nowrap;">MC_InitSys_Invt_0(</span></p><p>        <span style="text-wrap: nowrap;">Mode:= TRUE,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//TRUE脉冲型,FAlSE非脉冲型</span></p><p>        <span style="text-wrap: nowrap;">Period:= 4,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //运行周期,需要和任务周期Task保持一致</span></p><p>        <span style="text-wrap: nowrap;">Done=&gt; ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//初始化完成信号</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //错误</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//功能块错误码</span></p><p><span style="text-wrap: nowrap;"><br/></span></p><p><span style="text-wrap: nowrap;">//输出通道轴定义</span></p><p><span style="text-wrap: nowrap;">MC_Axis_0(</span></p><p>        <span style="text-wrap: nowrap;">AxisID:= 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //输出通道选择,YO脉冲输出,Y1方向输出,禁止重复定义</span></p><p>        <span style="text-wrap: nowrap;">MaxVelocity:=5000 ,&nbsp; &nbsp; &nbsp; &nbsp; //输出最大速度,默认5000mm/min</span></p><p>        <span style="text-wrap: nowrap;">MaxAcceleration:=180000 ,&nbsp; //输出最大加速度,默认180 0000</span></p><p>        <span style="text-wrap: nowrap;">MaxHomeSpeed:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//输出最大回零速度,默认值3000mm/min</span></p><p>        <span style="text-wrap: nowrap;">MaxVim2Speed:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//当前轴第二阶段最大回零速度,默认值20mm/min,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">MaxVim1Speed:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//当前轴第一阶段最大回零速度,默认值200mm/min,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">MaxJogSpeed:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //输出最大手动速度,默认值5000mm/min</span></p><p>        <span style="text-wrap: nowrap;">LimitEnable:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //软限位使能标志,TRUE软限位开启,FAlSE软限位关闭,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">MaxPLimit:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //当前轴最大正限位位置,默认值9999999999.99,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">MaxNLimit:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //当前轴最大负限位位置,默认值-9999999999.99,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">PulseData:=10000 ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//转动一圈脉冲数,需与伺服内部参数保持一致</span></p><p>        <span style="text-wrap: nowrap;">DistanceData:= 10,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴转动一圈周长</span></p><p>        <span style="text-wrap: nowrap;">MaxJerkTime:= ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //当前轴最大允许加速度变化时间,默认值100,可选择默认值不填写</span></p><p>        <span style="text-wrap: nowrap;">Mode:= 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //轴脉冲控制方式(0:脉冲+方向,1:正反转, 2:正交)</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );</span></p><p>        </p><p><span style="text-wrap: nowrap;">//轴使能</span></p><p><span style="text-wrap: nowrap;">MC_Power_Invt_0(</span></p><p>        <span style="text-wrap: nowrap;">Axis:= MC_Axis_0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用轴定义名称,对应输出通道Y0,Y1</span></p><p>        <span style="text-wrap: nowrap;">Enable:= Enable_power,&nbsp; &nbsp; &nbsp;//轴使能,高电平有效</span></p><p>        <span style="text-wrap: nowrap;">AxisError:= FALSE,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//TRUE轴报警,FAlSE轴未报警</span></p><p>        <span style="text-wrap: nowrap;">AxisEnable:= MC_InitSys_Invt_0.Done,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//轴初始化是否完成</span></p><p>        <span style="text-wrap: nowrap;">Status=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Valid=&gt; ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //TRUE轴使能有效,FAlSE轴使能无效</span></p><p>        <span style="text-wrap: nowrap;">Busy=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );</span></p><p><span style="text-wrap: nowrap;"><br/></span></p><p><span style="text-wrap: nowrap;">//轴运动</span></p><p><span style="text-wrap: nowrap;">MC_MoveVelocity_Invt_0(</span></p><p>        <span style="text-wrap: nowrap;">Axis:= MC_Axis_0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用轴定义名称,对应输出通道Y0,Y1</span></p><p>        <span style="text-wrap: nowrap;">Enable:= Enable_Move,&nbsp; &nbsp; &nbsp; //轴运行,上升沿触发</span></p><p>        <span style="text-wrap: nowrap;">Direction:= TRUE,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //轴运行方向</span></p><p>        <span style="text-wrap: nowrap;">Velocity:= 100,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //轴运行速度,运行单位mm/min</span></p><p>        <span style="text-wrap: nowrap;">Acceleration:=10000 ,&nbsp; &nbsp; &nbsp; //加速度大小</span></p><p>        <span style="text-wrap: nowrap;">JerkTime:= 10,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//允许加速度变化时间</span></p><p>        <span style="text-wrap: nowrap;">InVelocity=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Busy=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">CommandAborted=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );</span></p><p><span style="text-wrap: nowrap;"><br/></span></p><p><span style="text-wrap: nowrap;">//轴停止</span></p><p><span style="text-wrap: nowrap;">MC_Stop_Invt_0(</span></p><p>        <span style="text-wrap: nowrap;">Axis:= MC_Axis_0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用轴定义名称,对应输出通道Y0,Y1</span></p><p>        <span style="text-wrap: nowrap;">Enable:= Enable_stop,&nbsp; &nbsp; &nbsp; //轴运行,上升沿触发</span></p><p>        <span style="text-wrap: nowrap;">Deceleration:=100000 ,&nbsp; &nbsp; &nbsp;//减速度大小</span></p><p>        <span style="text-wrap: nowrap;">Mode:=FALSE ,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //TRUE减速停,FAlSE立即停止</span></p><p>        <span style="text-wrap: nowrap;">Done=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Busy=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );</span></p><p>        </p><p><span style="text-wrap: nowrap;">//轴复位</span></p><p><span style="text-wrap: nowrap;">MC_Reset_Invt_0(</span></p><p>        <span style="text-wrap: nowrap;">Axis:= MC_Axis_0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //调用轴定义名称,对应输出通道Y0,Y1</span></p><p>        <span style="text-wrap: nowrap;">Enable:= Enable_reset,&nbsp; &nbsp; &nbsp;//轴复位,上升沿触发</span></p><p>        <span style="text-wrap: nowrap;">Done=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Busy=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">Error=&gt; ,&nbsp;</span></p><p>        <span style="text-wrap: nowrap;">ErrorID=&gt; );</span></p><p></p><p></p>

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright © 2001-2025 英威腾技术论坛 版权所有 All Rights Reserved. 粤ICP备07504406号
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表