你那Q0.0是不对的,那是位输出。应该是PQW***,***表示你组态的模拟输出地址。为了编下面程序,我给你定义PQW272
L 27648 // 模拟量上限
L 5 // 载入五个档
/I // 整数相除
T MW20 // 每个档对应模拟值
A I0.0 //检查1档位状态
JNB M001 //位为0跳转到标签M001
L0 //如果为一载入0
T MW22 // 因为一档为零没有必要去乘了,直接传送去
M001: A I0.1
JNB M002 //检查2档状态
L 2
L MW20 //乘以一个档对应模拟值
*I
T MW22 //传送到MW22
M002: A I0.2 //检查3档状态
JNB M003 //RLO为0跳转
L 3
L MW20
*I
T MW22
M003 A I0.3
JNB M004
L 4
L MW20
*I
T MW22
M004: A I0.4
JNB M005
L 27648 //五档对应最大值,所有直接传送27648
T MW22
M005:L MW22 //载入MW22
T PQW272 //输出
MW20,MW22随便写的一个M区,根据实际情况选择存储区
开始没有看清输出。输出写反了的哈,五档对应的10V,1档对应0V.。你可以改一下。






[ 此帖被djljcl在2013-06-13 00:19重新编辑 ]