|
Using VB With IASI2
Source code for this can be found in the
downloads section.
This
is a screen shot of a VB program written in VB 2005 Express
Edition that will directly interface to an IASI2 device either
connected to a COM port or through a converter device such as a
BV101 or BV201Here is a BV4102 Matrix connected to a BV101
 |
|
Connecting to the PC
Method 1 By direct connection to a COM
port or through a serial connector. All IASI2 devices can be connected
directly to a COM port or through a USB to serial converter,
Prolific for example. The wiring diagram is shown here:
 |

A practical set up, the white lead has 4 wires and comes from
the COM port. The plus 5V is provided by a
BV1102 which is wired into the connector. Shown is the back
of an IASI2 LCD display. |
A power supply will be needed (see bv1102) as
the COM power does not provide any power of its own, unlike the newer
USB specification. This is called the inverted method because the output
from RS232 is inverted. All IASI2 devices default to inverted at start
up.
Method 2 By using a serial to TTL, Logic
convertor. This method is the same as that used for direct connection to
a microcontroller but as we are using a PC, the RS232 signals will need
to be converted to 5V levels.
Option A - MAX232
The MAX232 is a buffer driver chip that will
convert the voltage levels used in RS232 (+ and - 12V) to 5V logic
levels, for convenience the BV201 is available that uses the MAX232 but
also has the 9 pin connector required for connection directly to a RS232
COM port.
 |

This shows a practical example connecting a BV4103 to a RS232
COM port via the MAX232 (BV201) converter, this time the power
supply is required to power both the BV210 and the BV4103. |
Option B USB
There are a few USB-TTL converter on the market, these should not be
confused with the Prolific type that convert USB to RS232. ByVac has one
called the BV101.
 |

This shows that a BV101 can connect directly to an IASI device. |
This option is probably the easiest as the connection can be done
directly and there is no need for a power supply. Pin 4 is not
connected to anything on the BV101 and so can either be connected or
not. A convenient method of connecting several devices together is
to use a 10 way ribbon cable and IDC connectors as no soldering will
be required.
Only
half of the 10 way cable is used and only one side of the 10 way
connector, this is because it is not possible to get a 5 way IDC
connector but for convenience there is nothing to beat it especially
when connecting multiple IASI devices on the same bus.
The Software
IASI-Generic
All IASI devices work on simple text commands so it is a matter
for the software to send the appropriate text via a COM port. To
illustrate this as simply as possible download the IASI-Generic
source code from the software section.
The code has two VB files, one for the form and the other dedicated
to IASI. The following describes how the software works in sections
so that you can use or modify it according to your project. This
code has been made as simple as possible to illustarte the concepts
when using these devices.
Opening the COM Port
This is a vital step as all communication will be via the COM
port. When the form opens it runs
Populate_Ports(). This conveniently gathers all of the
available ports on the system and places them in the combo box.
Opening the COM port with cmdOpen_Click
enables the rest of the form panels and turns the button green. Any
errors at this point will be trapped by the system as error checking
has been purposely left out to make the code simpler to understand
and use.
Establishing a Connection
There are two options for establishing a connection, RS232 and
UART. The RS232 is for when the device is connected directly to the
PC COM port and is called INVERTED and UART for when the device is
connected via method 2 described above and is called non-inverted.
A connection is established by sending 2 or 3 bytes with a value
of 13 (ASCII Carriage Return - CR) followed by a byte with a value
of 1. For non-inverted connections another byte is required with a
value of 4. This can actually be sent before or after the '1'
command. This is taken care of by Connect
subroutine in the IASI.VB module. On successful connection the
device will return its address followed by '>'. Each device has its
own time slot for responding to command 1, address 'a' will respond
first and address 'z' last. It can take up to 800 ms for 'z' to
respond and hence the delay.
For working systems this routine could be improved by checking
for the correct response and re-trying if required. For this program
all that happens is the returned result is displayed in the text box
opposite the button.
Sending Commands
A command is placed in the text box including the address and
will be sent when the button is pressed, the result will be
displayed in the edit box at the bottom of the form.
The Prompt
Most commands when successfully completed by the device will send
back a prompt this is a byte with the value of 62 (0x3e) which is
the ASCII code for '>'. Application software can take advantage of
this. In the function SendText a
command is sent to the device via the COM port
(Form1.Sout('command')) and then a loop is set up that will exit
when '>' is received. Just in case there is a problem with the
device or the command a timer is used that will cause the loop to
exit.
For a more complex example look at the other VB code in the
software list.
|