windows环境下高速数据采集 (提供源程序的我会在开一贴另送100-200分,如果有虚拟仪器的源程序我再加100-200分。) (200分)

  • 主题发起人 主题发起人 gaozhou
  • 开始时间 开始时间
{ -----------------------------------------------------------------------------}<br>{ 更新日期: &nbsp;29/3/2002 &nbsp;修改作者:司马华鹏 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>{ -----------------------------------------------------------------------------} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>{ 这个模块是单独的数模转换函数模块 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>{------------------------------------------------------------------------------}<br><br>unit UnitAD;<br><br>interface<br><br>&nbsp; function PortReadByte(Addr:Word):Byte;<br>&nbsp; function PortreadWord(Addr:Word):Word;<br>&nbsp; Function PortReadWordLs(Addr:Word):Word;<br>&nbsp; Procedure PortWriteByte(Addr:Word;Value:Byte);<br>&nbsp; Procedure PortWriteWord(Addr:Word;Value:Word);<br>&nbsp; Procedure PortWriteWordLs(Addr:Word;Value:Word);<br>&nbsp; &nbsp;<br>implementation<br><br>//PortReadByte函数<br>//参数:端口地址<br>//返回:从指定端口得到的单字节值(8位)<br><br>Function portReadByte(Addr:Word):Byte;assembler;register;<br>asm<br>&nbsp; &nbsp; MOV DX,AX<br>&nbsp; &nbsp; IN AL,DX<br>end;<br><br>//高速读取端口函数 PortReadWord 函数<br>//参数:端口地址<br>//返回从指定端口得到的双字节值(16位)<br>//注意:可能有些卡和计算机不能访问全部Word<br><br>Function PortReadWord(Addr:Word):Word;assembler;register;<br>asm<br>&nbsp; &nbsp; MOV DX,AX<br>&nbsp; &nbsp; IN AX,DX<br>end;<br><br>//低速读端口值 :PortReadWordLs<br>// 参数:端口地址<br>//返回从指定端口得到的双字节值(16位)<br>//注意工作时要调整延迟<br><br>Function PortReadWordLs(Addr:Word):Word;assembler;Register;<br>const<br>&nbsp; &nbsp; DELAY=150;<br>&nbsp; &nbsp; //依靠CPU的速度和卡的速度<br>Asm<br>&nbsp; &nbsp; MOV DX,AX<br>&nbsp; &nbsp; IN AL,DX<br>&nbsp; &nbsp; //读LSB端口<br>&nbsp; &nbsp; MOV ECX,DELAY<br>&nbsp; &nbsp; @1:<br>&nbsp; &nbsp; LOOP @1 &nbsp; &nbsp; &nbsp; //在两次读之间延时<br>&nbsp; &nbsp; XCHG AH,AL<br>&nbsp; &nbsp; INC DX &nbsp; &nbsp; &nbsp; &nbsp;//端口地址加一<br>&nbsp; &nbsp; IN AL,DX &nbsp; &nbsp; &nbsp;//读MSB端口<br>&nbsp; &nbsp; XCHG AH,AL &nbsp; &nbsp;//重新存储字节顺序<br>end;<br><br>//写端口 :PortWriteByte函数<br><br>Procedure PortWriteByte(addr:Word;value:byte);assembler;register;<br>asm<br>&nbsp; &nbsp; XCHG AX,DX<br>&nbsp; &nbsp; OUT DX,AL<br>end;<br><br>//高速写端口 :PortWriteWord函数<br>Procedure PortWriteWord(Addr:Word;Value:Word);assembler;register;<br>asm<br>&nbsp; &nbsp; XCHG AX,DX<br>&nbsp; &nbsp; OUT DX,AX<br>end;<br><br>//低速写端口函数<br>Procedure PortWriteWordLS(Addr:Word;Value:Word);assembler;register;<br>const<br>&nbsp; &nbsp; &nbsp;DELAY=150;<br>asm<br>&nbsp; &nbsp; XCHG AX,DX<br>&nbsp; &nbsp; OUT DX,AL<br>&nbsp; &nbsp; MOV ECX,DELAY<br>&nbsp; &nbsp; @1:<br>&nbsp; &nbsp; LOOP @1<br>&nbsp; &nbsp; XCHG AH,AL<br>&nbsp; &nbsp; INC DX<br>&nbsp; &nbsp; OUT DX,AL<br>end;<br><br><br><br>end.<br>
 
你要达到的要求不是很高,我做过的也是数据采集分析的东东。当时我外設是可以支持1394<br>接口的
 
to 墙头草,<br>&nbsp; 请详细地说一下。
 
其实原理很简单,当时提供的硬件附有计算机断口操作说明并且提供了dll形式的函数。<br>麻烦的是,当时提供的dll的函数是用c调用的。你一定知道c和delphi的参数定义有的时候是<br>不同的,所以我得大量工作是将c形式的参数转化为delphi认的参数。想研究的话留下mail,<br>呵呵你有什麽好的代码也给我来一份:)
 
不知道大家有没有想过每个协议做成驱动程序,然后只要装载其驱动,就可以完成通讯。<br><br>当然这还不行,采集的数据就是为了显示,所以要想法子让数据交换。比如DDE...OPC<br>
 
to 墙头草,<br>&nbsp; 我的mail:mlzhougao@163.com
 
我做过这方面的东西,而且已经形成商品了,有兴趣可以和我交流一下<br>lsgd1688@163.com
 
哦很感兴趣,收藏一下。
 
to 爱元元的哥哥:你那个代码应用于哪一块哪?<br><br>
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部