oIOPack Object

Main Index
Object List
Back to top of pageDescription:
 

The oIOPack Object provides access to four I/O lines and is essentially a pointer that allows the program to choose which I/O lines to control at run time.  The program can also, at run-time, re-specify which I/O lines to use at any time.

The selected four I/O lines can be set to read the electrical state presented on them or set to output a specified electrical state.

The difference between this object and the oDIO4 Object is that the oDIO4 Object arranges the properties in such a way that it can be used in a virtual circuit.  Another difference between the two is that oIOPack will use 1 byte of variable memory while the oDIO4 uses 1 byte of object memory.  This can be an important difference when creating large programs. 

 The following table lists the size and availability of the oIOPack Object.
 ObjectSizeDescriptionA1A2B1B2C1
oIOPack1 Byte

Provides access to four I/O lines.

xxxxx
Back to top of pageOperation:
 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.

Back to top of pageProperties:
 

The following table lists the properties of the oIOPack Object:

Property

Description

Pack
A value that specifies the I/O Pack to use.
Object Class: oVar3 Value Range: 0 - 7
Data Type: Numeric Default Value: 0
PackDescription
0

The instance of the oIOPack Object is inactive.

1

Uses the lower half of group 1. (pins 8 - 11)

2

Uses the lower half of group 2. (pins 16 - 19)

3

Uses the lower half of group 3. (pins 24 - 27)

4

Uses the upper half of group 0. (pins 5 - 7) Note that only 3 I/O lines are used.  (See history)

5

Uses the upper half of group 1. (pins 12 - 15)

6

Uses the upper half of group 2. (pins 20 - 23)

7

Uses the upper half of group 3. (pins 28 - 31)

Direction
A value that specifies if the 4 I/O lines are Inputs or an Outputs.
Object Class: oProperty Value Range: 0 - 15
Data Type: Numeric Default Value: N/A
Availability: This property was added if firmware version C.1. 
Each Bit in DirectionConstantDescription
0cvOutput

The specified I/O Line are outputs.

1cvInput

The specified I/O Line are inputs.

State
A value that indicates the current electrical state on the I/O lines.
Object Class: oProperty Value Range: 0 - 1
Data Type: Numeric Default Value: N/A
Availability: This property was added if firmware version C.1. 
Each Bit in State ConstantDescription
0cvOffThe specified I/O line is at 0 Volts.
1cvOnThe specified I/O line is at +5 Volts.
Nibble
A value that selects which half of the Port to use.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Availability: This property was added if firmware version C.1. 
NibbleConstantDescription
0cvLow

The oIOPack Object uses the lower 4 bits of the specified Port.

1cvHigh

The oIOPack Object uses the upper 4 bits of the specified Port.

Port
The PIC Hardware object used to control the I/O group.
Object Class: oPort Value Range: 0 - 3
Data Type: Numeric Default Value: 0
Availability: This property was added if firmware version C.1. 
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of pageExample:
 In the following example, two oIOPack Objects are used.
'This program creates two oIOPack Object
'and outputs a count pattern.

Dim A As New oIOPack
Dim B As New oIOPack

Sub main()
  A.IOGroup = 1
  A.Nibble = 1
  A.Direction = cvOutput
  B.IOGroup = 3
  B.Nibble = 0
  B.Direction = cvOutput
  Do
    A = A + 1
    B = A
    ooPIC.Delay = 10
  Loop
End Sub

Back to top of pageRelated Items:

 The following table lists some of the objects that use the oIOPack Object.
 ObjectDescriptionA1A2B1B2C1
oDIO4Provides a 4-bit digital I/O.xxxxx
oBitShifterAn Object that outputs a bit pattern that shifts.xxx
oBumper4Reads a 4-contact bumper.xxx
oCompassDNReads a Dinsmore 1490 Compass.xxx
oJoyStickReads an Atari style joystickxxx
oOrbitSwitch4Reads a circular array of 4 switches.xx
oStepperControls a stepper motor.xxx
oTrackerAn Object that tracks the position of a line.xxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oIOLineProvides access to a single I/O Line.xxxxx
oIOLineAProvides access to a single I/O Line accessible by the PIC's A2D Module.xxxxx
oIOLinePProvides access to a single I/O Line accessible by the PIC's PWM Module.xxxxx
oIOGroupProvides access to eight I/O lines.xxxxx
Back to top of pageVersion History and Bug List:
 Firmware Ver A1: Introduced as just a pointer.  When IOPack = 0 or 4, the oIOPack Object is inactive.
Firmware Ver B2: Expanded so that when pointing to pack 4, it uses the 3 pins 5 - 7.
Firmware Ver C1: Expanded to include the Nibble, Port, State and Direction properties.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.