oCounter2H Object

Main Index
Object List
Back to top of pageDescription:
 A Hardware Object that counts the number of high-speed cycles on an input using hardware specific I/O lines.

The following table lists the size and availability of the oCounter2H Object and its variations.
 ObjectSizeDescriptionA1A2B1B2C1
oCounter2H3 BytesCounts the number of high-speed cycles on an input.xxx

Back to top of pageOperation:
 The oCounter2H Object counts each cycle of the input on I/O Line 16 by incrementing the 16-Bit Count property each time the input cycles. When the Count property reaches 65535, the next cycle will cause the Count property to roll to 0.

The Operate property specifies if the Count property will increase each time the input cycles.

An MSB oLogic property is provided which reflects the 16th bit of the Count property's data and can be pointed to by a virtual circuit in which it can be used as the input to a oCounter Object to extend the count. 

The PreScale property divides the input cycles before they are counted.

The Timer property is an instance of the oTimer object which is created when the oCounter2H is.  It uses this object to maintain the actual 16-bit count.  The oCounter2H configures its properties so that it will count the cycles present on I/O Line 16.  Changing the oTimer Object's properties can be set and will affect the way the oCounter2H operates.  Note that since all instances of the oTimer Object use the same PIC hardware therefore all instances of the oCounter2H Objects will read the same 16-Bit value.  Also note that all other objects that use the oTimer object will also use the same 16-Bit value as well.  For instance, The oFreqH Object uses an instance of the oTimer object. (see oTimer Object for more detail)

Back to top of pageProperties:
 

The following table lists the properties of the oCounter2H Object:

Property

Description

Count
The current cycle count value.
Object Class: oWord Value Range: 0 - 65535
Data Type: Numeric Default Value: 0
PreScale
A value that selects what the count will be divided by.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
PreScaleDescription
01:1 - The count is not changed.
11:2 - The count is divided by 2.
21:4 - The count is divided by 4.
31:8 - The count is divided by 8.
Operate
A value that selects whether or not the counter counts the cycles on the input.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe counter does not count the cycles on the input.
1cvOnThe counter counts the cycles on the input.
MSB
The Most-Significant-Bit of the count data which cycles each time the counter counts to 65535.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
MSBDescription
0Count property is <= 32767
1Count property is >= 32768
IOLineC
I/O Line 16 used as an external clock source.
Object Class: oIOLine Value Range: 16
Data Type: Numeric (Read-Only) Default Value: 16
Timer
The PIC Hardware object used to maintain the count.
Object Class: oTimer Value Range: 
Data Type: Numeric Default Value: 0
Configured to count the cycles present on I/O Line 16.

Note: Timer is an instance of the oTimer Object.  All instances of the oTimer Object use the same PIC hardware, Therefore all instances of the oCounter2H Objects will read the same 16-Bit value.  Also not that setting its properties can affect the way the oCounter2H operates.

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, the oCounter2H Object's Count property is outputted on the oDio16's 16 I/O lines.
' Copy the oCounter2H's
' Value to an oDio16.

Dim T As New oCounter2H
Dim D As New oDIO16 

Sub Main()
  D.Direction = cvOutput
  T.Operate = 1
  T.PreScale = 3
  T.Operate = cvTrue
  Do
    D.State = T.Count
  Loop 
End Sub
Back to top of pageRelated Items:
 The following table lists other objects with related functions.
 ObjectDescriptionA1A2B1B2C1
oClockProvides a programmable logic clockxxx
oCountDown(O)Counts down to 0.xxx
oCounterProvides counting functions.xxxxx
oTimerControls the PIC's Timer1 Hardware Module.xxxxx
oOperatingSystemProvides a 1 Hertz and 60 Hertz clock.xxxxx
Back to top of pageVersion History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


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