| An oIOLine Object provides access to an I/O Line by indexing the available I/O Lines via the value of the Group and Bit properties. The Line property specifies which I/O Line to use. Once the Line 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 Pin. The State property references the electrical state of the I/O Pin specified. (Note that this property was added in Firmware C.1. See history.) The Direction property specifies if the I/O Pin is an input or an output. (Note that this property was added in Firmware C.1. See history.) When the Direction property is set to 0 (cvOutput), then the specified Pin 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 Pin is set to be an input and the State property will report whether or not 5 Volts is being applied to the Pin 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 Line property will also re-index the hardware that the Direction and State properties reference. This means that you MUST set the IOLine property BEFORE you set the Direction property for the Direction property to affect the I/O line you want to use. For example, if Pin 1 is specified and it is an input, then the Direction property would read 1 and the State property would report the current electrical state of Pin 1. Then if the Line property was changed to 2 and Pin 2 was an output, the Direction property will now read 0 and the State property would report the current electrical state of Pin 2. 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 Pin property is used to specify which pin within the Port to use. Each bit within the PIC's I/O Port registers control a single Pin where Bit 0 is the first physical pin and Bit 7 is the eighth physical pin. When the Port property is 0, which specifies Port A and E collectively, the pins span across Port A and Port E with the exception that Port 0, Pin 0 does not reference any pin. (Note that this property was added in Firmware C.1. See history.) When any of the three properties; Line, Port or Pin are set, all three are updated using the formula: Line = (Port * 8) + (Pin). For example, if the eighth Pin in Port B is to be used, then the Line property needs to be set to 15 which works out to: Line = (1 * 8) + (7). Likewise, the Port and Pin properties could be set to 1 and 7 respectively. Collectively, there are Thirty-one addressable I/O Lines within the ooPIC. Note that the Line property is the default property. This means that if an instance of the oIOLine Object exists, then not only can the Line property be set to 8 by assigning it with the statement "IOLine.Line = 8", it can also be set with the statement: "IOLine = 8" as demonstrated in the oLED 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. |