科威PLC芯片组开发实例(七)
[font=宋体]实战开始,苦手对象:[/font][font=Times New Roman]EASY-M0806R[/font][font=Times New Roman] [/font]
[font=宋体]首先,我们得搞清楚,[/font][font=Times New Roman]EASY-M0806R[/font][font=宋体]的[/font][font=Times New Roman]IO[/font][font=宋体]引脚的分配情况,这款[/font][font=Times New Roman]PLC[/font][font=宋体]有[/font][font=Times New Roman]8[/font][font=宋体]个输入点,[/font][font=Times New Roman]6[/font][font=宋体]个输出点,那么就相应的有[/font][font=Times New Roman]8+6 = 14[/font][font=宋体]个[/font][font=Times New Roman]IO[/font][font=宋体]引脚对应它们的输入和输出,对应原理图我们得知:[/font]
[font=Times New Roman]8[/font][font=宋体]个输入点对应的引脚是:[/font]
[font=Times New Roman]I0[/font][font=宋体]→[/font][font=Times New Roman]P3.7
I1[/font][font=宋体]→[/font][font=Times New Roman]P3.6
I2[/font][font=宋体]→[/font][font=Times New Roman]P3.5
I3[/font][font=宋体]→[/font][font=Times New Roman]P3.4
I4[/font][font=宋体]→[/font][font=Times New Roman]P3.3
I5[/font][font=宋体]→[/font][font=Times New Roman]P3.2
I6[/font][font=宋体]→[/font][font=Times New Roman]P3.1
I7[/font][font=宋体]→[/font][font=Times New Roman]P3.0[/font]
[font=Times New Roman] [/font]
[font=Times New Roman]6[/font][font=宋体]个输出点对应的引脚是:[/font]
[font=Times New Roman]OUT0[/font][font=宋体]→[/font][font=Times New Roman]P1.0
OUT1[/font][font=宋体]→[/font][font=Times New Roman]P1.1
OUT2[/font][font=宋体]→[/font][font=Times New Roman]P1.2
OUT3[/font][font=宋体]→[/font][font=Times New Roman]P1.3
OUT4[/font][font=宋体]→[/font][font=Times New Roman]P1.4
OUT5[/font][font=宋体]→[/font][font=Times New Roman]P1.5[/font]
[font=Times New Roman] [/font]
[font=宋体]其次,每个输入输出点都对应一个[/font][font=Times New Roman]LED[/font][font=宋体],当输入输出点吸合的时候,对应的[/font][font=Times New Roman]LED[/font][font=宋体]将被点亮,那么对应原理图我们得知[/font][font=Times New Roman]14[/font][font=宋体]个[/font][font=Times New Roman]LED[/font][font=宋体]对应的引脚是:[/font]
[font=Times New Roman]ILED0[/font][font=宋体]→[/font][font=Times New Roman]P2.0
ILED1[/font][font=宋体]→[/font][font=Times New Roman]P2.1
ILED2[/font][font=宋体]→[/font][font=Times New Roman]P2.2
ILED3[/font][font=宋体]→[/font][font=Times New Roman]P2.3
ILED4[/font][font=宋体]→[/font][font=Times New Roman]P2.4
ILED5[/font][font=宋体]→[/font][font=Times New Roman]P2.5[/font]
[font=Times New Roman]ILED6[/font][font=宋体]→[/font][font=Times New Roman]P2.6
ILED7[/font][font=宋体]→[/font][font=Times New Roman]P2.7[/font]
[font=Times New Roman]OLED0[/font][font=宋体]→[/font][font=Times New Roman]P0.4
OLED1[/font][font=宋体]→[/font][font=Times New Roman]P0.5
OLED2[/font][font=宋体]→[/font][font=Times New Roman]P0.6
OLED3[/font][font=宋体]→[/font][font=Times New Roman]P0.7
OLED4[/font][font=宋体]→[/font][font=Times New Roman]P4.1
OLED5[/font][font=宋体]→[/font][font=Times New Roman]P4.0[/font]
[font=Times New Roman] [/font]
[font=宋体]与此同时,[/font][font=Times New Roman]PLC[/font][font=宋体]还有一个[/font][font=Times New Roman]RUN/SET[/font][font=宋体]的输入,该输入负责管理[/font][font=Times New Roman]PLC[/font][font=宋体]的运行状态和下载状态,对应着不同的状态,有一个专门[/font][font=Times New Roman]LED[/font][font=宋体]点亮[/font][font=Times New Roman]/[/font][font=宋体]熄灭来判断此输入的状态,一般来说,运行状态时,该[/font][font=Times New Roman]LED[/font][font=宋体]被点亮,下载状态则反之。根据原理图我们得知:[/font][font=Times New Roman] [/font]
[font=Times New Roman]RUN/SET-LED[/font][font=宋体]→[/font][font=Times New Roman]P4.3[/font]
[font=Times New Roman] [/font]
[font=Times New Roman]PLC[/font][font=宋体]如果错误的被执行,应该还有一个错误的[/font][font=Times New Roman]LED[/font][font=宋体]将被点亮,这个[/font][font=Times New Roman]LED[/font][font=宋体]对应的引脚为:[/font]
[font=Times New Roman]ERR-LED[/font][font=宋体]→[/font][font=Times New Roman]P4.2[/font]
[font=宋体]那么我们怎么得知[/font][font=Times New Roman]PLC[/font][font=宋体]运行[/font][font=Times New Roman]/[/font][font=宋体]下载的状态,还有出错的状态呢?请看[/font][font=Times New Roman]easycore.inc[/font][font=宋体]文件,有[/font][font=Times New Roman]3[/font][font=宋体]个变量定义:[/font]
[font=Times New Roman]KEY_SET
EQU
3FH
;1[/font][font=宋体]有效[/font][font=Times New Roman]([/font][font=宋体]下载梯形图[/font][font=Times New Roman])[/font]
[font=Times New Roman]KEY_PRO
EQU
3EH
;0[/font][font=宋体]有效[/font][font=Times New Roman]([/font][font=宋体]下载用户程序[/font][font=Times New Roman])[/font]
[font=Times New Roman]PLC_PRO_ERR
EQU
3DH
;[/font][font=宋体]梯形图错误标志[/font][font=Times New Roman],1[/font][font=宋体]有效[/font]
[font=宋体]这个是我们前几节所没有讲到的,通过检测这些位变量,我们就可以对[/font][font=Times New Roman]RUN/SET-LED[/font][font=宋体]和[/font][font=Times New Roman]ERR-LED[/font][font=宋体]进行控制了。[/font]
[font=Times New Roman] [/font]
[font=宋体]知道了这些以后,我们就对[/font][font=Times New Roman]EASY-M0806R[/font][font=宋体]的[/font][font=Times New Roman]IO[/font][font=宋体]引脚分配有了大致的了解,趁此机会,我们把[/font][font=Times New Roman]easycore.inc[/font][font=宋体]最后剩下没讲完的变量也拉出来遛一下吧[/font][font=Times New Roman]~[/font]
[font=Times New Roman]M0~M15[/font][font=宋体]:这[/font][font=Times New Roman]16[/font][font=宋体]个字节变量可是直接寻址方式的哟,但是应用它们有个局限性,那就是必须得在[/font][font=Times New Roman]SCAN[/font][font=宋体]里面应用,其他地方是不允许调用这[/font][font=Times New Roman]16[/font][font=宋体]个字节变量的,如果你非要在其他地方使用,那么就必须得把它们压栈,不过还是不推荐此方法,真的要压栈的话,还不如压公共直接寻址变量区[/font][font=Times New Roman]DRAM_USER[/font][font=宋体]区域呢。[/font]
[font=Times New Roman] [/font]
[font=Times New Roman]FLOAT_M1~ FLOAT_M4[/font][font=宋体],[/font][font=Times New Roman]W_R0~ W_R7[/font][font=宋体],[/font][font=Times New Roman]W_DATA[/font][font=宋体]:这几个变量是专门调用[/font][font=Times New Roman]easycore.lib[/font][font=宋体]函数库里面的函数所要用到的出口入口的变量。大致了解一下它们的含义便行,如果你到了需要调用[/font][font=Times New Roman]easycore.lib[/font][font=宋体]函数库里面的函数这个阶段,那么本文对你来说,相信应该已经没有多大意义了[/font][font=Times New Roman]^-^~![/font]
[font=Times New Roman] [/font]
[font=宋体]下一讲我们将分模块来详细叙述如何根据我们所掌握的[/font][font=Times New Roman]IO[/font][font=宋体]口引脚信息,来填充我们的驱动项目工程。[/font]
[font=Times New Roman] [/font]
[font=Times New Roman]PS[/font][font=宋体]:本节所讲的[/font][font=Times New Roman]IO[/font][font=宋体]口配置可能会与实际[/font][font=Times New Roman]IO[/font][font=宋体]口配置略有出入,大家当以实际的原理图为准![/font]
[font=Times New Roman] [/font]
[font=宋体][size=10.5pt]本帖首发中国工控网科威[/size][/font][size=10.5pt]PLC[/size][font=宋体][size=10.5pt]论坛,转载请声明![/size][/font]
页:
[1]