wjun7610
级别: 略有小成
精华主题: 0
发帖数量: 127 个
工控威望: 249 点
下载积分: 708 分
在线时间: 31(小时)
注册时间: 2007-09-16
最后登录: 2024-05-06
查看wjun7610的 主题 / 回贴
楼主  发表于: 2013-06-22 19:51
Omron_Fins.dll V1.0 Fins通信协议串口通讯动态链接库DLL(以下简称DLL),是为满足工业通信需要,

针对工业领域要求上位机对欧姆龙系列PLC通讯实时采集与控制的组态编程而设计。

可以适用于常用的各种开发环境如:Vb6、Vb.net、Delphi、C#、VC++、powerbuilder、易语言、labviEW等进行上位机软件开发。

本DLL是采用Delphi语言开发的标准串口通讯库,具有以下特点:

1)、遵循欧姆龙最新Fins通信协议;

2)、支持多串口并发操作,支持多线程串口通讯,将串口通讯对主程序的影响降至最低;

3)、实时性、可靠性好,通用性强;

4)、适用于多PLC(下位机)联网和上位机通信,满足多方面的需要;

5)、函数接口功能全,操作简单,支持欧姆龙PLC的绝大部分地址的读写功能函数;

6)、支持USB、PC扩展卡等扩展串口号;

7)、支持多种操作系统win2000/winXP/Win7(标准Win32 DLL);

8)、易于快速开发(VC等非RAD开发环境的开发);

9)、采用数组指针调用数据发生与接收,初学者快速入门;对于不方便使用指针的开发环境可采用DLL缓冲区传递;

10)、可在多种编程环境下使用,例如VB、VC、Delphi、PB、Labview、易语言等开发环境;

11)、扩展了函数功能读取下位机中的双字、单精度浮点等类型数据,更加符合工业自动化领域的工控软件的开发。

软件版本及相关说明:

Omron_Fins.dll V1.0 Fins通信协议串口通讯链接库,实现了对欧姆龙全系列PLC的Fins协议的支持,

wangjun于2013年在原有Omron_HostLink.dll V3.2版基础上基于Finsi协议重写通讯底层协议结构。

对于16位整数和32位整数读取写入均按有符号整数处理,小数的返回按单精度浮点型(2进制浮点)

处理读取方式。提供扩展功能函数,方便用户实现混合数据读取。能够同时满足32个串口并发

情况下的正常使用。

Omron_Fins.dll V1.0 分为完美版和单机版两个版本。

注意:实例在使用时不能超出试用版的地址限制,否则无法正确通讯。


龙帅工作室为您提供专业串口通讯控件,也可为您订制

专用通讯协议串口控件。目前龙帅系列串口通讯协议

控件包括modbus_rtu、modbus_tcp、三菱FX PLC编程口、

欧姆龙HostLink、西门子PPI等多个系列产品。

淘-宝-店:http://shop34821629.taobao.com

电 话:13912935690

腾讯QQ:157610979

阿里旺旺: wj_longshuai

邮 箱:[url=mailto:157610979@QQ.com]157610979@QQ.com[/url] ;   [url=mailto:chinawanglong@163.com]chinawanglong@163.com[/url]
[ 此帖被wjun7610在2016-11-24 14:06重新编辑 ]
附件: 欧姆龙fins协议动态库.rar (1353 K) 下载次数:652
网站提示: 请不要用迅雷下载附件,容易出错
wjun7610
级别: 略有小成
精华主题: 0
发帖数量: 127 个
工控威望: 249 点
下载积分: 708 分
在线时间: 31(小时)
注册时间: 2007-09-16
最后登录: 2024-05-06
查看wjun7610的 主题 / 回贴
1楼  发表于: 2013-06-22 19:52
DLL串口操作函数包括:

  1)、finsComOpen打开串口;

     finsCvComOpen打开串口; //CV模式通讯串口打开

  2)、finsComClose关闭串口;
      
  3)、finsSetDelay串口通讯延时设定;
                    
  4)、finsComTrue判断串口是否打开成功;
            
  5)、finsComWork判断串口是否正在工作中;

Fins协议基本功能函数包括:

  1)、finsPlcRs  读取PLC运行状态;

  2)、finsPlcWs 更改PLC运行状态;  

  3)、finsBitForced  PLC位元件强制;

  4)、finsCancelAllF 取消全部PLC强制;

  5)、finsReadBit 读PLC位元件值;

  6)、finsReadInt 读PLC字元件值;

  7)、finsWriteBit 写PLC位元件值;  

  8)、finsWriteInt 写PLC字元件值;

Fins协议扩展功能函数包括:

  1)、finsSet PLC的位元件置位;

  2)、finsReSet PLC的位元件复位;  

  3)、finsReadDInt 读PLC的双字整数值;

  4)、finsReadFloat 读PLC的浮点数据值;

  5)、finsWriteDInt 写PLC的双字整数值;

  6)、finsWriteFloat 写PLC的浮点数据值;

Fins协议DLL缓冲区传递功能函数包括

  1)、finsClearBuf  清除复位DLL缓存区;

  2)、finsReadBitBuf 读PLC的位元件值  

  3)、finsReadIntBuf 读PLC的字元件值;

  4)、finsReadDIntBuf 读PLC双字整数值;

  5)、finsIntDllBufRead 读DLL整数缓存区值;

  6)、finsReadFloatBuf 读PLC浮点数据值;  

  7)、finsFloatDllBufRead 读DLL浮点缓存区值;

  8)、finsWriteIntDllBuf  写DLL整数缓存区值;

  9)、finsBitBufWrite  写PLC的位元件值;

  10)、finsIntBufWrite 写PLC的字元件值;  

  11)、finsDIntBufWrite 写PLC双字整数值;

  12)、finsWriteFloatDllBuf 写DLL浮点缓存区值;  

  13)、finsFloatBufWrite 写PLC浮点数据值;
当需要进行16位整数、32位整数、32位浮点数值进行混合读写时,所需拓展函数包括:

  1)、DecBitBin  字整数的位抽取;

  2)、Int32ToInt_16h  双字到字转换高位字;  

  3)、Int32ToInt_16l  双字到字转换低位字;

  4)、Int16ToInt32  字到双字的转换;

  5)、Float32ToInt_16h 浮点到字转换高位字;

  6)、Float32ToInt_16l 浮点到字转换低位字;

  7)、Int16ToFloat32  字到浮点的转换;

  8)、Int16Unsign   16位有符号整数转无符号整数  
wjun7610
级别: 略有小成
精华主题: 0
发帖数量: 127 个
工控威望: 249 点
下载积分: 708 分
在线时间: 31(小时)
注册时间: 2007-09-16
最后登录: 2024-05-06
查看wjun7610的 主题 / 回贴
2楼  发表于: 2013-06-22 19:52
在VC中使用DLL一般都是采用动态声明的方式,函数说明中给出的是Delphi的函数原型,

在VC中声明时只要注意一下类型的对应即可,Delphi中的longint类型对应VC中的int类型

Delphi中的Pchar对应VC中的char* ,下面给出主要函数的声明:

在使用的文件的cpp中声明一个句柄:

HINSTANCE hinstDLL;

用来标识导入的动态链接库。

1)、按下例说明声明相关各个函数:(在cpp文件的头处声明)

typedef int (_stdcall *pOpen)(int nport, int BaudRate, int DataBits, char* Parity, int StopBits, char* User);
typedef int (_stdcall *pClose)(int nport);
typedef int (_stdcall *pSetDelay)(int value);
typedef int (_stdcall *pComTrue)(int nport);
typedef int (_stdcall *pComWork)(int nport);

typedef int (_stdcall *pRs)(int nport, int node);
typedef int (_stdcall *pWs)(int nport, int node, int State);
typedef int (_stdcall *pBitForced)(int nport, int node, int address, int Bit, int value, char* Area);
typedef int (_stdcall *pCancelAllF)(int nport, int node);
typedef int (_stdcall *pReadBit)(int nport, int node, int address, int Bit, int Count, char* Area, int* RxdBuffer);
typedef int (_stdcall *pReadInt)(int nport, int node, int address, int Count, char* Area, int* RxdBuffer);
typedef int (_stdcall *pWriteBit)(int nport, int node, int address, int Bit, int Count, char* Area, int* TxdBuffer);
typedef int (_stdcall *pWriteInt)(int nport, int node, int address, int Count, char* Area, int* TxdBuffer);

typedef int (_stdcall *pSet)(int nport, int node, int address, int Bit, char* Area);
typedef int (_stdcall *pReSet)(int nport, int node, int address, int Bit, char* Area);
typedef int (_stdcall *pReadDInt)(int nport, int node, int address, int Count, int* RxdBuffer);
typedef int (_stdcall *pReadFloat)(int nport, int node, int address, int Count, float* RxdBuffer);
typedef int (_stdcall *pWriteDInt)(int nport, int node, int address, int Count, int* TxdBuffer);
typedef int (_stdcall *pWriteFloat)(int nport, int node, int address, int Count, float* TxdBuffer);

typedef int (_stdcall *pBitBin)(int value, int Bitaddress);
typedef int (_stdcall *p32I_16h)(int value);
typedef int (_stdcall *p32I_16l)(int value);
typedef int (_stdcall *p16I_32I)(int valueH, int valueL);
typedef int (_stdcall *p32f_16h)(float value);
typedef int (_stdcall *p32f_16l)(float value);
typedef float (_stdcall *p16I_32f)(int valueH, int valueL);
typedef int (_stdcall *pInt16Unsign)(int value);

2)、建立动态链接库的新函数名:(在cpp文件的头处声明)

pOpen mOpen;
pClose mClose;
pSetDelay mSetDelay;
pComTrue mComTrue;
pComWork mComWork;

pRs mRs;
pWs mWs;
pBitForced mBitForced;
pCancelAllF mCancelAllF;
pReadBit mReadBit;
pReadInt mReadInt;
pWriteBit mWriteBit;
pWriteInt mWriteInt;

pSet mSet;
pReSet mReSet;
pReadDInt mReadDInt;
pReadFloat mReadFloat;
pWriteDInt mWriteDInt;
pWriteFloat mWriteFloat;

pBitBin mBitBin;
p32I_16h m32I_16h;
p32I_16l m32I_16l;
p16I_32I m16I_32I;
p32f_16h m32f_16h;
p32f_16l m32f_16l;
p16I_32f m16I_32f;
pInt16Unsign mInt16Unsign;

3)、导入动态链接库,如例所示:(在cpp文件的OnInitDialog过程建立):

hinstDLL = LoadLibrary("Omron_fins.dll");

4)、判断dll文件是否存在并声明并建立动态链接库中的函数与新函数名的对应关系,

如下:(在cpp文件的OnInitDialog过程建立):

   if (hinstDLL)
   {
      mOpen = (pOpen)GetProcAddress (hinstDLL,"finsComOpen");
      //mOpen = (pOpen)GetProcAddress (hinstDLL,"finsCvComOpen");  CV模式plc使用这个打开串口
      mClose = (pClose)GetProcAddress (hinstDLL,"finsComClose");
      mSetDelay = (pSetDelay)GetProcAddress (hinstDLL,"finsSetDelay");
      mComTrue = (pComTrue)GetProcAddress (hinstDLL,"finsComTrue");
      mComWork = (pComWork)GetProcAddress (hinstDLL,"finsComWork");
    
      mRs = (pRs)GetProcAddress (hinstDLL,"finsPlcRs");
      mWs = (pWs)GetProcAddress (hinstDLL,"finsPlcWs");
      mBitForced = (pBitForced)GetProcAddress (hinstDLL,"finsBitForced");
      mCancelAllF = (pCancelAllF)GetProcAddress (hinstDLL,"finsCancelAllF");
      mReadBit = (pReadBit)GetProcAddress (hinstDLL,"finsReadBit");
      mReadInt = (pReadInt)GetProcAddress (hinstDLL,"finsReadInt");
      mWriteBit = (pWriteBit)GetProcAddress (hinstDLL,"finsWriteBit");
      mWriteInt = (pWriteInt)GetProcAddress (hinstDLL,"finsWriteInt");

      mSet = (pSet)GetProcAddress (hinstDLL,"finsSet");
      mReSet = (pReSet)GetProcAddress (hinstDLL,"finsReSet");
      mReadDInt = (pReadDInt)GetProcAddress (hinstDLL,"finsReadDInt");
      mReadFloat = (pReadFloat)GetProcAddress (hinstDLL,"finsReadFloat");
      mWriteDInt = (pWriteDInt)GetProcAddress (hinstDLL,"finsWriteDInt");
      mWriteFloat = (pWriteFloat)GetProcAddress (hinstDLL,"finsWriteFloat");


     mBitBin = (pBitBin)GetProcAddress (hinstDLL,"DecBitBin");
     m32I_16h = (p32I_16h)GetProcAddress (hinstDLL,"Int32ToInt_16h");
     m32I_16l = (p32I_16l)GetProcAddress (hinstDLL,"Int32ToInt_16l");
     m16I_32I= (p16I_32I)GetProcAddress (hinstDLL,"Int16ToInt32");
     m32f_16h = (p32f_16h)GetProcAddress (hinstDLL,"Float32ToInt_16h");
     m32f_16l = (p32f_16l)GetProcAddress (hinstDLL,"Float32ToInt_16l");
     m16I_32f= (p16I_32f)GetProcAddress (hinstDLL,"Int16ToFloat32");
     mInt16Unsign = (pInt16Unsign)GetProcAddress (hinstDLL,"Int16Unsign");
  
     AfxMessageBox("Omron_fins.dll已成功载入!");
  }
  else
{
    AfxMessageBox("没找到Omron_fins.dll!");
    SendMessage(WM_CLOSE);
  }

注:双引号中为动态链接库中的原有函数名。


函数中用到了char*型参数,这里介绍下char*与Cstring的相互转换的函数:

(1)char*->CString

char* sz;
CString str;
str.Format("%s",sz);  //可以用此函数将读取的值转成字符串

(2) CString -> char*

CString str;
char* sz = str.GetBuffer(0);//可将字符串转成char*给函数赋值


5)、当不再需要使用DLL时记得关闭串口及释放动态链接库,(在OnDestroy事件中释放)

if(hinstDLL)
{
   int k = mComTrue(mnport);
   if (k==1)
   {
      mClose(mnport);
   }    
   FreeLibrary(hinstDLL);
}
cmsn
级别: 略有小成
精华主题: 0
发帖数量: 275 个
工控威望: 451 点
下载积分: 1027 分
在线时间: 276(小时)
注册时间: 2012-09-10
最后登录: 2024-05-08
查看cmsn的 主题 / 回贴
3楼  发表于: 2013-06-22 20:57
这个关注下
manjialin
专业工业控制软件开发!
级别: 略有小成
精华主题: 0
发帖数量: 144 个
工控威望: 334 点
下载积分: 718 分
在线时间: 110(小时)
注册时间: 2008-11-28
最后登录: 2020-08-26
查看manjialin的 主题 / 回贴
4楼  发表于: 2013-07-02 08:55
干了那么多年软件开发,第一次听说OMRON能全系支持FINS
945785181
做自己,信自己。
级别: 探索解密
精华主题: 0
发帖数量: 20 个
工控威望: 128 点
下载积分: 619 分
在线时间: 17(小时)
注册时间: 2011-01-15
最后登录: 2015-08-13
查看945785181的 主题 / 回贴
5楼  发表于: 2013-07-11 09:14
下载下来都不能解压的