MODBUS Communications Driver
Important DLL Usage Notes
MODBUS is a 16-bit protocol. Accordingly, most of the integer variables used by the MODBUS Driver DLL are 16-bit integers (short in most 32-bit Windows C compilers).
This is especially important when working with arrays. All arrays used by the Driver contain 16-bit integers! Compiler type checking should help to protect you from inadvertent use of 32-bit integers (the standard C int in 32-bit mode).
The only exception is register addresses, which can exceed the 16-bit integer limit of 32767. In a typical C program, these would be passed as unsigned short. However, Visual Basic has no unsigned integer type. Since many Driver developers use VB, register addresses are passed as long to accommodate that language.
Loading the DLL
When creating a program that uses the MODBUS Driver DLL, you need to make sure that the DLL itself is accessible, both during development and when installing your finished program on an end-user’s machine. This means that the DLL must be in the application directory, the Windows System directory (SYSTEM32 for Windows NT), or the Windows directory.
If Windows cannot find the Driver DLL file (called MBDRVDLL.DLL for the 32 bit version and MBDRV16.DLL for the 16 bit version) when it is launching your application, it will close the program after displaying a cryptic error message.
Programmers familiar with Windows API calls can make sure that Windows can find the DLL before attempting to use it. This can help prevent a type of error that is often frustrating and confusing to end- users.
The “Missing” DLL
Users of the Windows 95 and NT platforms occasionally call ACS to report that we have shipped them a disk containing no Driver DLL. Actually, the DLL is on the installation disk, but it can be “invisible” due to settings in the Windows Explorer.
By default, the Windows Explorer hides certain “system” file types, presumably to protect those files from accidental deletion. Among others, the Explorer considers any file with a .DLL extension to be a system file.
To make system files visible, open an Explorer window and select the “View / Options…” dialog box. In the “Hidden Files” frame, select the “Show All Files” radio button and click “OK.” This will make the Driver DLL visible.
June 6, 1998