当前位置: 主页 > PLC控制

WinCC中如何访问1200PLC中的数组数据

1200PLC中有两个数组,这两个数组中元素个数都为20,在wincc中使用什么方式可以快捷方便的把这两个数组中的数据提出来,我是用以下方式实现的

DimX_VaLUES(20),Y_Values(20)
DimdblAxisX
Dimnumber
X_Values(0)=HMIRUNtime.Tags("Trend_NPSHa1").Read
X_Values(1)=HMIRuntime.Tags("Trend_NPSHa2").Read
X_Values(2)=HMIRuntime.Tags("Trend_NPSHa3").Read
X_Values(3)=HMIRuntime.Tags("Trend_NPSHa4").Read
X_Values(4)=HMIRuntime.Tags("Trend_NPSHa5").Read
X_Values(5)=HMIRuntime.Tags("Trend_NPSHa6").Read
X_Values(6)=HMIRuntime.Tags("Trend_NPSHa7").Read
X_Values(7)=HMIRuntime.Tags("Trend_NPSHa8").Read
X_Values(8)=HMIRuntime.Tags("Trend_NPSHa9").Read
X_Values(9)=HMIRuntime.Tags("Trend_NPSHa10").Read
X_Values(10)=HMIRuntime.Tags("Trend_NPSHa11").Read
X_Values(11)=HMIRuntime.Tags("Trend_NPSHa12").Read
X_Values(12)=HMIRuntime.Tags("Trend_NPSHa13").Read
X_Values(13)=HMIRuntime.Tags("Trend_NPSHa14").Read
X_Values(14)=HMIRuntime.Tags("Trend_NPSHa15").Read
X_Values(15)=HMIRuntime.Tags("Trend_NPSHa16").Read
X_Values(16)=HMIRuntime.Tags("Trend_NPSHa17").Read
X_Values(17)=HMIRuntime.Tags("Trend_NPSHa18").Read
X_Values(18)=HMIRuntime.Tags("Trend_NPSHa19").Read
X_Values(19)=HMIRuntime.Tags("Trend_NPSHa20").Read

Fori=0Tonumber-1‘在趋势图上绘制的点数
dblAxisX=CDbl(X_Values(i))
Next
先把数组元素一个个的列举,然后通过一个FOR循环实现。但这种方式太麻烦,请教各位大侠有没有更好的方法。

问题补充:
如果数据量大WinCC怎样一次性把数据都读过来比如把一个数据块里的数据一次性读过来怎么实现。WinCC读取plc里的数组类型的变量,还是要把数组中的每个变量一个个的拆分开来才可实现对数组变量的读取。这样太费劲了。有没有高效的方式啊

最佳答案

直接这样可能更简单点
Fori=0Tonumber-1”在趋势图上绘制的点数
dblAxisX=CDbl(HMIRuntime.Tags("Trend_NPSHa"&i+1).Read)
Next

提问者对于答案的评价:

  • 关注微信

猜你喜欢

微信公众号