西门子PLC的通信协议主要是PPI、MPI、Profibus、CP243/CP343/CP443 网络协议,prodave是早期完成的程序接口,除了网络协议外其它的主要协议都支持,SoftNet是西门子最新推出的通信协议接口,稳定,并且大而全,目前西门子所有主流的协议都支持(我的blog文章:西门子Softnet驱动的成功开发已经做了简单介绍),由于好多朋友对prodave都比较关注,所以我这里专门写篇blog来简单介绍一下。
我所知道的最新的Prodave的版本是V5.5,完整版的要45兆左右,由于出的比较早,所以动态库“W95_s7.dll”的名称保留至今,我最早接触是在01~02年,不过当时版本好像不到V5.5,与S7-200通信很不稳定,并且访问周期比较长。给我的感觉Prodave好像专门为S7-300制作的(从库函数的声明可以看出),连S7-300相对而言比较顺利。
组态王、力控好多主流工控软件访问西门子PLC都是通过Prodave或Softnet的,可以在驱动程序中看到熟悉的W95_s7.dll,所以通信能力大家还是应该放心的。
题外话,对嵌入式系统,如WinCE,由于不能直接使用Prodave和Softnet,所以要实现与西门子PLC通信,一般只有破解了(西门子的通信协议都是保密的,并且也是加密的,一般不公开给客户),目前实现的较好的主要有PPI,MPI(需要MPI适配器,不同适配器通信协议有一定区别),CP243,CP343/CP443。
下面是我在开发相关西门子通信程序时,做的一个VC测试程序,仅供参考(Prodave简版驱动和相关测试代码,我已经上传,文章后面附下载连接)。
voidCTestDlg::OnProdave()
{
intiRes;
CStringmyStr;
signedcharBuffer[2048];
WORD*Buffer_int=(WORD*)Buffer;
unsignedchar*Buffer_byte=(unsignedchar*)Buffer;//WORDwValue;
//m_field_readMB200
iRes=m_field_read(200,1,Buffer);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
myStr.Format("MB200=%3d",Buffer_byte[0]);
m_Dis.ReplaceSel(myStr);
UpdateData(false);
}
else
{
//myStr.Format("m_field_readerrorno:%d",iRes);
AfxMessageBox(ErrString(iRes));
}
//m_field_read
iRes=m_field_read(100,1,Buffer);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
myStr.Format("MB100=%3d",Buffer_byte[0]);
m_Dis.ReplaceSel(myStr);
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
//m_field_read
iRes=a_field_read(0,1,Buffer);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
myStr.Format("QB0=%3d",Buffer_byte[0]);
m_Dis.ReplaceSel(myStr);
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
//写数据MB110
unsignedlongvalue;
value=100;
memcpy(Buffer,&value,4);
iRes=m_field_write(111,1,Buffer);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
myStr.Format("MB110=%3d",Buffer[0]);
m_Dis.ReplaceSel(myStr);
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
//写数据MB4
BYTEvalue1;
value1=33;
memcpy(Buffer,&value,1);
iRes=m_field_write(4,1,Buffer);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
myStr.Format("MD4=%3d",Buffer[0]);
m_Dis.ReplaceSel(myStr);
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
}
voidCTestDlg::OnLoad()
{
adr_table_typemyTable[2];
myTable[0].adr=3;
myTable[0].segmentid=0;
myTable[0].slotno=2;
myTable[0].rackno=0;
myTable[1].adr=0;
myTable[1].segmentid=0;
myTable[1].slotno=2;
myTable[1].rackno=0;
intiRes;
CStringmyStr;
//初始化ProDave300
iRes=load_tool(1,"S7ONLINE",myTable);
if(iRes==0)
{
m_Dis.SetSel(30000,30000);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("load_toolok!");
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
unload_tool();
return;
}
}
voidCTestDlg::OnUnloadtool()
{
intiRes;
CStringmyStr;
iRes=unload_tool();
if(iRes==0)
{
m_Dis.SetSel(30000,30000);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("unload_toolok!");
m_Dis.ReplaceSel(" ");
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
}
voidCTestDlg::OnStatus()
{
intiRes;
CStringmyStr;
charmyInfo[512];
iRes=ag_zustand(myInfo);
if(iRes==0)
{
m_Dis.SetSel(30000,30000);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("ag_zustandok!");
UpdateData(false);
if(myInfo[0]==0)
{
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("RUN");
}
else
{
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("STOP");
}
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
}
}
LPSTRCTestDlg::ErrString(WORDwErrCode)
{
LPSTRmyStr1;
switch(wErrCode)
{
case517:
{
return"PRODAVEnotinitialized.";
break;
}
case787:
{
return"Incorrectrate/Interruptvector.";
break;
}
case789:
{
return"MPIAddresserror.";
break;
}
case800:
case818:
{
return"hardwarefault.";
break;
}
case820:
{
return"comnotavaliable.";
break;
}
case898:
case900:
{
return"nodriverordevicefound.";
break;
}
case16386:
{
return"Connectionnotestablished.";
break;
}
default:
{
CStringmyStr;
myStr.Format("%d",wErrCode);
myStr1=myStr.GetBuffer(0);
myStr.ReleaseBuffer();
returnmyStr1;
}
}
}
voidCTestDlg::OnNewss()
{
//激活连接
intiRes;
iRes=new_ss(1);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("new_ssok!");
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
unload_tool();
return;
}
}
voidCTestDlg::OnAginfo()
{
//读PLC信息
intiRes;
charmyInfo[512];
iRes=ag_info(&myInfo[0]);
if(iRes==0)
{
m_Dis.SetSel(100000,100000);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel("ag_infook!");
UpdateData(false);
m_Dis.ReplaceSel(" ");
m_Dis.ReplaceSel(&myInfo[4]);
UpdateData(false);
}
else
{
AfxMessageBox(ErrString(iRes));
unload_tool();
return;
}
}
prodave 测试程序:http://download.csdn.net/source/228758
Prodave简版驱动:http://download.csdn.net/source/228765
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>
相关推荐
PRODAVE5.5.part2.rar PC PLC开发包
PRODAVE 5.5rar,PRODAVE 5.5
Prodave5.5 下载Prodave5.5_a,Prodave5.5_b,解压到同一文件夹即可
西门子PLC Prodave5.5编程 需要的留个邮箱qq:57476662 email:lkl_xz@163.com
西门子Prodave简版安装程序,完全版要40多兆
Prodave5.5 b 下载Prodave5.5_a,Prodave5.5_b,解压到同一文件夹即可
西门子PLC的通信协议主要是PPI、MPI、Profibus、CP243CP343CP443 网络协议,prodave是早期完成的程序接口,除了网络协议外其它的主要协议都支持
prodave 5.5手册使用说明书,包含prodave 5.5内函数的具体用法
西门子Prodave相关资料,在开发pc机与西门子PLC通信的驱动程序时要用的。
西门子Prodave6.0在C#中的应用
西门子开发包 可直接写电脑程序和PLC通信
西门子Prodave5.5 VC测试程序,这是我开发相关程序是做的一个测试程序,注意运行前需要安装Prodave5.5程序,并连接配置好相关西门子PLC设备
西门子PLC 数据导出,通过Prodave 6.2 dll,vc源码
siemens plc+vb vc 关于prodave的使用说明及下载地点 很好的学习资料
西门子PRODAVE 6.0 S7-300与计算机直接通讯 采用MPI和以太网通讯方式
将该文件放在程序所在目录下,即可通过error_message函数获得错误的具体信息,便于调试和发现问题。 具体信息可参见上传的另一资源“西门子Prodave S7 V5.6工具箱英文手册"第57页。
-使用PRODAVE6_IE.dll类库,其中的接口均为中文接口; -读取的数据长度测试最长为40组数据; -PRODAVE6.Dll控件请与接口类库控件放在一起使用; -类库使用没有任何限制; -西门子通讯的前提需要安装西门子编程软件,建立好...
需要用prodave实现PC与西门子200/300/400plc通讯必须要看的,包过基本问题以及一些FAQ,内有vb及vc实现的例子。
prodave的使用说明书,有vb&vc两种例子
西门子英文网站上的手册,有函数调用示例(MPI 6.0没有示例)。建议用MPI编程的朋友先看看MPI5.6版本,再看6.0。