MasterLink FAQ



  1. What compilers can I use with the MasterLink software libraries?
  2. What is needed to compile a sample program using a Microsoft 4.0 or 5.0 compiler?
  3. How do I compile the sample programs that came with this software for the specific data acquisition board that I have purchased?
  4. How can I tell if the MasterLink software drivers have been loaded properly on my computer system?

1. What compilers can I use with the MasterLink software libraries?

Compilers supported for all our software drivers are:

  • Windows 3.x/95/98/ME/NT/2000
    Microsoft C/C++
    Borland C/C++
    Microsoft Visual BASIC
  • DOS
    Microsoft C/C++
    Borland C/C++
    Microsoft QuickBASIC

2. What is needed to compile a sample program using a Microsoft 4.0 or 5.0 compiler?

The following shows what is needed to compile the sample program called AI_CW.C using Microsoft Visual C++ Version 4.0. Version 5.0 should be similiar.










3. How do I compile the sample programs that came with this software for the specific data acquisition board that I have purchased?

The MasterLink Sample programs for both 'C' and Visual Basic are written in a way that can be used with any of our boards with just a few minor modifications. The following document should answer any questions on how to do this:

Introduction
Our boards are either I/O mapped or Memory-Mapped boards. There are a switches on the board that allow you to select a specific address. Each address must be different on each board used.

What the Sample Programs Do Not Demonstrate
Some of our boards are "Carrier" boards, i.e. they have the ability to have added to them various additional hardware modules, like analog expansion, or additional digital channels. The sample programs are not written to access these expansion modules. But with a good understanding of how the sample programs work, the ability to write code to collect data from any expansion module on a carrier board is possible. The sample programs also do not demonstrate how to access data from multiple boards, either of the same type, or different boards in a single program. This application note includes instructions on how to do this.

Required Modifications
Since we do not know what board a customer is going to purchase, our sample programs are written in a way, where all of our boards will work. There are a few places in the code that require modifications for use of a specific board. There are also certian routines that are used in the sample programs, that are not really necessary to use in a true application.

One of the necessary things to change, required for all our boards is its address. Our boards are either I/O mapped or Memory-Mapped boards. In the sample programs, I/O mapped board addresses are identified using a constant called ADDRESSIO. Boards that are Memory-Mapped use an address that is identified using a constant called SEGMENTISA. Both constants are defined in every sample program. The value needs to be changed to match your boards address. The non-used constant need not be changed or removed.

Some of the sample programs also have a constant called BOARDID. This value also needs to be changed to match the board you are using. In all the sample programs that use the constant BOARDID value, the is a set of comments that identify the BOARDID value that should be used.

The most important modification needed by all sample programs, in a sub-routine called InitRoutine. The 'InitRoutine' is where all boards used in the program get identified and initialized. Since we do not know exactly which board is to be used, we include call routines that initialize all of our boards. You must modify this routine to include only the boards you will be using, you will get error messages.


InitRoutine Example
The InitRoutine subroutine, in most of the sample programs, looks like the following:


void InitRoutine (HWND hWnd)
{
 int error_code;

 error_code = SWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during SWInit");

 error_code = Include98C ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include98C");
 error_code = Include41C ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include41C");
 error_code = Include1C ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include1C");
 error_code = Include428W ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include428W");
 error_code = Include377W ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include377W");
 error_code = Include91W ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include91W");
 error_code = Include89W ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include89W");
 error_code = Include368M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include368M");
 error_code = Include341M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include341M");
 error_code = Include31M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include31M");
 error_code = Include23M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include23M");
 error_code = Include19M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include19M");
 error_code = Include5M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include5M");
 error_code = Include2M ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include2M");

 error_code = SlotAssign (SLOTISA, SEGMENTISA);
 ErrorRoutine (hWnd, error_code,
  "Error during SlotAssign");
 error_code = SlotAssignIO (SLOTIO, ADDRESSIO);
 ErrorRoutine (hWnd, error_code,
  "Error during SlotAssignIO");

 error_code = HWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during HWInit");
}

  To change this routine for a I/O mapped board like the PCI-20428W-1, the ADDRESSIO constant and InitRoutine would need to modified to look as follows:

#define ADDRESSIO 0x350 .... set to switches on the board.


void InitRoutine (HWND hWnd)
{
 int error_code;

 error_code = SWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during SWInit");

 error_code = Include428W();
 ErrorRoutine (hWnd, error_code,
  "Error during Include428W");

 error_code = SlotAssignIO (SLOTIO, ADDRESSIO);
 ErrorRoutine (hWnd, error_code,
  "Error during SlotAssignIO");

 error_code = HWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during HWInit");
}

  To change this routine for a Memory-Mapped board like the PCI-20098C-2F, the SEGMENTISA constant and InitRoutine would need to modified to look as follows:

#define SEGMENTISA 0xcd40 .... set to switches on the board.

void InitRoutine (HWND hWnd)
{
 int error_code;

 error_code = SWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during SWInit");

 error_code = Include98C ();
 ErrorRoutine (hWnd, error_code,
  "Error during Include98C");

 error_code = SlotAssign (SLOTISA, SEGMENTISA);
 ErrorRoutine (hWnd, error_code,
  "Error during SlotAssign");

 error_code = HWInit ();
 ErrorRoutine (hWnd, error_code,
  "Error during HWInit");
}

  You must always have SWInit() at the beginning of the InitRoutine, and HWInit() at the end of the InitRoutine().


Misc. Additions
Each board used must have the appropriate IncludeXXXX() routine. If performing DMA, you will need IncludeDMA(), and IncludeBuf(). If performing Thermocouple readings, you will need IncludeTC(). Please also note that when doing Thermocouple readings, the .TC files included in the Masterlink directory, will need to be placed in the same directory as the location of the executable program that gets created. If these .TC files are not present, you will get a -11000 error code message.

Accessing Hardware with the Sample Programs
The sample programs are written, with accessing data with only a single board, or a single carrier board that contains no addition data acquisition modules.

The following is the command to read a single anaalog input channel from the AI_CW.C sample program:

AIRead(slot,module,channel,kAZChannel,gain,range,differential,(int FAR*) &counts[channel]);

What makes each board unique in any program is the combination use of two values. The first is the 'SLOT' value. For I/O mapped-boards, the 'slot' number is defined by a constant called SLOTIO, and is passed as a parameter in the SlotAssignIO() routine, executed in the InitRoutine(). For memory-mapped boards, the 'slot' number is identified by a constant called SLOTISA, and is passed as a parameter in the SlotAssign() routine, executed in the InitRoutine(). The second value is the 'module' value. The uniqueness of these two numbers is all that is needed to collect data from a particular board.

The value of 'module' on all non-carrier type boards will always be 0 (zero). This includes boards like the PCI-20428W, PCI-20093W, and PCI-20087W. The value of 'module', on our carrier boards depends on which hardware module is being accessed on the carrier board. For example, the PCI-20098C-2F is a multifunction carrier board. It has a on board A/D converter, with on-board analog input channels and two addtional connectors to expand its capabilites. Data collected from the analog and digital channels located on the board itself would use a 'module' value equal to 0 (zero). Data collected from an additional hardware module would use a 'module' value equal to 1 (one). Adding another hardware module, would use a 'module' value equal to 3 (three).


Using Multiple Boards

Using more than one board requires the addition of another set of slot and address values to be defined in the program.

In the sample programs, the constant ADDRESSIO defines the address of a particular I/O mapped board, like the PCI-20428W-1. The constant, SLOTIO, defines the 'slot' value used. Adding a second board, would require defining another new board address, for example, ADDRESSIO_A that matched the I/O address of the second board, and another new slot value, for example SLOTIO_A to define the next slot number, 25. With a additional board, you would need a second SLOTASSIGNIO() routine. The following shows an example of what would be necessary to define two PCI-20428W-1 boards in a single program:

 #define ADDRESSIO 0x300

 #define SLOTIO 24

 #define ADDRESSIO_A 0x320

 #define SLOTIO_A 25

 void InitRoutine (HWND hWnd)

{

  int error_code;

  error_code = SWInit ();

  ErrorRoutine (hWnd, error_code,

     "Error during SWInit");

 

  error_code = Include428W ();

  ErrorRoutine (hWnd, error_code,

    "Error during Include428W");

  error_code = SlotAssignIO (SLOTIO, ADDRESSIO);

  ErrorRoutine (hWnd, error_code,

     "Error during SlotAssignIO");

  error_code = SlotAssignIO (SLOTIO_A, ADDRESSIO_A);

  ErrorRoutine (hWnd, error_code,

     "Error during SlotAssignIO_A");

  error_code = HWInit ();

  ErrorRoutine (hWnd, error_code,

     "Error during HWInit");

}

To read an analog channel from the first board you would need the following command:

  slot= SLOTIO;

  module = 0;

  AIRead(slot,module,channel,kAZChannel,gain,range,differential,(int FAR*)   &counts[channel]);

To read a analog channle from the second board you would need the following command:

  slot= SLOTIO_A;

  module = 0;

  AIRead(slot,module,channel,kAZChannel,gain,range,differential,(int FAR*) &counts[channel]);

Please note that the only difference is the 'slot' value.


Routines Needed Only by the Sample Programs
There are a number of routines that are only needed by the sample programs, and really do not need to be included with a actual application program.

   There are:
   showHWConfiguration()
   SlotInquire()
   getHWComponentName()
   getHWSlotModule()
   findHWComponent()
   GraphData()

These routines try to figure out what type of board is being used. It returns a string containing the name of the board, a slot number, and a module number. They are only useful in the sample programs, and work only if a single board is used and the board has no expansion hardware modules installed.

Program Execution Notes
When doing Thermocouple readings, the .TC files included in the MasterLink directory, will need to be placed in the same directory as the location of the executable program that gets created. If these .TC files are not present, you will get a -11000 error code message.

The DLL called PCI_W32.DLL needs to be located in the same directory as the final executable program that gets created. If running the program from a project file using Borland, Microsoft, or Visual Basic, this PCI_W32.DLL file needs to be place in the same directory where the Interactive Development Enviroment executable program is located.


4. How can I tell if the MasterLink software drivers have been loaded properly on my computer system?

No modifications are made to any .INI files. You don't have to change them yourself either -- no changes are required (unless you already have the drivers for 16-bit applications installed and you want to remove them). The file that 16-bit MasterLink uses, pcivdmad.386, is no longer useful in Windows 95 or NT, even with 16-bit Master Link, so it should not be in your system.ini file at all.

For Windows 95, the MasterLink device driver is called MASTRLNK.VXD and is found in the WINDOWS\SYSTEM directory. The virtual DMA device is called VDMAD.VXD and is found in the Windows WINDOWS\SYSTEM\VMM32 directory (if this file is in the right location, it will be loaded automatically on start-up).

For Windows NT, there is only one file, called MASTR_NT.SYS, which is installed in the Windows SYSTEM32\DRIVERS directory. You can tell if this driver was properly installed by (after the required reboot after installation), opening the Control Panel, double-clicking on the Devices item and looking for an entry for MasterLink. The entry should indicate that the device is started and starts automatically.

An easy way to verify that the driver is installed, whether on NT or 95, is to run a simple Visual Designer diagram to do some I/O with a board. You'll get a specific error if Master Link can't open MASTRLNK.VXD or MASTR_NT.SYS.

If the file is not present, you must re-install the MasterLink software and select the proper driver when asked and let the installation, transfer the file, along with updating the proper registry entries.


Price Information

View online pricing for all of our products


Free Downloads

Download white papers, manuals, drivers, more...


Request Information

Request literature, quotations, tech support


 
Subscribe to our newletter:
Your name:
Email:
 Edit your data






edascecom pageid374
edascedate20080807
edascemonth200808
English

1