:Revision=2
:html
<<
128.131
IC Port-Expander PCF8574-Object|PCF8574
--
The IP-Object PCF8574 realizes the digital output via the PCF8574 port on the IC Bus.

The single port chips must be defined in the I2CBusses.Dat and are addressed by their names.

The defintion is made within the I2CBusses.Dat after the definition of the buses in a block, which is started with [PCF8574]. Afterwards in each row a PCF8574 port chip is defined:

Example of a I2CBusses.DAT:
<!CODE>
{-----------------------------------------------------------------------------------------}
// BusName      Type            Data                            Info
{-----------------------------------------------------------------------------------------}
I2C_MCD         I2CviaME3000    (SDAIn=A13;SDAOut=B8;SCLOut=B9) Default Bus intern in Victor
I2C_Adapter     I2CviaRS232     (Port=1; Invert=true)           relocated System over RS232 Port1

//----------------------------------------------------------------------------------------
// Name         BusName         Address Data
//----------------------------------------------------------------------------------------
[PCF8574]
PCF0            I2C_Adapter     0       (Used=$3F;INVERT=$ff;PINS=Relais1,Relais2,Relais3,Relais4,Relais5,Relais6,--,--)
PCF1            I2C_Adapter     1       (Used=$3F;INVERT=$ff;PINS=Relais7,Relais8,Relais9,Relais10,Relais11,Relais12,--,--)
PCF2            I2C_Adapter     2       (Used=$3F;INVERT=$3f;PINS=Relais13,Relais14,Relais15,Relais16,Relais17,Relais18,--,--)
PCF3            I2C_Adapter     3       (Used=$3F;INVERT=$3f;In=$C0;PINS=Relais19,Relais20,Relais21,Relais22,Relais23,Relais24,--,--)
PCF4            I2C_Adapter     4       (Used=$1F;INVERT=$1F;IN=$E0;PINS=Relais25,Relais26,Relais27,Relais28,Relais29,IN,IN,IN)
{--End of Data--}
<!TXT>
The line with [PCF8574] starts the definitions.

Each of the following lines starts with the name of the PCF8574 port. This name will be used to address the port. This name should be a valid interpreter identifier.

The name is followed by the name of the bus, where the port IC is attached. 

This bus name must have been defined earlier in the busses part of the file.

The third element is the address of the port IC, as selected with the 3 address pins. The addresses 0-7 apply to the PCF8574<b>P</b> types, while the addresses 8-15 are used for the PCF8574<b>AP</b> types. Each address may be used only once per bus.

The forth element is a list (separated by semicolons) of optional additional data between brackets. The additional data has the following setup "Name=Value". "Name" specifies the type of date. Permitted "Names" are:

 <!CW>USED specifies which bits are used followed by an 8 bit value, where a set bit indicates that the bit is used (default=$FF / 255). This value has effect only on the display on the monitor; unused pins are grey.

 <!CW>INVERT determines which output signals will be inverted (active=low, inactive=high), followed by an 8 bit value, where a set bit indicates that the pin is inverted (default=$00 / 0).

 <!CW>IN determines which pins must be considered as input, followed by an 8 bit value, where a set bit indicates that the pin is an input (default=$00 / 0).

Please not that a Pin cannot be an inverted output and an input at the same time: <!CW>(IN <!CW>& <!CW>INPUTS) must be 0.

 <!CW>PINS define names for the single pins in the monitor. The pin names are separated by commas. Therefore <!CW>PINS may not contain neither commas nor semicolons.
>>
<<
128.131.1
Functions of the PCF8574-Object|Functions
--
>>
<<
128.131.1.1
PCF8574.Get|Get
--
<!DEF>
function <!TW>PCF8574.Get (sPCFName : string) : real;
<!TXT>
Returns the output-state (it is not read in) of the PCF8574-port with the name <!PW>sPCFName as 8 bit value.
>>
<<
128.131.1.2
PCF8574.Read|Read
--
<!DEF>
function <!TW>PCF8574.Read (sPCFName : string) : real;
<!TXT>
Returns the input-status (it is read in) of the PCF8574-port with the name <!PW>sPCFName as 8 bit value.
>>
<<
128.131.1.3
PCF8574.Error|Error
--
<!DEF>
function <!TW>PCF8574.Error (sPCFName : string) : real;
<!TXT>
Returns <!RW>TRUE, if during the last action of the PCF8574-port with the name <!PW>sPCFName an error occured.
>>
<<
128.131.2
Procedures of the PCF8574-Object|Procedures
--
>>
<<
128.131.2.1
PCF8574.Bits|Bits
--
<!DEF>
procedure <!TW>PCF8574.Bits (sPCFName : string; rBits, rOperation, rSendIt : real);
<!TXT>
The actual output bits of the PCF8574-port with the name <!PW>sPCFName are combined with the bit patterm given by <!PW>rBits as specified in the <!PW>rOperation. 

 If <!PW>rSendIt = <!RW>Send, then the data is sent to the chip, otherwise it is stored internally.

 <!PW>rOperation can be : <!RW>CLR | <!RW>SET | <!RW>FLIP | <!RW>NOP or 0..3

 <!PW>rSendIt can be    : <!RW>STORE | <!RW>SEND        or 0..1
>>
<<
128.131.2.2
PCF8574.Word|Word
--
<!DEF>
procedure <!TW>PCF8574.Word (sPCFName : string; rBits, rSendIt : real);
<!TXT>
The bit pattern given in <!PW>rBits is transfered to the PCF8574-port with the name <!PW>sPCFName.

If <!PW>rSendIt <!RW>= Send, then the data is sent to the card, otherwise it is stored internally.

 
The <!PW>rSendIt can be    : <!RW>STORE | <!RW>SEND     or 0..1
>>
<<
128.131.2.3
PCF8574.BitsEx|BitsEx
--
<!DEF>
procedure <!TW>PCF8574.BitsEx (rGroup : real; sCommand : string);
<!TXT>
Macrocommand : Sets/deletes Bits on PCF8574-Chips and waits

 <!PW>rGroup selects an action group (0..9)

 <!PW>sCommand has the following form:
<!CODE>
<!SW>Address[+<!SW>Address...],<!SW>Action[,<!SW>Action...][;<!SW>Address[+<!SW>Address...],<!SW>Action[,<!SW>Action...]...]
<!TXT>

 <!SW>Address is a bit pattern on a PCF8574 Chip.
Several addresses can be connected with +.

<!SW>Address can be given in 2 forms:
   
<h5>1. as bit pattern</h5>
<!CODE>
<!SW>PCFName<font color=#ff0000><b>$</b></font><!SW>BitPattern
<!TXT>
 <!SW>PCFName is the name of a PCF8574Chip as defined in the I2CBusses
 <!SW>BitPattern is the complete bit pattern in Hex syntax
  Example : <!CW>PCF1$03 - both lower bits of port PCF1
<h5>2. via bit number</h5>
<!CODE>
<!SW>PCFName<font color=#ff0000><b>.</b></font><!SW>Bit[<font color=#ff0000><b>.</b></font><!SW>Bit ...]
<!TXT>
 <!SW>PCFName is the name of a PCF8574Chip as defined in the I2CBusses
 <!SW>Bit is a number from 0 to 7. The bit numbers are separated by points.
  Example : <!CW>PCF1.0.1 - both lower bits of port PCF1

<!SW>Action has the following setup (n is always the group number 0..9 or 'x') :

<!STBL>
<!>nS <!>Sets the bits<!>
<!>nR <!>Resets the bits<!>
<!>nDz<!>Delay of z milliseconds<!>
<!ETBL>

 <!SW>n indicates the group. Only those actions are executed whose groups are selected by the parameter <!PW>rGroup. 'x' matches any <!PW>rGroup.

<ul indent=12>
<li>if no action is activated via <!PW>rGroup, nothing happens</li>
<li>if no actions are specified, nothing happens</li>
<li>if <!PW>sCommand is empty, nothing happens</li>
<li><!PW>sCommand can specify several addresses+actions (separated by ';')</li>
</ul>

Example
<!CODE>
PCF8574.BitsEx (1, 'PCF1$A+PCF2.7,1r,9s');

'1' activates group 1.
The parts of sCommand 
'PCF1$A+PCF2.7' are two addresses:
  'PCF1$A' -> Bit 3 and Bit 1 of port PCF1
  'PCF2.7' -> Bit 7 of port PCF2
'1r' if group 1 active, then reset the bits
'9s' if group 9 active, then set the bits 

Since group 1 is active, the bits are deleted
<!TXT>
>>
<<
128.131.2.4
PCF8574.Send|Send
---
<!DEF>
procedure <!TW>PCF8574.Send (sPCFName : string);
<!TXT>
Sends any internally stored data of port <!PW>sPCFName.
>>

<<
128.131.2.5
PCF8574.Pin|Pin
--
The PCF8574.Pin - object...
>>
<<
128.131.2.5.1
PCF8574.Pin.Info|Info
--
The PCF8574.Pin.Info - Object...
>>
<<
128.131.2.5.1.1
PCF8574.Pin.Info.Set|Set
--
<!DEF>
procedure <!TW>PCF8574.Pin.Info.Set (sPCFName : string, rPinNr : real, sPinInfo : string);
<!TXT>
Set the info text <!PW>sPinInfo for pin <!PW>rPinNr of port <!PW>sPCFName.
>>
