USBIO24 ELEXOL, USBIO24 Datasheet - Page 11

DIGITAL I/O MODULE, USB TO 24 I/O

USBIO24

Manufacturer Part Number
USBIO24
Description
DIGITAL I/O MODULE, USB TO 24 I/O
Manufacturer
ELEXOL
Type
USB I/O Moduler
Datasheet

Specifications of USBIO24

Development Tool Type
Digital I/O Module
Tool / Board Application
Digital Signal Transfer
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
USB I/O 24 R Datasheet
Programmers Reference Documentation
Programming the USBIO24 from Visual Basic using the Virtual COM Port.
To operate the USBIO24 from within Visual Basic it is best to use the Microsoft MSComm control
to access the COM port. To input data from the USBIO24 you must use the port in binary mode
and receiving the data is a bit convoluted.
Opening the Port
As the USBIO24 unit uses binary data transfer we must use the port in binary mode.
If the port number is incorrect or the USBIO24 module is not connected then VB will generate an
error.
MSComm1.CommPort = 3 ‘ Set this number as shown in the Device Manager
MSComm1.InputMode = comInputModeBinary ‘ Set Binary Input Mode
MSComm1.PortOpen = True ‘ Open the Port
Setting the pins as Inputs or Outputs
Setting the Ports as Input or Output you must determine the value for the pins you want set as
inputs.
To set pins I/O1, I/O2 and I/O3 as inputs and the remaining pins as outputs you simply add the bit
values of the input pins 1 + 2 + 4 = 7 and thus the value to be placed in the IOValx variable in the
following example code is 7.
‘ Set I/O1, I/O2 & I/O3 of port A to inputs and the rest as outputs.
IOValA = 7 ‘ First 3 inputs all the rest as outputs
IOValB = 0 ‘ All outputs
IOValC = 0 ‘ All outputs
MSComm1.Output = "!A" + Chr$(IOValA) ' Write to Port A Direction Register
MSComm1.Output = "!B" + Chr$(IOValB) ' Write to Port B Direction Register
MSComm1.Output = "!C" + Chr$(IOValC) ' Write to Port C Direction Register
Writing to the Ports
To write to the Output Pins simple repeat the Above without the ! character.
The following example code sets the I/O8 pin on port B to high and the remaining pins as low.
IOValB = 128 ‘ I/O8 high, all the rest low
MSComm1.Output = "B" + Chr$(IOValB)
Elexol Pty Ltd
Version 1.1
Page 11
http://www.elexol.com

Related parts for USBIO24