Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

1

Fall, 2000
Chemistry 382/378
Role-Playing Lab in
Instrumental Analysis
Experiment #01
Digital Input/Output

Prof. John P. Walters


Dep't. of Chemistry
St. Olaf College
Northfield, MN 55057
507-646-3429
walters@stolaf.edu

In this experiment you will explore using the National Instruments DIO-32 digital input/output board,
driven by LabVIEW, to control first some LEDs, then a DC fan, and lastly to construct and read a recording pH meter. After the pH meter has been built, you will test the linearity, the response time and
the drift of a new triode style of glass pH electrode. In the next experiment, you will compare these
performance specifications to a new, Field Effect Transistor (FET) pH-sensing electrode. In both of
these experiments, you will be developing a routine that could be used professionally as part of an
analytical method validation.
Since this is the first experiment that we do, and since much of this will be new, some tutorial exercises will be suggested. Later experiments will build on what is done here, so these tutorials will be
directed toward future work, as opposed to general instruction in digital I/O. Much work will be done
in the I/A lab using the National Instruments programming environment called LabVIEW. The Student
Edition, version 6.1 and the Professional development edition, version 6.1.x, will be used. Many
features of LabVIEW will have to be learned as they are used for the first time. One such feature that
will be used in this experiment is the cluster. Some introductory material on making clusters of digital indicators also will be given.
The Lab Layout
The lab room that we will use is set up to hold four people at a time (see Figure 1). Each person has a
personal small desk, a Mac computer with large video display and a set of DIO and A/D-D/A boards,
and a comfortable chair. The room
is set up somewhat differently for
each experiment, with the exception of the Zymark laboratory robot that is in place for the whole
semester.
Computer Interfacing
Work Station #2

Electronic Wiring
Bench #2

Figure 1 The lab room layout

Computer Interfacing
Work Station #1

The lab room does not, unfortunately, have enough room for
winter coats and bulky book bags.
These will have to be left outside.
Each small desk has a cable above
it with clips to which you can
fasten individual copies of the figures presented in the experiment.
In this way, you need only have
the diagrams and figures at hand
that are needed to make the experiment happen. At either end of
the lab room are larger electronic
soldering benches.

Electronic Wiring
Bench #1

Computer Interfacing
Work Station #4

Computer Interfacing
Work Station #3

2
The Small Desks
Terminal Block for A/DBoard
(optional placement)
NB - Relay Board
5 VDC
Power Supply

Small Experimentors
Socket for Relay Board

Experimentors Socket for A/D Board


4 5 6

7 8

9 10 1
1

1 1 1
2 3 4

1 1
5 6

1 1 1
7 8 9

2 2 2
0 1 2

2 2
3 4

2 2 2
5 6 7

2 2
8 9

3 3 3
0 1 2

3 3 3
3 4 5

3 3
6 7

3 3 4
8 9 0

4 4
1 2

4 4 4
3 4 5

4 4
6 7

12 VDC
Power Supply
1 2

3 4 5

6 7

8 9 10 1
1

1 1
2 3

1 1 1
4 5 6

1 1
7 8

1 2 2
9 0 1

2 2
2 3

2 2 2
4 5 6

2 2 2
7 8 9

3 3
0 1

3 3 3
2 3 4

3 3
5 6

3 3 3
7 8 9

4 4
0 1

4 4 4
2 3 4

4 4 4
5 6 7

Each small desk has several DIO items on it.


Locate them. They are:

12 VDC Fan
Electronic Plasticware Experimentors Station

1 1
3 4

8 9 10 1 1
1 2

1 1
3 4

2 3

4 5

7 8

6 7

1 1
5 6
1 1
5 6

1 1
7 8
1 1
7 8

1 2
9 0
1
9

2 2
1 2

2 2
0 1

2 2
3 4

2 2
2 3

2 2
5 6

2 2
4 5

2 2
7 8

2 2
6 7

2 3
9 0

2 2
8 9

3 3
1 2

3 3
0 1

3 3
3 4

3 3
2 3

3 3
5 6

3 3
4 5

3 3
7 8

3 3
6 7

3 4
9 0

3 3
8 9

4 4
1 2

4 4
0 1

4 4
3 4

4 4
2 3

5 6

4 4
5 6

4 4
4 5

4
7

4 4
6 7

A set of three or four calibration


buffers. A more extensive set of 11
buffers also is available for better
certification of the meter.

3 4

1 2

The Corning type 130 digital pH


meter and associated triode combination electrode.

1 1
10 1 2

Ribbon Connector Block


Terminal Block for DIO Board
(optional placement)

1 2 3

The next exploratory activity to do is to select a small desk at which to work and study
the layout it has for working on the Digital
input/output (DIO) experiment (see Figure
2).

Corning
Corning Model 130
Model 130
pH Meter
Meter
pH
Long and Short
Hook-up
Wire Holder

Set of 4 Buffers
Terminal Block for A/D or DIO Board

Figure 2 A small desk set up for DIO

A 12 VDC and a 110-vAC fan used


as part of the experiment dealing with switching on and off inductive loads with solid state relays.

An electronic experimenters station used to make all of the digital connections between the
Mac computer and the corning pH meter. The station also has a set of built in Light Emitting
Diodes (LEDs) that are used to follow the binary condition of the Mac and pH meter digital
lines.

A holder containing many stripped, 22 gauge, solid hook-up wires of various lengths and colors that are inserted into the columns of the various experimenters sockets on the desk to make
the Mac pH - DIO connections. By using these sockets and wires, no soldering is needed.

One or more 50 pin terminal blocks that connect via flat ribbon cables to the digital I/O and
analog A/D boards in the Mac. These are provided with either push-in or screw-down connection one end of the hook-up wires.

5 and 12 VDC power supplies. The 5 VDC supply powers the LEDs on the experimenters
station and the NB-relay board. The 12 VDC powers the fan and other select DC loads.

The electronic experimenters station forms the heart


of the small desk for this experiment. The Corning pH
meter is connected to one side of the columns on the
experimenters socket on it, and also to the LEDs.
Thus, all of the pH meter information is available in
digital form to view and to observe. The other set of
columns on the experimenters socket is used to connect to a 50 pin terminal block and the Mac using
push-in, hook-up wires (see Figure 3).
The creative part of this kind of interfacing is choosing
the desired pH meter functions to have appear on the
computer video display and then assigning their digital
bits to the appropriate columns and pins in the experimenters socket and 50 pin terminal block.
Figure 3 Patching wires in station socket

3
The pH Meter
The Corning Model 130 pH meter is a sophisticated system of operational amplifiers and digital circuitry. It would be well beyond the scope of
our beginning work to attempt to actually
construct this meter. However, interfacing it
to the Mac computer turns out to be fun,
useful, and manageable. We then can use
the full power of the Mac, of Excel, and of
LabVIEW to display and to analyze the
performance of the meter.
The input operational amplifier stage of the
meter is represented schematically in Figure
4. The glass electrode and saturated calomel
reference electrode have a pH dependent
potential developed between them. This potential is amplified by the input stage. In the
feedback loop of this amplifier are variable
resistances to control the slope (mV/pH unit)
and temperature compensation of the electrodes. The output of the amplifier and the
SCE are attached to resistances that offset
the voltage it produces, allowing correction
for liquid junction potentials (standardization) and meter electronic drift (zero adjust- Figure 4 Input stage of Corning 130 pH meter
ment). During the lab we will explore how
to set these adjustments.
Not shown in Figure 4 are the actual digital outputs of the Corning meter. Most of the meter functions
are available on a ribbon connector at the back of the meter.
These functions are shown in
Figure 5.
For example, each digit of the
pH reading is brought out in 4
bits (binary integers) of binary coded decimal (BCD)
information. Since we will use
5 digits of pH information, 20
pins are required to represent
this. In addition, we will use
those individual bits that tell
whether pH or millivolts have
been selected for display, and
one bit to reflect the sign of the
pH or millivolt reading.
Each bit of all of this information will require one physical
wire to be connected between
the pH meter and the Mac DIO
board, going through the exFigure 5 pH meter digital output functions
periment plastic station. Mapping these wires and making the physical connection forms the essential core of digital I/O computer
interfacing.

The way in which the pH digits are used to


form a complete binary coded decimal word
is shown in Figure 6.
Each pH digit is represented as one BCD 12-4-8 nibble. The sum of the 1-2-48 BCD
bit weights is equal to the decimal value of
the digit.
Two nibbles are combined to make an 8 bit
byte, and two bytes are combines to make
a 16-bit word containing all four pH digits.
Since we never encounter pH values greater
than 20, the most significant pH digit, for
values over 9.99, are simply represented as
a single bit. We will later combine it with
other single bits to make a 5th nibble.
All of these bits will be used to light LEDs
on the Plastic experimenters station. Notice
that when the BCD nibbles are combined
into a full word, the actual decimal value of
the word increases to reflect the total number
of bits in it.
Connection between the pH meter digital
output and the Mac computer is made via a
Figure 6 BCD representation of pH digits
set of digital ports. A port is a physical representation of a byte. Each of the eight bits in the byte is
brought out to an individual electrical connector.
The resulting 8 connectors are physically connected
together to form half of a port. Usually more than
one port is built. The result is called a terminal
block. Such a two port, 50 connector (or 50 pin)
device is shown schematically here in Figure 7.

Figure 8 A physical terminal block


Here, there are four 8 bit bytes (A, B, C, and D)
connected into two 16 bit ports (0 and 1), for a total
of 32 bits of digital input or output traffic.

Figure 7 A 50 pin, 2 port, 4 byte terminal block

This terminal block is physically constructed to allow wires or other devices to be screwed into small
holes on its face (see Figure 8). The screw arrangement is called a guillotine because of the

5
way the edge of the inside of the connection
cuts into the wire to hold it in place when the
appropriate screw is tightened down.
When the pH meter is wired into the Mac, it is
done through the terminal block. A logical
map is made showing how to push a wired
between the terminal block and the experimenters socket on the Plastic station (see Figure 9).
Making this map is one of the creative parts of
this experiment. The only required wire placement is the ground. The other leads can be associated with any byte and any combination of
LEDs that are pleasing. It will be learned
though that the BCD order of the wires is imFigure 9 A logical map for wiring to pH meter
portant, as is getting the right information out of
the computer byte after it has been read. The
logical map design thus, while creative, must be done with regard to how the information is to be read
by the computer.
Project #1 - Learning Digital I/O by Flashing Bytes
Before any interfacing is done between the Mac and the Corning pH meter, it is best to just use the
Mac to Output to a set of LEDs. This little exercise is called flashing bytes. It allows you to practice
making the physical wire connections between the terminal block and the LEDs on the Plastic station,
and to build some beginning LabVIEW VIs to make the lights turn on and off as the individual bits
making up bytes and words change from low (0) to high (1) state.
Figure 10 shows the first nibble of a
byte being wired from the Mac to a set
of four LEDs. Note the 1-2-4-8 BCD
weighting of each bit in the nibble.
The BCD weight corresponds to, and is
fixed by, bits B0, B1, B2, and B3 of
port 0 on the terminal block. The wires
that carry these bits could be connected
to any 4 LEDs. There is no special requirement.
But, once the connection order has been
chosen, then the 1-2-4-8 BCD arithmetic is fixed too. If you want to know
what the decimal digit was that set some
particular LED pattern, then you must
know the 1-2-4-8 BCD weight each
LED has, and that is where you must
keep a record of how the LEDs were
wired. This requires good collaboration
between Software and Hardware
people.
Figure 10 wiring a nibble on the Plastic station

Start this work by drawing your own


logical/physical-wiring map using the
blank version of Figure 10 that is ap-

6
pended to this experiment. To help get used to turning off and/or on a set of LEDs in one instruction,
a basic byte flasher LabVIEW is built. There will be time for some tutorial help here. Be prepared
to use it.
The front panel of the basic byte flasher is shown in
Figure 11. There are several LabVIEW controls
and indicators that will need to be explained to
you. Some are easy to follow. Others are subtler.
The one that is hardest is the cluster. Note in Figure 11 that there are two boxes containing 16 LED
indicators. These boxes are clusters, and they are
filled with the LEDs. In the tutorial, you will be
shown how to fix a cluster on your front panel, how
to put LEDs into it, and how to label and order them
Figure 11 Basic byte flasher front panel
so that they correspond to the properly weighted
BCD bits of a 16 bit binary word. An example of
these operations is shown in Figure 12. Make sure
that all of this is done and understood before going
on. After that, you will have to size the cluster that
you have made. This is tricky in that there is no way
you would know to do it without being told first. The
sequence of steps required is shown in Figure 13.
Figure 12 Making a cluster of Booleans
The wiring diagram for the basic byte
flasher is shown in Figure 14. This is a
bit of an artistic rendition, since you
will not be able to see both of the FOR
loop constructs at the same time.
Again, you will need to have a tutorial
on how to select the icons to make this
VI. You will need to know how to con- Figure 13 Sizing a cluster of Booleans
vert the cluster of LEDs on the front
panel to an array of binary bits, how to
convert that array to a number, and
then how to wire that number out to
the digital port that you will connect
to at the terminal block on the Plastic
experimenters station.

Figure 14 Wiring diagram for basic byte flasher


have pressed in the VI write cluster.

After you have built the VI, and have


wired the LEDs via the Plastic station as started in Figure 10, you may
run the VI to make sure that you have
the correct BCD coding between the
Mac and the LED lamps. By using
the LabVIEW finger you can set
the LED pattern you want to write on
the VI front panel. Then when you
run the VI, the same LED lamps on
the Plastic station should light as you

7
You also can read what you have written. Change the VI from write to read. Now, on the Plastic
station, use push-in wires to connect some of the LED lamps physically to ground. This is done by
connecting a wire between the appropriate column in the top set of columns on the experimenters
socket to any hole in the top or bottom row of holes that make up the ground buss. The LED will go
out. Now, when you read the station, the LED indicators in the read cluster should match the physical condition of the LED lamps on the station.
If you are unsure of this operation, or are having trouble with it, ask for a tutorial. Being able to build
and use this basic byte flasher is necessary before you can go on to other parts of todays work.
Project #2 - Running the 12 vDC and 110 vAC Fans
Simple byte flasher kinds of VIs can be used to do more than turn on lamps. With the proper auxiliary electrical devices, they can be made to turn on and off power loads. One such load is the 110 vAC
single-speed fan. This fan is either turned on or turned off by switching 110-vAC power to it. Another
similar load is the twelve-volt direct current (vDC), variable-speed fan. This fan is an example of those
used in GC ovens for temperature regulation. Its speed is regulated by a pulse-width modulation control, which is fed by a 12 vDC supply, which itself is turned on or off by switching 110 vAC power to
it.
Power is switched to both of these fans by turning on or off a set of solid state relays. This is a relay
device that takes a digital signal directly from one or another of the DIO lines on a National Instruments
DIO-32 board. It switches on or off the 110-vAC line connected to it at loads up to 10 amperes. It
Is diagrammed below in Figure 15. The two lines that are called the Digital Control Signal are connected directly to the National Instruments 50 pin terminal block at the proper positions for ground,
DIO channel 0, and DIO channel 1.
110 vAC in

Switched 110 vAC Out


Solid State Relay

Digital Control Signal In

Figure 15 The Solid State Relay (SSR)


In this part of the experiment, there are two SSRs that are used. One switches 110 vAC to the 110vAC fan. It thus just turns this fan on or off. The other switches power to a 100 vAC to 12 vDC
power supply. The output of this power supply goes to a pulse width modulator that is used to adjust
the width of pulses of 12 vDC power that are delivered to the 12 vDC fan. The fan inputs are also connected to this modulator. Adjusting a resistor on the pulse width modulator sets the width of the
pulses, and thus the fan speed. Look at Figure 16 on the next page to see a block diagram of these
connections.

8
Terminal Block with
Digital Outputs
Channel 0 and Channel 1

110 vAC Connections


to Wall Sockets

Solid State Relays


TTL Trigger Inputs
110 vAC Power Outputs

12 vDC
Power
Supply

110 vAC Fan


on Plastic
Support Box

Variable Speed
12 vDC Fan
on Plastic
Support Box

+
-

Pulse Width
Modulator.
DC Input.
Pulse Output.
Adjustable
Resistor Sets
Pulse Width.

Figure 16 Block Diagram Showing Connections of Fans and SSR Power Switches

9
The 12-vDC fan and pulse
width modulator speed
control are shown in Figure 17 at the left. The
speed control has two terminal blocks on the left
side for wiring. Power
comes in at the bottom for
the 12-vDC-power supply, shown in Figure 18,
and goes out to the fan
leads at the top.

Figure 17 12 vDC Fan and Pulse width Modulator Speed Control

When you connect these


leads pay attention to the
polarity of each the red
wire is + and the blue is -.
Use the small screwdriver
furnished to tighten the
connectors onto the wires.

Figures 18 and 19 show how to connect


the 110 vAC fan and the 12-vDC power
supply into the two open SSR switched
power outlets. By putting two nightlights into the top sockets of the
switched power outlets, it is possible to
tell when they are hot. This can be useful for diagnosing any problems.

Figure 18

The SSR Switched Outlets, the 12 vDC


Power Supply, and the 110 vAC Fan.

Figure 19

The 110 vAC Fan

10
The solid state relays are housed in a
small plastic sandwich box. 110vAC power comes in from a terminal
strip, and exits to the outlets shown
in Figure 18. You will not have any
hookups to make to these connections. There are however two trigger
lines that enter the SSR box. These
have to be connected to the proper
pins on the 50 pin terminal block that
is itself connected to the DIO-32 circuit board inside the computer.
These trigger lines are shown in
Figure 20.

A small inset is shown below for


orientation to the way these trigger
lines are connect to the computer.
The larger diagram that you can
use during the experiment is
shown on the next page as Figure
21.

Figure 20

The SSR Box Showing the Two TTL Trigger


Lines that are connected to the Computer.

11

Figure 21

Connection of the SSR Trigger Lines to the NB-DIO-32 Board via the Plastic LED
Indicator Box.

In Figure 21, the trigger lines come into the LED indicator box from the lower right. The black leads
are ground, and are plugged into the lower ground lines. The red leads are positive, and are plugged
into a column of holes desired. Stripped wires are then inserted into an indicator light column, as well
as an appropriate connection socket on the 50 pin terminal block. This can be chosen using the diagram
shown below in Figure 22.
Port

Port

GN

GN

GN
2

GN

2
2

2
2

GN

C7

D6

D3

D1

D5

D7

D0

D4

WORD

WORD

Port 1

2
3

GN

3
3

GN

3
3

GN

C1

D2

C0

C5

C3

C4

C2

3
3

3
3

4
4

WORD

A6

C6

A2

A4

A5 A3

4
4

4
WORD

Port 0

Figure 22

A1 A0

B2

A7

B6

B5

WORD

B1 B3

B7

WORD

B4 B0

WORD

WORD

50 Pin Terminal Block Connection Assignments to DIO Ports and Lines

12

Figure 23 The Completed Fan Setup on the Lab Desk

Digital Fan Control VIs


One way to digitally control the fan is shown in
Figure 24. Building this VI will give you additional experience in converting between binary
and BCD numbers. The panel is just a cluster of
Booleans. Inspection of the diagram however
shows that the cluster is first unbundled before each Boolean is individually to a 0 or a 1
decimal number.
These numbers are then BCD scaled by multiplying them by the appropriate decimal weight
for each digit. The weighted numbers are then
all added together to get a final decimal number,
and this decimal number is then sent out to 8
bits of the digital port that is already connected
for you to the NB relay board. You would wire
the fan into one or another of the relays on the
board. Then, when you turned on the particular
switch that controlled that relay, the fan would
go on or off.

Figure 24 A BCD fan control VI

13
This form of control is essentially no different than that provided by the basic flashing bytes example
except that each bit of the controlling Boolean byte is available as a separate device in the diagram, instead of being buried as one element in a Boolean array. Thus, more can be done with the switches
inside the wiring diagram.
When you have the fan operating, build a VI that will alternately turn the fan on and off at a rate that
its effective (average) speed is adjustable. This technique will be used later in the term when the
mock GC oven is made. Record what you have done so you can use it then.
Project #3 - Multiple Flashing Bytes
An interesting extension to this work is to combine the cluster of Booleans with the LabVIEW constructs of a FOR loop and SEQUENCE frames to make a timed set of multiple flashing bytes. This is
the kind of digital controller that is used in larger analytical instruments, such as the GC/MS, or in industrial process controllers.

Figure 25 A multiple flashing bytes VI

The panel of a multiple byte flasher that you can build is shown in Figure 25. There are six clusters of
16 LEDs. These are easy to make by cloning the first one that is made by hand. Each cluster will
activate the LEDs on the Plastic station for a fixed time. The time is entered in the controls at the right
of each cluster.

14
The clusters will execute in order from top to bottom of the panel. If desired, the top to bottom sequence can be repeated a number of times by entering the desired number in the Repeat? control at
the top of the panel. The Pass # indicator at the top
shows how many times the pattern has been executed.
The multiple byte flasher wiring diagram is shown
in Figure 26. Two of the six sequence frames are
shown (mostly for teaching) to indicate that each
frame is more or less identical. The reason that the
multiple flasher works is that each frame uses its
own cluster of LEDs. For example, frame 0 uses
the cluster at the top of the panel and converts it
from a cluster of Booleans to an array of Booleans
and then from an array to a number, which is sent
out the digital port. The port width is set to 16 bits
on the front panel so that all 16 LEDs on the Plastic
station are lit each time a number is output.

Figure 26

The little clock icon in each frame sets the time delay
for each pattern. You will want to look this up to see
that it counts milliseconds. Thus to wait one second,
the front panel delay is first multiplied by 1000 to
Wiring diagram for multiple byte convert it to milliseconds and then wired into the
flasher
delay clock.

The FOR loop construct is what determines how


often the pattern of 6 clusters repeats. The way this is set up, the same pattern is repeated for each
count of N. If a different pattern were required for each count, then a different set of frames would be
needed. This would make the exercise too detailed for where we are now working.
A nice set of flashing byte patterns can be taken
from the data presented in Figure 27. These can be
keyed into the clusters shown in Figure 25 and sequence executed. The LEDs on the Plastic station
should then flash on and off for the times shown.
Figure 27 shows A/B patterns. It probably would be
better for you to just select some patterns from those
shown and make them sequentially execute.
Other options that have proven interesting in the past
are variations on the movie marquee flashing lights.
Patterns H through K follow this reasoning, as do L
through O. Later in the semester patterns of bytes
like this will be used to control the electrochemical
apparatus that we will use, as well as the lamp and
fan on the mock GC oven. The better you understand how to make them now, the easier it will be
for you to use them then.

Figure 27 Set of test byte patterns

15
Project #4 -Building the Corning pH Meter Interface
The interface that you will make to connect the Corning pH meter to the Mac will be done in LabVIEW and will have many interesting functions. It will combine all of the experience you have acquired making the flashing bytes VIs, and add a few more features as well. A picture of one students
previous front panel is shown below in Figure 28. You will probably want to design yours differently.
At the top of the panel are a set of
square LEDs that will indicate the
BCD value of each digit of the pH,
as well as single bit indicators
showing The 5th pH digit, and if
mV or pH functions have been selected. Each nibble of 4 LEDs
shows the BCD weight of the digit
displayed, and what its decimal
value is. Note that there are digit
AND value notations by the decimal digits. The AND function is
one new feature that you will need
to explore to convert the binary
reading you take from the pH meter
to a properly weighted decimal
digit.
Below the decimal digits are some
controls that you will need to use to
Figure 28 The pH meter VI suggested front panel
measure the response time of the
electrodes being tested. You can,
for example, just toggle the pH meter by pressing the Run Once button. If, however, you want to
continuously sample the meter, you can select the time between readings on the slider control shown.
You also can choose to save your data to a file that later can be read into an Excel 5.0 spreadsheet.
And, of more use than you might first expect, you can choose to make the VI issue a faint beeping
sound each time it takes a reading.
The decimal value of the pH is not only displayed in the large digits at the top of the VI, but also as an
analog value on the strip chart graph shown at the bottom. This makes your interface a recording
pH meter, a device that would be more expensive than the entire Mac system were it to be purchased
as a stand alone instrument. The
strip chart feature will allow you to
visualize the way in which the electrode responds when it is moved
between buffers of differing pH.

Figure 29 Wiring diagram for the pH meter interface

The wiring diagram for the pH meter is shown in Figure 29. Note that
there are two figures overlapping in
this illustration. This is to show the
empty contents of the two, true/false
case structures. Notice also that
there is a set of AND gates operating on the binary value read from
the digital port. This is new and
needs study.

16

Figure 29B pH Meter VI Diagram - rotated and enlarged

17
The AND Function and Hardware Wiring
The AND function is a Boolean logical manipulation of the bits in a digital word (sequence of bytes, nibbles, and bits) that we
will use here to extract individual bits
from the full word.
To understand this better, lets begin by
looking at the physical way that pH information is brought into the Mac via the National Instruments DIO-32 board. This is
done on the Plastic experimenters station by
patching wires between the 50 pin terminal
block connected to the Mac and the indicating LEDs on the experimenters socket that
are prewired to the back of the Corning pH
meter by a spectra-strip 26 wire ribbon
cable. An example of beginning to wire just
the first digit is shown in Figure 30.
Note (in the middle of the diagram) that all
of the pH meter functions are available on
the columns that make up the top of the experimenters socket. These columns are
shaded black on the socket. There is nothing
connected to the white columns that separate
the black ones. The columns of 5 holes on
the top of the socket are not connected to
columns on the bottom of the socket. The
shaded columns are pre-wired to the LED
indicators at the top of the Plastic experimenters station, so you will not have to
concern yourself with making those connec- Figure 30 Hardware connection from Mac to pH meter
tions.
Take the time now to notice the way that the BCD weighting is
done for each pH digit, and how it is brought out to the shaded
set of 4 volumes as shown in Figure 31. The least significant
bit (1) is on the far left of each nibble, and the most significant bit (8) is on the far right.
This is opposite of the way you have wired the socket when
doing flashing byte experiments. Thus, when you wire to the
Mac via the 50 pin terminal block (see Figure 23), the wired
connecting to byte A, bit 0 (terminal block socket #37) will
have to connect to column 7 (not column 1) in the experimenters socket. This can be confusing if you do not study
Figure 30 carefully before you actually start wiring.

Figure 31 BCD pinout order

18
When all of the wires have been connected between the 50 pin terminal block and the experimenters
socket, you will have made a large word containing at least 17 bits of information (if only the pH is
desired) and up to 20 bits (if the functions, etc. are selected as well). When the LabVIEW VI reads
port 0 on device 4, as in Figure 30, and the Port Width is set to 24, then 24 bits of binary information are read into one word at the same time. To do anything with this information, it has to be
parsed, or, the bits we want have to be extracted from it, a nibble or a bit at a time. This is what the
AND function does.
Note the table at the left. This is
called a truth table for the
Bit1
Bit2
Bit3
AND function. There are shown
Test Bit
Combined Mask Bit
Action
Result Bit
a Test Bit and a Mask Bit,
0
AND
0
ignore Bit 1
0
which when ANDed together
1
AND
0
ignore Bit 1
0
produce a Result Bit. Note
0
AND
1
extract Bit 1
0
that when the Mask Bit is a zero,
1
AND
1
extract Bit 1
1
the Result Bit is always a 0, no
matter what the Test Bit was.
But if the Mask Bit is a 1, then the Result Bit is the same as the Test Bit. Thus, by making the Mask bit
a 1, we have extracted the contents of the Test Bit and placed it intact into the Result Bit.
Using the AND function to extract a bit from a bit is not what we do. We will want to make a nibble or
a byte of the Mask, and set the
bits in the Mask Byte to 1s
Bit1
Bit2
Bit3
when we want to extract certain
Test
Combined
Mask
Action
Result
information from a Test Byte
Byte
Byte
Byte
into a Result Byte. Note the ta1
AND
0
ignore Bit1
ble below. Here the Test Byte is
1
AND
1
extract Bit1
1
binary 01110011 (decimal 206)
0
AND
1
extract Bit1
0
and the Mask Byte is 01111110
(decimal 126). The Mask Byte is
0
AND
1
extract Bit1
0
set with 1s to extract the middle
1
AND
1
extract Bit1
1
6 bits from the Test Byte. The
1
AND
1
extract Bit1
1
Result Byte is 111001 (decimal
1
AND
1
extract Bit1
1
78), reflecting the fact that bits 3
0
AND
0
ignore Bit1
and 4 of the Test Byte were 0
Decimal
Decimal
Decimal
and the others being extracted all
206
AND
126
extract middle
78
1s.
6 Bits
The AND function thus can be
used to extract any number of bits we want out of the 24 bits we capture from the pH meter. For example, we could extract the first 4 bits (the lowest nibble) by ANDing the pH meter word with binary
1111 or decimal 15. The result would be a set of 4 bits
whose BCD value represented the 1s pH digit, according to
the map shown in Figure 30.
The extraction of other bits into nibbles or larger bytes is best
understood by building a VI to practice with. The one to
make here, called an AND machine is shown in Figure 32.
Now is the time to build this VI and see how the extraction is
done.

Figure 32 an AND machine

19
For example, suppose that we want to extract the nibble of bits from the 20 bit WORD that correspond to bits 13 through 16. To do this, we would set these bits high (make them 1s) in the MASK,
and when the MASK and WORD were ANDed, the RESULT would be all zeros except those bits,
whose values would be the same as bits 13 through 16 in WORD. The arithmetic way of saying this is:
629145 .AND. 61440 . I S . 36864
The AND machine shows the arithmetic way, the binary way, and the cluster of LEDs way. Practice
with this until you can see how to extract any bit, nibble, or byte you want from WORD by ANDing it
with MASK.
Figure 33 shows how the individual pH digits are ANDed
out of the larger 20 bit word a
nibble at a time. The digital
port is read by the DIG PORT
READ sub-VI, and 24 bits of
information are presented as a
single decimal number at its
output. When this number is
ANDed with 15 (binary 1111),
the least significant or lowest
nibble is extracted.

Figure 33 ANDing Digits to Get a pH Value

The next AND is with decimal


240 (binary 11110000). This
extracts the next most significant, or next highest, nibble.
But, note that the result is an 8bit byte. To see the decimal
weight of just the top nibble of
that byte, we have to divide it
by 16. This is because the bit
000X 0000 of the byte changes
every time the lower four nibbles are all 1s, or we say the
upper nibble counts the number
of 16s that have occurred in

the word.
Each of the nibbles that are needed to represent a particular pH digit are extracted with their own AND
function, and after each AND the decimal number of that digit is determined by dividing by one more
than the full BCD weight of the previous byte when its binary representation is all ones. This is a
standard digital interfacing technique, and one that you should both understand and remember for future work.
The AND operations just extract individual digits. They do not give a decimal number that represents
the pH. To get such a number we have to apply true decimal (not binary coded decimal) weighting to
each of the digits. For example, the digit extracted by ANDing with decimal 15 (binary 1111) is the 1s
decimal place in the pH. We know this by the way in which the interface was physically wired. In
Figure 33 we also see that 1, divides the ANDed digits by 10, by 100, and by 1000 to build a pH between 9 and 0.001. The one digit needed to give pH greater than 10 is extracted as the 21st bit by
ANDing with 65536 and converted to a 1 by dividing by the same number (it is either 1 or 0 since we
have no lab pH values >20), and then multiplied (not divided) by 10 to put it into the proper decimal
place. The final pH is built as a total decimal number by adding together all of the decimally weighted
digits. This is all shown in Figure 27.

20
Project #5 - Measuring Electrode Response Times
At last. The pH meter is now built and can be used to measure the response time of the electrode and
meter combination.
This response time is a complex process. It is not just the meter that must quickly respond to changes
in solution pH. Also, the glass membrane that makes up the sensing electrode must rehydrate and reequilibrate with changes in AH+, but also the reference electrode, since the two are housed in the same
body. Perhaps even subtler is the fact that the solution must be remixed inside the electrode body to
cause this re-equilibration. If the electrode combination is suddenly plunged into a buffer solution, then
there will be an acid base reaction as the buffer components adjust. But, if it is just moved between
dilute solutions of different acidity (unbuffered), then it will be just the rate of mixing and subsequent
dilution that determines how quickly the solution composition changes in the immediate vicinity of the
glass membrane. There also are mechanical stirring of the bulk solution effects that have to be considered. And, if there are differences in solution temperature then they will distort the calibration of the
pH meter and make it appear that the response time has changed. Clearly, this is not a simple measurement!

Figure 35 An example of recording pH system response


An example of sudden changes in pH being recorded by the LabVIEW pH meter interface is shown
in Figure 35. The VI was set to sample once per second. The results were not save to a file. Beeping
was turned on. The measurement was to go from 4 to 7 to 120 buffers, then to water, and then back to
4.
Even in this simplistic example, it is clear that there are many things happening. Not all of the response
times are the same. And, it also is not clear if the VI was set to sample fast enough to show the true
system response.

21
Here are the factors to explore when you measure your system response. They are objectives of the
practical part of this experiment.

Determine what the sampling time of the pH meter is. Timing the right flashing LED on the
Plastic station over a dozen or more samples can do this.

Determine how fast your VI will sample with and without Beeping. This can be done by making it repeat a dozen or more times.

Make a series of measurements that will reveal if the plunging the electrode between buffers of
different values, and going in different pH directions, makes a difference in system response
time.

Make a series of measurements to determine if plunging the electrodes between solutions of


similar pH but different buffer capacity, and going in different pH directions, makes a difference in system response time.
Make a series of measurements to determine if plunging the electrode between solutions that are
poorly buffered and differ only slightly in pH, and going in different pH directions, makes a
difference in system response time.

Make a series of measurements to determine the degree to which mechanical stirring of the solutions into which the electrode is being plunged, and going in different pH directions, makes a
difference in system response time.

You might also like