1、LED 数码显示控制的 PLC 编程(2007-11-28 18:52:17) 转载标签: 学习公社分类: PLC 学习 参考程序描述:按下启动按钮后,由八组 LED 发光二极管模拟的八段数码管开始显示:先是一段段显示,显示次序是 A、B、C、D、E、F、G、H,随后显示数字及字符,显示次序是 0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F,断开启动按钮程序停止运行。方法一:用 SHRB 指令用 M10.0M10.7 M11.0M11.7 M12.0M12.7 的 24 个位表示显示的 24 种状态的控制位。将下面这段语句指令全部复制,然后开一个记事本文件,粘贴进去。ORGAN
2、IZATION_BLOCK MAIN:OB1TITLE=POU CommentBEGINNetwork 1 / Network Title/ Network CommentLD I0.0LPSAN T38= M0.1LRDTON T38, 15LPPAN T37TON T37, 10Network 2LD M12.7O M0.1= M0.0Network 3LD T37SHRB M0.0, M10.0, 24Network 4 / Network Title/ Network CommentLD M10.0O M11.0O M11.2O M11.3O M11.5O M11.6O M11.7O
3、M12.0O M12.1O M12.2O M12.4O M12.6O M12.7= Q0.0Network 5LD M10.1O M11.0O M11.1O M11.2O M11.3O M11.4O M11.7O M12.0O M12.1O M12.2O M12.5= Q0.1Network 6LD M10.2O M11.0O M11.1O M11.3O M11.4O M11.5O M11.6O M11.7O M12.0O M12.1O M12.3O M12.5O M12.2= Q0.2Network 7LD M10.3O M11.0O M11.2O M11.3O M11.5O M11.6O
4、M12.0O M12.1O M12.3O M12.4O M12.5O M12.6= Q0.3Network 8LD M10.4O M11.0O M11.2O M11.6O M12.0O M12.2O M12.3O M12.4O M12.5O M12.6O M12.7= Q0.4Network 9LD M10.5O M11.0O M11.4O M11.5O M11.6O M12.0O M12.1O M12.2O M12.3O M12.4O M12.6O M12.7= Q0.5Network 10LD M10.6O M11.2O M11.3O M11.4O M11.5O M11.6O M12.0O
5、 M12.1O M12.2O M12.3O M12.5O M12.6O M12.7= Q0.6Network 11LD M10.7= Q0.7END_ORGANIZATION_BLOCKSUBROUTINE_BLOCK SBR_0:SBR0TITLE=POU CommentBEGINNetwork 1 / Network Title/ Network CommentEND_SUBROUTINE_BLOCKINTERRUPT_BLOCK INT_0:INT0TITLE=POU CommentBEGINNetwork 1 / Network Title/ Network CommentEND_INTERRUPT_BLOCK做好了 txt 记事本文件,再将它导入 PLC 中,文件类型是“所有”我就拿我做的实验来讲解,我用的是 7 段码,Q0.1Q0.7 分别对应着 7 段如果要显示数字 2,那么就如下图,即 Q0.1、Q0.2、Q0.4、Q0.5、Q0.7 工作。如果是 8,那就全部工作,这就不一一列图了。方法二:用 SEG 指令用 SHRB 指令来写程序太长,太麻烦了。个人推荐用 SEG 段码指令,程序简洁明了。LD SM0.1MOVB 0, VB10LD I0.0AN T37TON T37, 10LD T37INCB VB10SEG VB10, QB0