Programming Guide: CRD155B
For information regarding specific Portal API functions,
see the function reference.
General:
-
A note to those who are familiar with the 8255 chipset used on this card:
The 8255 is always operated in mode 0 when using the Portal API
to access the card. Port C has the capability to be split up and
each portion of the port configured independently of the other. The
API does not do this, instead it treats Port C as a single port and configures
the entire 8 bits as a whole.
-
The CRD155B has 3 ports which can be programmed for input or output.
Therefore, the Port parameter in the API functions can be 1, 2,
or 3 when you are using this particular card model. Port 1 is actually
Port A on the 8255 chip, Port 2 = Port B, and Port 3 = Port C.
-
See the user's manual to find the pinouts of the ports on the back of the
I/O card.
Diagnostic Program:
Winford Engineering has created a diagnostic program
for the CRD155B which will help you to quickly test your ideas or simple
projects without having to write your own test code. It can also
be used to verify that your card is working correctly. This diagnostic
program allows you to open your card, configure it as you wish, and input
and output values. This program is included in the "samples/crd155btest"
directory of the Portal distribution for both Windows and Linux platforms.
To help you get started in your programming projects, the source code is also included.
Supported Functions:
-
we_OpenCard - ModelID should be set
to the constant WECRD_155B, BaseAddr will vary depending on how
you have set the DIP switch on the card. See the manual for the switch
settings. BaseAddr should be set to the actual base address
for which the card is configured. When we_OpenCard is called for
a CRD155B, the card is configured so all 3 ports are inputs. Therefore,
if a port was previously configured for output before we_OpenCard was called,
its value will be lost when we_OpenCard configures that port for input.
-
we_ConfigureCard - Port may
be 1, 2, or 3. If you need to configure multiple ports, simply call the
function multiple times. Mode may be one of the constants
WECRD_INPUT or WECRD_OUTPUT which configures the port to be an input port
or an output port respectively. Because the CRD155B uses the 8255
chip, every time we_ConfigureCard is called, all output registers on the chip
will be cleared. This means that any port configured as an output
port will have its current value cleared when we_ConfigureCard is called.
This occurs even if the port remains an output port after the we_ConfigureCard
function is finished. For example, suppose that Port 1 is configured as an
output port with a current output value of 255. Now suppose that we_ConfigureCard
is called in order to configure Port 2 to also be an output port. Now both
Ports 1 and 2 are output ports. However, Port 1's output value of 255 has been
cleared and is now 0 because the card was reconfigured.
Due to this behavior, it is often wise
to configure the card properly at the beginning of a program and then,
unless it is actually necessary, do not call we_ConfigureCard after that
point in your code. It is certainly fine to call we_ConfigureCard
in the middle of your program, but just be aware of its subtle side-effects.
This behavior is a result of the 8255 chip architecture.
- we_InputValue - Port may be 1,
2, or 3.
- we_OutputValue - Port may be 1,
2, or 3. The Value parameter to this function is a 32 bit
parameter. However, the CRD155B is an 8-bit card, which means
only the lowest eight bits of any output value will be sent to the card.
- we_ReadBack - Port may be 1, 2, or
3.
- we_CloseCard - When a CRD155B is closed,
either with this function or with we_CloseAllCards, the card itself and
the port states remain unaffected. The ports will remain configured
and any output ports will retain their values. Only when you call
we_OpenCard will the ports be automatically reconfigured as inputs.
- we_CloseAllCards
Copyright 2004 Winford Engineering.