| An oIOPack Object provides access to 4 I/O Lines by indexing the available I/O Lines via the value of the Group and Nibble properties. The Pack property specifies which pack of 4 I/O lines to use. Once the Pack property is set, the Direction and the State properties reference the actual hardware that controls the Direction and State of the specified PIC I/O Pins. The State property references the electrical state of the I/O Pins specified. (Note that this property was added in Firmware C.1. See history.) The Direction property specifies if the I/O Pins are inputs or outputs. (Note that this property was added in Firmware C.1. See history.) When the Direction property is set to 0 (cvOutput), then the specified Pins will output either 0 or 5 Volts depending on what the State property is set to. When the Direction property is set to 1 (cvInput), then the specified Pins are set to be an inputs and the State property will report whether or not 5 Volts is being applied to the Pins by an external device. Note that since the Direction and State properties reference the actual hardware of the specified PIC I/O Pin, then changing the PACK property will also re-index the hardware that the Direction and State properties reference. This means that you MUST set them BEFORE you set the Direction property for the Direction property to affect the I/O line you want to use. For example, if Pins 8-11 are specified and they are inputs, then the Direction property would read 15 and the State property would report the current electrical state of Pins 8-11. Then if the Pack property was changed to 3 and Pins 24-27 were outputs, the Direction property will now read 0 and the State property would report the current electrical state of Pins 24-27. See other examples below. The Port property is used to specify which group of I/O lines to use. The groups are defined by the physical PIC I/O Ports available in the PIC where 1 = Port B, 2 = Port C and 3 = Port D. Setting the Port property to 0 is a special case that concatenates Port A and Port E to form a single continuous group of I/O lines. (Note that this property was added in Firmware C.1. See history.) The Nibble property is used to specify if the lower or upper 4 bit of the port register are used. Each nibble within the PIC's I/O Port registers control four Pins where nibble 0 is the first four physical pins and Nibble 1 is the second four physical pins. When the Port property is 0, which specifies Port A and E collectively, only the upper nibble is accessible which accesses the 3 bits in Port E. Port 0, nibble 0 does not reference any pins. (Note that this property was added in Firmware C.1. See history.) When any of the three properties; Pack, Port or Nibble are set, all three are updated using the formula: Pack = (Port) + (Nibble*4). For example, if the low nibble in Port B is to be used, then the Pack property needs to be set to 1 which works out to: Pack = (1 ) + (0*4). Likewise, the Port and Nibble properties could be set to 1 and 0 respectively. Collectively, there are seven addressable I/O Packs within the ooPIC. Note that the Pack property is the default property. This means that if an instance of the oIOPack Object exists, then not only can the Pack property be set to 1 by assigning it with the statement "IOPack.Pack = 1", it can also be set with the statement: "IOPack = 1" as demonstrated in the oBumper4 Object's help page. Caution: the I/O lines in Group 2 are used for special purposes such as PWM, serial input/output and DDELink. Be sure that you are not attempting to reuse them if the special functions are in use. |