6.15 DIO Functions
Modules for the following DIOs exist:
-
witio_48
Wasco WITIO-48 ISA DIO card by Messcomp Datentechnik GmbH
-
me_dio_X
DIO subsystem of cards by Meilhaus Electronic GmbH
To use a module in an experiment put its name into the DEVICES
section of the EDL
script.
Both cards reqyuire the use of of a kernel module and an additional
library that have been successfully installed. The driver and library
for the Wasco WITIO-48 card comes with fsc2
,
the one for the ones for the Meihaus cards can be downloaded from the
Meilhaus web site.
List of DIO functions:
Since the cards differ quite a bit in their capabilities the arguments required to be passed to the functions also can be different!
Descriptions of DIO functions:
- `dio_name()'
Returns a string with the name of the DIO device being used.
- `dio_reserve_dio()'
This function can be used to reserve (or un-reserve) a DIO so that it can only be used with a pass-phrase. This will mainly be used by modules for other devices that require a DIO to keep an
EDL
script from accdentally changing the output or reading the input of the DIO.In the case of the Wasco Wasco WITIO-48 card the first argument is the DIO to be reserved (or released). This must be either a number,
1
or2
or, better, a symbolic name,DIO1
orDIO2
. For the Meilhaus DIO subsystem the whole subsystem gets locked or unlocked, so no DIO number can be passed to the function.If there is no further argument an integer is returned. If it is
1
the DIO or subsystem is reserved, if it's0
it's not reserved and can be used without a pass-phrase.The next argument is a string variable to be used as the pass-phrase in later calls of the functions dio_mode() and dio_value().
The final argument is optional. If is not given the function will try to reserve the DIO or subsystem. If called with either an argument of
0
or a string"OFF"
the DIO or subsystem is released so that it can be freely used again. If called with either an argument of1
or a string"ON"
the DIO or subsystem is reserved (which is identical to not passing it this argument).The function returns an integer, if it is
1
the operation (i.e. reserving or releasing the DIO or subsystem) succeeded, if it is0
the operation failed.- `dio_mode()'
The Wasco WITIO-48 card has two DIO chips, both allowing 24 bit wide input and output. These DIOs can be further split up into sub-DIOs of smaller width. By calling this function you can set the way a DIO is split up.
In contrast, the Meilhaus card DIO subsystem has a single 32-bit wide DIO which can be split up into either 32 1-bit wide DIO channels, 4 8-bit wide channels, 2 16-bit wide channels or 1 32-wide channel.
For the Wasco WITIO 48 card the function expects at least one argument, the DIO to be used with the function. This must be either a number,
1
or2
or, better, a symbolic name,DIO1
orDIO2
. When called without another argument the current mode is returned as an integer number (as they could also be specified to set a mode, see below). If there is a second argument this is the mode to be set. You can use either a number or a string to specify the new mode:- `
0
or"3x8"
' The DIO is split up into three independent 8-bit DIOs, which then can be addressed as channels in calls of the function dio_value().
- `
1
or"2x12"
' The DIO is split up into two independent 12-bit DIOs, which then can be addressed as channels in calls of the function dio_value().
- `
2
or"1x24"
' The DIO isn't split up at all but used as a 24-bit wide DIO.
- `
3
or"16_8"
' The DIO is split up into two independent DIOs, one with a width of 16 bit and one 8-bit wide. These can be addressed as channels in calls of the function dio_value().
If no mode is set for a DIO the mode for 24-bit input and output is used per default.
For a Meilhaus me6000 card DI, DO or DIO subsystem the only argment is optional. If none is given the current mode is returned as a number, either
1
for the mode where 8 1-bit wide channels are used and8
for the mode with 1 8-bit wide channel. If instead one of these numbers is passed to the function the corresponding mode is set (if available).- Please note:
If the DIO or subsystem had previously been reserved by a call of the function dio_reserve_dio() the pass-phrase specified in that call has to be passed to the function as the very first argument if you want to be able to change the mode of the DIO.
- `
- `dio_value()'
This function is used to either input or output a value. For the Wasco WITIO-48 card the first arguments must be the DIO to be used (preferably use the symbolic names
DIO1
andDIO2
). and a channel. For both modules the channels to be used must be specified. Depending on the mode the DIO has been set to using the function dio_mode(), for the Wasco WITIO-48 either one, two or three channels can be used, for the Meilhaus card DIO subsystem one, two, four or 32 can be available. Always use the symbolic namesCH1
,CH2
,CH3
etc. If there is no further argument data will be read in from the DIO and passed back to theEDL
script as the return value of the function.If there's a third argument it is taken as the value to output at the DIO (or, to be precise, the channel of the DIO). How many channels can be used, what range of data can be output and how each bit the value is mapped to the output pins depends on the mode the DIO is been set to.
For the Wasco WITIO-48 card we have:
- `
"3x8"
mode' Since in this mode there are three independent sub-DIOs, three channels,
CH1
,CH2
andCH3
, can be used. Each channel is 8-bit wide, so the range of values that can be output (or input) is restricted to numbers between0
and255
.If the channel is
CH1
the bits of the value are output at the pins of the connector labeled1PA7
to1PA0
forDIO1
and at the pins2PA7
to2PA0
forDIO2
, where the most significant bit goes to the highest numbered pin 7 and the least sigificant bit to the pin numbered 0. If a channel ofCH2
has been selected the bits are mapped to the pins1PB7
to1PB0
or2PB7
to2PB0
and forCH3
to the pins1PC7
to1PC0
or2PC7
to2PC0
.- `
"2x12"
mode' In this mode the DIO is split into two 12-bit wide sub-DIOs, so only
CH1
andCH2
can be used to output a value between0
and4096
. ForCH1
the topmost 4 bits of the value are mapped to the pins1PC7
to1PC4
or2PC7
to2PC4
(with the most sigificant bit at1PC7
or2PC7
) while the lower 8 bits go to the pins1PA7
to1PA0
or2PA7
to2PA0
(depending on the selected DIO). ForCH2
the topmost 4 bits of the value appear at the pins1PC3
to1PC0
or2PC3
to2PC0
and the lower 8 bits are mapped to theB
-pins,1PB7
to1PB0
or2PB7
to2PB0
.- `
"1x24"
mode' The DIO isn't split into sub-DIOs, so the only allowed channel in this mode is
CH1
and the range of valid values is0
to16777215
. The highest 8 bits of the value go to theC
-pins (i.e.1PC7
to1PC0
forDIO
or2PC7
to2PC0
forDIO2
), the middle byte is mapped to theB
-pins and the lowest byte of the value to theA
-pins.- `
"16_8"
mode' In this mode the DIO is split into a 16-bit and an 8-bit wide DIO.
CH1
is the 16-bit DIO, allowing to output values between0
and65535
, andCH2
is the 8-bit DIO, allowing a the value to be between0
and255
. ForCH1
the upper byte of the value is mapped to theB
-pins while the lower byte appears at theA
-pins. TheC
-pins are used to output the value forCH2
.
For the Meilhaus me6000 card DIO subsystem we have:
- `1-bit mode'
In this mode the DI, DO or DIO is split up into 8 channels and for each channel only a value of
0
and1
can be set.- `8-bit mode'
In this mode the DI, DO or DIOO has a single channel, 8 bit wide. Values between
0
and255
can be used.Please note that a DI subsystem can only be used for input and a DO subsystem only for output. Also note that for a number of these cards only all 8 bits of a DIO subsystem can be switched between input and output together and not individually.
- Please note:
Except in the case of the Meilhaus card DIO subsystem in 32-bit mode trying to output a negative value will make the program abort immediately as will trying to output too large a value during the test run. During the experiment a too large value will be truncated to the allowed range by stripping off the higher order bits and a warning message is printed out.
- Also note:
if the DIO had previously been reserved by a call of the function dio_reserve_dio() the pass-phrase specified in that call has to be passed to the function as the very first argument if you want to be able to read from or write to the DIO.
The function can only be used in the
EXPERIMENT
section of anEDL
script.- `
This document was generated by Jens Thoms Toerring on September 6, 2017 using texi2html 1.82.