0% found this document useful (0 votes)
456 views30 pages

IFD5 Manual - Issue 5

This document provides instructions for installing and using the Armfield IFD5 General Purpose Interface Device. The IFD5 connects laboratory equipment to a PC to allow data exchange. It connects to equipment via a 50-way cable and to a PC via USB. Software must be installed to enable data logging and control capabilities. The IFD5 has LED indicators and requires no external power in most cases. Instructions are provided for installation, software installation, and troubleshooting communication issues.

Uploaded by

Carra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
456 views30 pages

IFD5 Manual - Issue 5

This document provides instructions for installing and using the Armfield IFD5 General Purpose Interface Device. The IFD5 connects laboratory equipment to a PC to allow data exchange. It connects to equipment via a 50-way cable and to a PC via USB. Software must be installed to enable data logging and control capabilities. The IFD5 has LED indicators and requires no external power in most cases. Instructions are provided for installation, software installation, and troubleshooting communication issues.

Uploaded by

Carra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

INSTRUCTION MANUAL

IFD5

GENERAL PURPOSE
INTERFACE DEVICE
IFD5

ISSUE 5
FEBRUARY 2006
ARMFIELD LIMITED
OPERATING INSTRUCTIONS
IFD5
GENERAL PURPOSE INTERFACE DEVICE

SAFETY IN THE USE OF EQUIPMENT SUPPLIED BY ARMFIELD ......... 1


INTRODUCTION.............................................................................................. 2
RECEIPT OF EQUIPMENT.............................................................................. 3
DESCRIPTION .................................................................................................. 4
INSTALLATION ............................................................................................... 5
SOFTWARE INSTALLATION......................................................................... 6
I/O PORT PIN FUNCTIONS............................................................................. 8
APPENDIX 1 – Using third party software to access the IFD5....................... 11
IFD5 Interface Manual
SAFETY IN THE USE OF EQUIPMENT SUPPLIED BY ARMFIELD
Before proceeding to install, commission or operate the equipment described in
this instruction manual we wish to alert you to potential hazards so that they
may be avoided.
Although designed for safe operation, any laboratory equipment may involve
processes or procedures which are potentially hazardous.
The IFD5 should not be exposed to water, moisture or other chemicals.
Accidents can be avoided provided that equipment is regularly maintained
and staff and students are made aware of potential hazards. A list of general
safety rules is included in this manual, to assist staff and students in this
regard. The list is not intended to be fully comprehensive but for guidance
only.

1
IFD5 Interface Manual
INTRODUCTION
The Armfield IFD5 is a general-purpose interface device, which can be used
with many pieces of Armfield equipment, allowing data to be exchanged
between the process unit and a PC with suitable software. The IFD5 connects
to Armfield equipment using a 50-way data cable, and to the PC using the USB
port, requiring no modification of PC hardware.
Armfield can supply educational software designed for use with the IFD5,
which is specific to each piece of equipment. This software includes data
logging and control capability (as applicable), tabular and graphical display of
results and full help texts which explain how to use the equipment and perform
experiments.
It is also possible to use the IFD5 interface to log data to a user supplied third
party program, such as Microsoft Excel, National Instruments LabView or
Mathworks Matlab. Appendix 1 explains how to install the relevant driver
software to enable a third party program to access the data interface, and details
the procedures for creating a basic data logger within LabView, Matlab and
Excel.

2
IFD5 Interface Manual
RECEIPT OF EQUIPMENT
1. SALES IN THE UNITED KINGDOM
The apparatus should be carefully unpacked and the components checked
against the Advice Note. A copy of the Advice Note is supplied with this
instruction manual for reference.
Any omissions or breakages should be notified to Armfield Ltd within three
days of receipt.
2. SALES OVERSEAS
The apparatus should be carefully unpacked and the components checked
against the Advice Note. A copy of the Advice Note is supplied with this
instruction manual for reference.
Any omissions or breakages should be notified immediately to the Insurance
Agent stated on the Insurance Certificate if the goods were insured by Armfield
Ltd.
Your own insurers should be notified immediately if insurance was arranged by
yourselves.

3
IFD5 Interface Manual
DESCRIPTION
The IFD5 is shown in Figure 1. The front panel of the unit consists of a 50-way
IDC header which carries the signals to and from the equipment (1), a red
‘power’ LED (2) which lights when the unit is connected to the PC and a green
‘active’ LED (3) which lights when the unit has been recognised by the PC.
The rear panel of the unit consists of the USB connector, which carries the
signals to the PC’s USB port (4) and a power supply socket (5), which is not
normally used.

2 1 3

5 4

Instrument Solutions
ARM USB Interface
H/W Iss 1 S/W Iss 1
Serial No 00796

Figure 1 – IFD 5 front and rear panels


In some cases, two IFD5s are used in unison. In this case, one of the devices
will be marked ‘expansion’. The marking showing whether the unit is a
‘master’ or ‘expansion’ is on the label on the top panel of the unit.
The IFD5 and associated software is designed to work with Windows 98 or
Windows 2000. The device will not work with older versions of the Windows
operating system, since they do not support Universal Serial Bus (USB)
technology.

4
IFD5 Interface Manual
INSTALLATION
The IFD5 is normally powered form the PC via USB port, so no external
connection is necessary. If however, another USB device is being used which
is also taking power from the USB port, then the current limit of the USB may
be exceeded. In this case, it will be necessary to power the IFD5 using the
power socket (5) on the rear of the unit (9-15V @ 120mA).
Ensure that the software supplied with the IFD5 is installed before connecting
the interface to the computer (see page 6 for details on software installation).
With the PC switched on, connect USB port on the IFD5 (4) to a USB port on
the computer, using the USB cable supplied. When connected, the red ‘power’
LED (2) on the front of the unit should illuminate. The green ‘active’ LED (3)
will also illuminate a short time later. This indicates that communications are
established between the IFD5 and the PC. If the ‘active LED’ fails to light,
disconnect the device, wait for about 30 seconds and then try again. If the LED
still fails to light, re-start the computer and try again.
The PC will then display a message saying that it has found new hardware and
the new hardware wizard should find the files it requires automatically. If this
does not happen, insert the ArmSoft CD-ROM into the drive, and direct the
wizard to look at the CD drive when prompted to do so.
Connect the data port on the IFD5 (1) to that on the apparatus using the 50-way
ribbon cable supplied. The socket for this on the equipment can be found on
the rear of the console for equipment with a separate console or on the side of
the plinth for items with integral console (refer to the instruction manual for
your apparatus for details).
When connecting two IFD5s, it should not matter which device is connected
first. However, if the software fails communicate with either of the devices
(indicated in the status bar at the bottom of the screen), disconnect one of the
IFD5s for about 30 seconds and then re-connect it.

5
IFD5 Interface Manual
SOFTWARE INSTALLATION
To run the Armfield software, users must have access to a PC with the
following:
• Pentium processor or equivalent
• 16 MB RAM
• 10 MB hard disk space (per program)
• SVGA display (800 x 600 high colour) or better
• USB port
• CD-ROM drive
• Microsoft Windows 98 or 2000
The software is supplied on CD-ROM. To install the software use the
following procedure:
• Insert the CD-ROM into the drive.
• The CD should autorun. If it doesn't, choose 'run' from the 'start' menu
and type:
d:\setup.exe
where d is the letter of the drive you are using. Click 'OK'.
• Follow the instructions on the screen.
• Setup will add a group to the start menu for your Armfield software.
To run the software, choose the appropriate shortcut from this group.

If the IFD5 is not installed correctly, then it is possible to cause Windows to


allow the Armfield device to be connected to the computer without the
appropriate driver being installed. This will cause the software to display the
message ‘IFD: Device Error’ in the bottom right-hand corner of the screen.
In normal operation this message can be cleared and communications restored
by disconnecting and reconnecting the USB cable and/or restarting the
software or computer. If these actions do not clear the message, it will be
necessary to manually prompt the computer to install the correct driver
software, as follows.

6
IFD5 Interface Manual
Windows 98
On the computer ‘desktop’ right-click on the ‘My Computer’ icon and choose
‘Properties’. View the ‘Device Manager’ screen. The Armfield device should
be displayed under ‘Universal Serial Bus controllers’. If it is not, then there
should be a category named ‘Other’ with a device called ‘Armfield USB
Interface’ shown with a yellow question mark icon.
• Right-click on this icon and choose ‘Properties’. In the ‘Driver’ screen
click the ‘Update Driver’ button.
• Windows will show the Update Driver Wizard. Ensure that the Armfield
CD is in the drive.
• Choose for Windows to search for a driver, and select the CD-ROM drive
as the location when prompted to do so.
• Windows will find the driver files from the CD-ROM and install them.
• Restart the computer.
• Start the Armfield Software. Data logging should function as normal.

Windows 2000
On the computer ‘desktop’, double click on the ‘Unplug/Eject Hardware’ icon
on the taskbar and select the Armfield USB Device.

• Place the Armfield CD-ROM in the drive. Click the ‘Properties’ button.
• View the ‘Driver’ page and click the ‘Update Driver’ button.
• Proceed through the wizard, selecting ‘Search for a suitable driver’ when
prompted and selecting ‘CD-ROM drive’ as the location.
• The wizard will install the driver files.
• Start the Armfield software. The data logging should function as normal.

7
IFD5 Interface Manual
I/O PORT PIN FUNCTIONS
The IFD5 is capable of passing data on 26 channels, as described below:
• Analogue Inputs – 8 differential channels or 16 single ended channels,
each with –5V to 5V signals digitised into a 12-bit number. IFD5 will
pass a value between –2047 and 2047 to the computer.
• Analogue Outputs – 2 channels, each with –5V to 5V signals, taken
from a 12-bit number. Computer must pass a value between –2047
and 2047 to the IFD5.
• Digital Inputs – 8 channels each receiving a 0 or 1.
• Digital Outputs – 8 channels each passing a 0 or 1.
These channels are arranged on the 50-way ribbon cable as shown in table 1
overleaf:

8
IFD5 Interface Manual

PIN NO CHANNEL NO
Analogue Inputs (0-5V dc)
Differential Mode Single-Ended Mode
1 Ch 0 signal Ch 0 signal
2 Ch 0 return Ch 1 signal
3 Ch 1 signal Ch 2 signal
4 Ch1 return Ch 3 signal
5 Ch 2 signal Ch 4 signal
6 Ch 2 return Ch 5 signal
7 Ch 3 signal Ch 6 signal
8 Ch 3 return Ch 7 signal
9 Ch 4 signal Ch 8 signal
10 Ch 4 return Ch 9 signal
11 Ch 5 signal Ch 10 signal
12 Ch 5 return Ch 11 signal
13 Ch 6 signal Ch 12 signal
14 Ch 6 return Ch 13 signal
15 Ch 7 signal Ch 14 signal
16 Ch 7 return Ch 15 signal
17 Analogue Ground
18 Amp Lo
19 +12 V Out
20 -12 V Out
21 Power Ground
Analogue Outputs (0-5V dc)
22 Ch 0 signal
23 Ch 0 return
24 Ch 1 signal
25 Ch 1 return
Digital Inputs (0-5V dc)
26 Digital Ground
27 Digital Ground
28 Ch 0
29 Ch 1
30 Ch 2
31 Ch 3
32 Digital Ground
33 Ch 4
34 Ch 5

9
IFD5 Interface Manual
35 Ch 6
36 Ch 7
37 Digital Ground
Digital Outputs (0-5V dc)
38 Ch 0
39 Ch 1
40 Ch 2
41 Ch 3
42 Digital Ground
43 Ch 4
44 Ch 5
45 Ch 6
46 Ch 7
47 Digital Ground
48 Digital Ground
49 Not used
50 Not used

Table 1 – Pin usage for 50-way data connector

10
IFD5 Interface Manual
APPENDIX 1 – Using third party software to access the IFD5
Installing the Driver Software
Insert the CD-ROM into the drive. The program should start automatically, but
if ‘autorun’ is disabled on your computer, go to the start menu, choose ‘run’
and type ‘d:\setup’ where d is the letter of your CD-ROM drive. Select the
‘Install Driver Software’ option and follow the instructions on screen.
Under Windows 98, the setup program will create the following files on your
computer:
C:\WINDOWS\INF\OTHERS\ARMFIELD LTDTHERMUSB.INF
C:\WINDOWS\INF\OTHERS\ARMUSB.INF
C:\WINDOWS\SYSTEM32\DRIVERS\THERMUSB.SYS
C:\WINDOWS\SYSTEM32\DRIVERS\ARMUSB.SYS
C:\WINDOWS\SYSTEM\ARMIFD.DLL
Under Windows 2000 these files will be:
C:\WINNT\INF\OTHERS\ARMFIELD LTDTHERMUSB.INF
C:\WINNT\INF\OTHERS\ARMUSB.INF
C:\WINNT\SYSTEM32\DRIVERS\THERMUSB.SYS
C:\WINNT\SYSTEM32\DRIVERS\ARMUSB.SYS
C:\WINNT\SYSTEM\ARMIFD.DLL
The first two files tells the computer how to recognise the IFD5 when it is
plugged in to the PC, the next two files are the drivers for the IFD5s USB
interface and the last file is a library file, used to pass data between the user
program and the IFD5 driver.
Also included on the CD-ROM are a tutorial on constructing a LabView or
Matlab data logger and a test program for checking that the apparatus and IFD5
are functioning properly.

11
IFD5 Interface Manual
Connecting the Equipment to the PC
Connect the IFD5 to the PC and equipment using the procedure on page 5.
Run the test program from Start – Programs – Armfield Data Logger – Test
Program. Check that the displays show appropriate readings. Refer to the
product manual for the apparatus you are using for a list of channel numbers
and their functions.
IFD5 Driver Function Calls
The driver for the Armfield IFD5 data logger is accessed using function calls to
the dynamic link library file ARMIFD.DLL. There are four basic calls which
can be made to the library file, based on the four types of data I/O described
above. These functions must be supplied with a full set of variables of the
correct format. All of the variables passed are 32-bit integer types.
Read Analogue
This call returns a value from one of the analogue channels. The syntax for the
call is:
function ReadAnalog(var channel: integer; var value: integer);
stdcall;

The stdcall directive indicates that the call is handled in a way which is
recognisable by most programming languages, including LabView. The
channel number should be selected as follows:
• Channels 0-7 for differential channels
• Channels 0-15 for single ended channels
• Channels 16-31 for multiplexed channels (where appropriate)
The value returned will be an integer ±2047 corresponding to ±5V. A value of
9999 indicates an error.
Write Analogues
This call sends values to the two analogue output channels. The syntax is:
procedure WriteAnalogs (var AO1: integer; var AO2:
integer);stdcall;

The values sent should be between ±2047 corresponding to ±5V.


Read Digitals

12
IFD5 Interface Manual
This call returns the values from one of the eight digital channels. The syntax
for the call is:
procedure ReadDigital (var channel: integer; var value:
integer); stdcall;

The return value will be 0 if the channel is off or 1 if the channel is on. A value
of -1 indicates an error.
Write Digitals
This call writes values from the eight digital output channels. The syntax for
the call is:
procedure WriteDigitals(var DO1: integer; var DO2: integer;
var DO3 : integer; var DO4 : integer;
var DO5 : integer; var DO6 : integer;
var DO7 : integer; var DO8 : integer);
stdcall;

The analogue channels use values between –2047 and 2047, relating to –5V to
5V on the apparatus. The digital channels use either a 0 or a 1 for ON or OFF.
There are also several more advanced calls which can be made to the IFD5
driver, as listed below:
Set Mode
When data is transmitted in single-ended mode, such as on the UOP3cc, the
mode must be set to single-ended using the following call:
procedure SetMode (var Mode : integer); stdcall;

This call sets the mode for the device to either 8 differential channels (Mode =
0) or 16 open-ended channels (Mode = 1).
Read Frequency
The IFD5 interface incorporates a frequency counter which can measure the
frequency of a signal on one of the digital input channels. The syntax for the
call is:
Procedure ReadFrequency(var channel : integer;
var Frequency : integer);stdcall;

The channel number supplied must be between 0 and 7. The first call to this
function will initiate counting, while subsequent calls will retrieve the value
from the previous count and begin a new count. Each count takes
approximately 1 second. Because of this, the counter will give the most

13
IFD5 Interface Manual
accurate results when the frequency being measured is reasonably stable; there
will be a delay in the reading if the frequency is changing.
High Speed Data Capture
The IFD5 also incorporates a routine for the high speed capture of multiple
data points from the first two analogue channels. An array of 2000 point is
stored for each channel, sampled at intervals of 0.77 milliseconds. The data
capture can be initiated by the software, or can be triggered by one of the
digital channels. The required syntax is:
Procedure ReadHS(var channel : integer;
var Ch1Data : array of smallint;
var Ch2Data : array of smallint);stdcall;

The channel variable determines the trigger mode (0 selects a software trigger,
1 to 8 selects a hardware trigger via the appropriate digital channel). Ch1Data
and Ch2Data are array types with 2000 elements each.
When using the ReadHS function, it is important that all other communications
with the IFD are paused, so as not to interrupt the data capture. If using the
ReadFrequency function, it will be necessary to allow a pause of approximately
one second before starting ReadHS, to ensure that the frequency count has
finished.

14
IFD5 Interface Manual
C/C++ (Cdecl) Procedures
In addition to the above stdcall procedures, the IFD5 driver contains a
duplicate set of functions which use the cdecl calling convention. These
functions are required when using Matlab to access the IFD5, and it may also
be preferable to use them if C or C++ is to be used.
The functions are summarised as follows:
function CReadAnalog(channel: integer): integer; cdecl;

function CReadDigital (channel: integer): integer; cdecl;

function CWriteAnalogs (AO1: integer; AO2: integer):


boolean; cdecl;

function CWriteDigitals (DO1 : integer; DO2 : integer;


DO3 : integer; DO4 : integer;
DO5 : integer; DO6 : integer;
DO7 : integer; DO8 : integer):
boolean; cdecl;

There is also the function for setting the mode (8 differential or 16 open ended
channels) for the analogue data transfer:
function CSetMode (Mode : integer); cdecl;

The advanced functions for frequency and high speed data capture are also
repeated:
function CReadFrequency (Channel : integer;
Frequency : integer); cdecl;

function CReadHS (Channel : integer;


Ch1Data : array of smallint;
Ch2Data : array of smallint); cdecl;

15
IFD5 Interface Manual
Building a Data Logger
Using the methods and function calls detailed above it should be possible to
construct a data logging or control program in any programming environment
which allows calls to dynamic link libraries (.dll files). Examples of such
environments include, but are not limited to C, C++, Delphi (Visual Pascal)
and Visual Basic.
The following pages give procedures for the construction of simple data
loggers using Matlab, LabView and Microsoft Excel.

16
IFD5 Interface Manual
Building a LabView Data Logger
This section assumes that the user has a knowledge of the basics of LabView.
Load LabView and choose new VI from the initial menu screen. This will give
you a blank document in which to work. Alternatively, you could add the data
logging facility to an existing VI. Select View Diagram from the window
menu. Make sure that the tools palette and functions palette are visible.
Accessing the Analogue Input Channels
From the functions palette, select Advanced and then Call Library Function.
Place the icon on the diagram, and double click on it with the selector tool to
access the setup page. Click on the browse button at the top of the page, and
locate the file C:\WINDOWS\SYSTEM\ARMIFD.DLL. Click on the Function
Name box and type ‘ReadAnalog’. Check that Calling Conventions is set to
‘default (StdCall)’ and that the function is set to ‘Run in UI Thread’.
Click on the Add a Parameter After button. The parameter area will change,
allowing various choices. Name the parameter ‘Channel’, set the Type to
‘numeric’, set the Data Type to ‘Signed 32-bit Integer’ and set Pass to ‘Pointer
to Value’. These settings apply to all of the parameters used by the library file.
Repeat this step so that there are two parameters, naming the second one
'Value'. When this is done, click OK to close the page.
The icon on the diagram should now have four cells on it, representing the two
parameters before and after being passed to the library file. The column on the
left contains the input parameters, while the column on the right contains the
outputs.
Popup (click with the right-hand mouse button) the top left-hand cell and
choose create constant. Type ‘0’ in the box that appears. Repeat this step for
the second cell in the left-hand column. This means that the channel number
and output will be set to zero before passing to the library file.
Popup on the bottom cell in the right-hand column and choose Create
Indicator. A blue box will appear with the caption Value. Click on View Panel
in the window menu to see the front panel. There should be an indicator box
present, titled 'value'.
Save the VI using the file menu, then click on the run continuously button. The
value in the indicator box will update continuously, showing the value being
read by the IFD5 on channel 0. If the program fails to run, then is probably an
error in the Call Library Function page. Check all of the values and settings on
this page carefully.

17
IFD5 Interface Manual
This procedure can be repeated in order to create indicators for analogue
channels as required.
Accessing the Digital Input Channels
Place another Call Library Function icon on the diagram screen, and edit its
settings as before. Locate the library file, and ensure that the calling
conventions and run mode are set correctly. Set the Function Name to
‘ReadDigital’ and specify two parameters to be passed, named Channel and
Value, of type ‘numeric’, data type ‘Signed 32-bit Integer’ and pass ‘Pointer to
Value’. Click OK to exit.
On the diagram, create two constants of 0 as before. For the output parameters,
we need to convert the value from integer (0 or 1) to Boolean (true or false)
data types. One method of doing this is to compare the value to a constant (1).
If the values are the same then the result is true, otherwise it is false.
On the Front Panel, Select Boolean from the Controls palette, and choose the
Round Light indicator. Return to the diagram, and there will be a green box
with T F inside it. Move this box so that it is to the right of the Call Library
icon. On the Functions palette select Comparison and then Equal?, and place
this icon between the other two. Using the wire tool, connect the output from
the top right-hand cell on the Call Library Function and connect to one of the
inputs to the Equal? icon. Connect the output from the Equal? icon to the input
for the T F indicator. Finally popup on the spare input to the Equal? icon and
click create constant. Set the constant value to 1.
Save the file before running. The ‘LED’ will light on the screen when the
digital channel is switched by the equipment. This can be repeated to build
indicators for each digital channel as required, modifying the channel input
parameter to view different channels.
Writing the Analogue Outputs
Create a Call Library Function block as before, with the Function Name set to
‘WriteAnalogs’. Define two integer parameters called AO1 and AO2.
On the Front Panel create two Digital Control boxes from the Numeric button
on the Controls palette. Popup on each of the boxes in turn and select Data
Range. Set the representation to Word (I16), the minimum value to –2047, the
maximum value to +2047, the increment to 1, and the default to 0. In the If
Value is Out of Range box, select ‘coerce’.
Return to the diagram and connect the outputs from the two controls (labelled
I16) to the input parameters on the Call Library Function icon. Save the file

18
IFD5 Interface Manual
before running. Any analogue outputs on the apparatus (pumps, etc.) will now
be set to the values in the boxes.
Writing the Digital Outputs
Create a Call Library Function block with a Function Name ‘WriteDigitals’.
Add eight parameters, named DO1 to DO8.
On the Front Panel create eight Check Box controls from the Boolean button on
the Controls palette. Label these DO1 to DO8. On the diagram go to the
Functions palette and select Boolean, then Boolean to (0,1). Place the icon on
the diagram next to the DO1 control. Using the wire tool, connect the DO1
control to the input to the Boolean icon and connect the output from the
Boolean icon to the top input to the Library Function Call icon. Repeat this for
all eight controls.
Save the file before running. Any digital switches on the equipment can now be
controlled from the computer, by clicking on the appropriate check box.
Customising the VI
The ‘virtual instrument’ created using the above procedure can now be
customised to fit exactly with the requirements of the experiment being
performed. Any of the indicators on the front panel can be renamed or deleted
as applicable. Controls can also be renamed, but if you wish to delete a control,
remember that each Call Library Function block must have a full complement
of inputs before it can run. This means that the deleted control must be replaced
with a constant of value 0.

19
IFD5 Interface Manual
Building an Excel Data Logger
This section assumes that the user has a knowledge of the basics of Excel.
Load Excel and a new spreadsheet should appear. This will give you a blank
document in which to work. Alternatively, you could add the data logging
facility to an existing spreadsheet.
Note: Excel is very sensitive to the syntax used in the functions described in
this section. Errors in the syntax may cause Excel to close and the system to
become unstable. Care should be taken to ensure that the formulae are entered
correctly before pressing the Enter key, and it is sensible to save your work at
regular intervals to avoid losing too much should Excel close unexpectedly.
The IFD5 MUST be plugged in to the PC in order for the Excel data
logger to work.
Accessing the Analogue Input Channels
Select the cell where you wish the value from the first analogue channel to be
displayed. Enter the following formula:
=CALL("ArmIFD","ReadAnalog","2NN!",0)
This will setup a call to the ArmIFD.DLL file, using the ‘ReadAnalogs’
function. The third parameter (2NN!) indicates that the function requires two
variables to be passed, and we want Excel to retrieve the first variable in the
list. The zero indicates that we wish to collect channel 0 data. For further help
on the parameters passed in this function, see Excel help.
Copy this formula down for seven further cells, and increment the fourth
parameter by one in each successive cell e.g. the second cell down should
contain:
=CALL("ArmIFD","ReadAnalog","2NN!",1)
These eight cells will then update to read the current values from the eight
analogue input channels whenever the spreadsheet is calculated.

Accessing the Digital Input Channels


Select the cell where you wish the value from the first digital channel to be
displayed. Enter the following formula:
=CALL("ArmIFD","ReadDigital","2NN!",0)

20
IFD5 Interface Manual
This will setup a call to the .dll file to read the first digital channel. Copy the
cell down seven further rows, and increment the fourth parameter for each cell
as before.
Writing the Analogue Outputs
Select the cells where you wish to enter the values for the analogue output
channels. Enter values of 1024 (50%) in both. In the cells to the right, enter the
following formulae (in this example the cells B5 and B6 are used as the entry
cells):
=CALL("ArmIFD","WriteAnalogs","1NN!",$B$5,$B$6)
=CALL("ArmIFD","WriteAnalogs","2NN!",$B$5,$B$6)
These formulae take the values from the left-hand cells and send the values to
the analogue output channels. In fact, only one of these formulas is required to
send the data, but both are included for completeness of display.
Writing the Digital Outputs
Select eight cells where you wish to enter the values for the digital output
channels. Enter values of either 0 or 1 in each of the cells (0 for off, 1 for on).
In the cells to the right of these, enter the following formula (in this example
cells B245 to B32 are used as the entry cells):
=CALL("ArmIFD","WriteDigitals","1NNNNNNNN!",$B$25,$B$26,
$B$27,$B$28,$B$29,$B$30,$B$31,$B$32)
Increment the first digit of the third parameter by one for each successive cell.
As for the analogue output call, it is not actually necessary to repeat this
formula eight times, but doing so does confirm the values which are sent.
Building a Recalculate Macro
The above formulae will get data from the IFD5 whenever the spreadsheet is
updated. If automatic data retrieval is required then we must write a macro (a
short visual basic function) which will force the spreadsheet to update.
Right-click on the toolbars at the top of the screen, and choose the ‘Forms’
toolbar. Place a button on the sheet. The macro window will appear; click OK
to add a new macro. The code editor window will appear, with the module for
the spreadsheet in the main window. Replace the code for the button click
which you have just generated with the following code:
Dim Running As Boolean
Sub Button1_Click()
Dim Start
21
IFD5 Interface Manual
Running = True
While Running = True
Start = Timer
Do While Timer < Start + 0.5
DoEvents
Loop
Calculate
Wend
End Sub
Insert another button and assign the macro ‘Button2_Click’ to it. Replace the
code for the macro with the following:
Sub Button2_Click()
Running = False
End Sub

Save the spreadsheet. The buttons ‘Button1’ and Button2’ can be renamed
‘Start’ and ‘Stop’ respectively. Clicking on the start button will force the sheet
to recalculate every 0.5 seconds. Clicking on the stop button will halt this
process.

22
IFD5 Interface Manual
Building a Matlab Data Logger
This section assumes that the user has a knowledge of the basics of Matlab.
To access the IFD5 from Matlab, you will need access to a C or C++ compiler.
It may be possible to use the compiler supplied with Matlab, but this tutorial is
based on the Microsoft C++ compiler.
Ensure that you have set up your C compiler for use with Matlab using the
command:
> MEX - SETUP

You need to create a text file called ARMIFD.DEF in


$MATLAB$\extern\include directory, with the following content:
LIBRARY ArmIFD.dll
EXPORTS
SetMode
CSetMode
ReadAnalog
ReadDigital
WriteAnalogs
WriteDigitals
CReadAnalog
CReadDigital
CWriteAnalogs
CWriteDigitals

This defines the functions in the Dynamic Link Library (.dll) file which are to
be used by Matlab.
Accessing the Analogue Input Channels
To access the functions within the .dll we need to create a C program, which
can be called from within Matlab.
Create a new text file called ANREAD.C in the $MATLAB$\work directory.
Enter the following text:
#include "mex.h"

long CReadAnalog(long channel);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,


const mxArray *prhs[] )
{
int i;
long ans;

mexPrintf("\n - Armfield IFD5 - \n\n Analogue Channels


\n\n");

23
IFD5 Interface Manual
i = 1;
while (i < 9)
{
ans = CReadAnalog(i-1);
mexPrintf(" AI %i: %d\n",i, ans);

i = i + 1;
}
}

This code defines a function CReadAnalog which returns a value from the
IFD5 channel corresponding to the channel number sent. It then defines a long
variable to store the answer, and an int variable to act as a loop counter.
Using a ‘while’ loop we check each of the 8 channels in turn, and print the
answer onto the screen.
Compile and run the program using the command line:
> MEX ANREAD.C ARMIFD.DLL
> ANREAD

The values from the eight IFD5 analogue channels will be displayed. The range
of the values is ±2047 corresponding to ±5V.
Accessing the Digital Input Channels
Create a new text file called DIGREAD.C and enter the following code:
#include "mex.h"

long CReadDigital(long temp);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,


const mxArray *prhs[] )

{
int i;
long ans;
ldiv_t div_result;
int digitals[8];

mexPrintf("\n - Armfield IFD5 - \n\n Digital Channels


\n\n");

ans = CReadDigital(0);

i = 1;

while (i < 9)
{
if ((ans & 1) == 1)
digitals[i] = 1;
else
digitals[i] = 0;
24
IFD5 Interface Manual

div_result = ldiv(ans, 2);


ans = div_result.quot;

i = i+1;
}

mexPrintf(" DI 1: %d\n", digitals[1]);


mexPrintf(" DI 2: %d\n", digitals[2]);
mexPrintf(" DI 3: %d\n", digitals[3]);
mexPrintf(" DI 4: %d\n", digitals[4]);
mexPrintf(" DI 5: %d\n", digitals[5]);
mexPrintf(" DI 6: %d\n", digitals[6]);
mexPrintf(" DI 7: %d\n", digitals[7]);
mexPrintf(" DI 8: %d\n", digitals[8]);

This code defines a function which reads the data from the eight digital
channels on the IFD5, returned as an eight bit word. It also defines a long
variable to receive the result, and an array of eight integers to receive the
channel values. The code calls the function, and receives an eight bit word
(ans). It then loops through the word, checking whether each bit is a 1 or a 0,
and setting the appropriate value in the Digitals array.
Compile and run the program as before.
Writing the Analogue Outputs
Create a new text file called ANWRITE.C and enter the following code:
#include "mex.h"

bool CWriteAnalogs(long AO1, long AO2);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,


const mxArray *prhs[] )

{
int i;
long mode, ans, AO1, AO2;
bool res;

AO1 = 1024;
AO2 = 1024;

res = CWriteAnalogs(AO1, AO2);

mexPrintf("\n Analog Outputs Written\n\n");

25
IFD5 Interface Manual
This code defines a function called CReadAnalogs which takes two long
parameters and passes them to the .dll. It then informs the user that the
channels have been written.
Compile and run the program as before. Matlab will output values of 1024 to
each of the analogue outputs (e.g. a pump on the apparatus would rotate at 50%
of its maximum speed).
Writing the Digital Outputs
Create a new text file called DIGWRITE.C and enter the following text:
#include "mex.h"

bool CWriteDigitals(int DO1,int DO2,int DO3,int DO4,int


DO5,int DO6,int DO7,int
DO8);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,


const mxArray *prhs[] )

{
int I, digitals[8];
long mode, ans;

while (i < 9)
{
digitals[i] = 1;
}

mexPrintf("\n Analog Outputs Written\n\n");

res = CWriteDigitals(digitals[1],digitals[2],
digitals[3],digitals[4],
digitals[5],digitals[6],
digitals[7],digitals[8]);

mexPrintf(" Digital Outputs Written\n\n");


}

This code defines a function which passes eight integer parameters to the IFD5
digital outputs. It sets all f the values in the ‘digitals’ array to 1, sends them to
the .dll, and then informs the user that the channels have been written.
Set Mode
The other function defined on page 12 for use with C or C++ is the SetMode
call, which is used to set either differential or single ended data transfer. If the
apparatus you are using has 16 single ended analogue channels rather than
eight differential channels, it will be necessary to use this function before the
data transfer is commenced.

26

You might also like