Unified IO - C++ interface for industrial IO cards
Windows NTDownload distribution package from www.bbdsoft.com
Unzip it to any directory on your hard disk.
For Windows NT only - use loaddrv.exe utility to install and load Unified IO hardware access driver. You can install and load this driver using following command line:
Loaddrv uniio <full path to your driver >\uniio.sys
To verify installation of the driver open Windows NT Control Panel item "Devices", find device uniio. Status should be "Started", Startup should be "Manual". In the future this driver will load automatically when you use Unified IO first time after restart. If you wish to load this driver automatically during Windows NT startup select push button "Startup…" and select Startup type – "Automatic". Then press "OK" button.
You can build release version of entire Unified IO package by executing br.cmd batch file. Debug version can be built by bd.cmd batch file. Already built release version for Microsoft Visual C++ of uniio.dll and uniio.lib are included in the package.
Size of Unified IO package can be reduced if you software does not have to support all IO cards supported by Unified IO.
.cpp file |
Required if |
osiface.cpp iotrack.cpp iocard.cpp |
always |
physmem.cpp fwfbuff.cpp ab1784card.cpp 1784dpram.cpp |
AB1784KTx card supported |
ioport.cpp |
any card other than AB1784KTx supported |
ac5card.cpp |
OPTO22 AC5 card supported |
pc7166card.cpp |
US Digital PC7166 card supported |
ac28card.cpp |
OPTO22 AC28 card supported |
dummycard.cpp |
testing without actual IO cards is supported |
pcibus.cpp pcidev.cpp pcicfg1.cpp pcicfg2.cpp pcicfgdr.cpp pcicfgsl.cpp pcicfg.cpp pci72xxcard.cpp |
Arbor Technologies PCI-7248 or PCI-7296 card supported |
Unified IO is designed to be platform independent C== class library for hardware control. Basic structure is in the figure bellow:
Figure 1 Unified IO Architecture
Therefore only small portion of Unified IO is platform dependent. This part varies depending on operating system. But basically this code should provide ability to perform port IO and direct memory access. Specific IO card wrappers are using only interface of platform dependent classes. As a result support for n cards under m platforms would require only n+m code modules. Traditional approach would require n*m device drivers. End user is using only platform independent Standard C++ code and therefore code is fully portable.
Unified IO is based on concept of IO Tracks. IO Track is a logical group of consecutive IO point controlled by the same IO interface card. There are 6 types of IO points:
Object of class inherited from abstract class IOCard is created for each IO card in the system. Then IO tracks have to be associated with IO cards. Then program control loop:
Here is a sample code of IO Track and IOCard creation:
// create digital IO card object AC5Card aDigitalCard (0x220); // create 2 tracks consisting of digital IO // and associate tracks with the card IOTrack track ( aDigitalCard // IO card reference , 0 // starting point , "IIIIIIIIIIIIOOOO" // track of 12 inputs and 4 outputs );
Specific IOCard instance is created. You should consult specific IOCard class description for constructor parameters description. In our case OPTO 22 AC5 card is created and it’s base address is passed in the constructor.
IO Track is created by providing a reference to a specific IOCard object to which this track belongs. Since IOTrack is an abstraction of physical group of inputs, outputs and other elements, multiple IOTracks can belong to the same IOCard. For this purpose starting point parameter is used. First IOTrack for any IOCard should have starting point 0. Other IOTracks in the same IOCard should have starting point more than 0. Usually this number is incremented by the number of points of previous track. In our example starting point for a next track on the same IOCard would be 16. Third parameter of IOTrack constructor is used to specify IO mask of the IOTrack. This can be any combination of the following characters (assuming specific IOCard supports them):
‘N’ Not UsedIf specified point type is not supported by a specific card an exception is thrown.
User is responsible for correct destruction of objects of classes IOCard and IOTrack.
Class IOTrack provides all necessary interface to read from and write to IO points. By calling function IOTrack::updateInputs() IOTrack reads all inputs belonging to this track from IOCard and places values to an internal image.
Later you can access this image by using IOTrack::operator [].
All modifications to outputs are performed in this internal image and are written to IOCard by calling function IOTrack::updateOutputs().
Usually all IO control is performed within an loop. In the beginning of the loop reading inputs from all tracks, then performing control logic and writing outputs to all tracks at the end.
Here is a simple example of reading and writing to IO points:
while (1) { // read current state of all inputs track.updateInputs (); // do control logic if ( track[5] && track[1] ) { track[14] = 0; } // endif // activate/deactivate outputs track.updateOutputs (); // sleep for 10 milliseconds = 10000 microseconds OSInterface::sleep (10000); } // endwhile
Class for accesing Allen-Bradley 1784 KTx series of cards by Remote IO protocol
returns dual port RAM address provided while constructing AB1784Card
Returns Remote IO link speed
returns full path to directory where AB1784KTx firmware files are stored.
An abstract class for representation of IO interface card.
default implemetation of reset operation does nothing.
Returns name of IO card
provides access to physical memory block from user process.
Retrives pointer to the specified block of physical memory.
modifies physical memory block
reads block of data from physical memory
returns size of a physical memory region
OPTO 22 ISA AC28 Pamux bus card wrapper
Returns base IO port address
returns reset port address
returns reset level. true - HIGH, false - LOW
OPTO 22 ISA AC5 direct digital card wrapper.
returns base IO port number - parameter provided while constructing AC5Card
Default implementation of IOCard, could be used to test functionality of software without actual IO cards.
Class for implementing file buffer for loading firmware files
Returns the size of an firmware file
Returns pointer to a firmaware file buffer read from disk
Represent class wrapper for reading and writing from PC IO ports
represents IO port. Constructor enables access to a port.
writes 1 byte of data to the port.
writes 2 bytes of data
writes 4 bytes of data
-
reads 1 byte of data
reads 2 bytes of data
reads 4 bytes of data
Basic abstraction level of physical IO track. Track must be asociated with an specific IO card.All input/output operations are performed through IOTrack.
-----------------------------------------------------------------------------
return type of specified IO point.
returns if there are any points of specified type.
meaning of starting point value is IO card specific.
Returns number of points per track
Returns a reference to IOCard which this trac belongs to.
returns track state code. 0 always means OK, other state codes are
IO card specific
returns state of individual IO point
changes state of individual IO point
reads current state of all input points from IO card. Should be called periodically.
modified physical state of all output points. Should be called periodically or after output state modification.
Singleton class for accessing operating system services. Windows NT implementatin loads and opens uniio.sys driver that is used to enable port IO from user process and retrive pointer to physical memory block. All communication with device driver is performed through OSInterface class.
suspends execution of the current thred for specified number of microseconds
Class for accessing USDigital PC7166 Encoder counter card. This card accepts tracks only with 'C' or 'R' types
Returns base IO Port of this card
Reset encoder counters to 0
Class for interfacing Arbor Technologies PCI-7248 and PCI7296 direct digital IO cards
Singleton class representing computer PCI bus.
Tests if PCI bus exists on the system
returns pointer to Device Information structure or NULL or device with specified ID is not present in the system
Clas for representing PCI device information retrieved from PCI Bus.
base addresses are from 0 to 5
Abstract class representing method of retrieving PCI device information.
returns if this PCI configuration retrieval method is available in the computer.
Function which scans PCI bus on first use and stores retrieved information in the PCIBus class
Class for direct PCI access using "Type 1"
Command word for Config1 access
-----------------------------------------------------------------------------
end destructor
-----------------------------------------------------------------------------
end constructor
-----------------------------------------------------------------------------
Abstract class for retrieving PCI device information using direct port IO.
Class for Direct PCI access using "Type 2"
end destructor
-----------------------------------------------------------------------------
end constructor
-----------------------------------------------------------------------------
Class which selects what PCI acces type should we use on a specific platform. Platform specific. On a Windows NT PC systems tries PCIConfig1 and if this one fails uses PCIConfig2.
determines which PCI bus configuration retrieval options are available and creates appropriate PCIConfig object.