oCounter Object

Back to top of page Description:
 A Processing Object that performs counting operations by increasing or decreasing another Object's Value for each "Clock-Tick"
 The following table lists the size and availability of the oCounter Object.
 ObjectSizeDescriptionA1A2B1B2C1
oCounter5 BytesProvides counting functions.xxxxx
Back to top of page Operation:
 

The oCounter Object will increment or decrement the value of the object that the output property points to for each "Clock-Tick".

A Mode property specifies how the oCounter Object determines when a "Clock-Tick" has occurred.

If the Mode property is set to cvCount (0), each cycle of the oLogic Object pointed to by the ClockIn1 property is considered to be a "Clock-Tick" and the value of the Output Object is incremented or decremented in the direction specified by the Direction Property.

If the Mode property is set to cvPhase (1), the oLogic Object pointed to by the ClockIn1 and Clockin2 properties are Quadrant-Encoded and the value of the Output Object is incremented or decremented in the direction specified by Quadrant change. The Direction Property is then updated to reflect the direction of the change.

Each time a "Clock-Tick" increments the Output object's value, that value is tested against the value of the Object pointed to by the Input property. If it is greater, the value of the Output object is cleared to 0. Likewise, each time a "Clock-Tick" decrements the Output object's value, it is tested against 0. If it is lower, the value of the Output object is set to the value of the Object pointed to by the Input property.

Back to top of page Properties:

The following table lists the properties of the oCounter Object:

Property

Description

Operate
A value that selects whether or not the count is updated.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOff

The count is not updated.

1cvOn

The count is updated.

ClockIn1
A pointer to an oLogic Object whose value is used as a clocking signal to determine when to increment or decrement the value of the object pointed to by the Output property.
Object Class: oLogicPtrI Value Range: Any oLogic Object
Data Type: Pointer Default Value: Null
ClockIn2
A pointer to an oLogic Object whose value is used as the ClockIn1's complement when the Mode property is set to cvPhase.
Object Class: oLogicPtrI Value Range: Any oLogic Object
Data Type: Pointer Default Value: Null
Input
A pointer to an object whose value is used as a count limit value.
Object Class: oValuePtrI Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Each time a "Clock-Tick" Increments the Output Object's Value, the new Value is tested against the Input Object's Value. If it is greater, then the Value of the Output Object is cleared to 0.
Each time a "Clock-Tick" decrements the Output Object's Value, the new Value is tested against 0. If it is lower, then the Value of the Output Object is set to the Input Object's Value.
Output
A pointer to an object whose value is incremented or decremented for each "Clock-Tick".
Object Class: oValuePtrO Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Mode
A value that selects how the counter evaluates the ClockIn1 and ClockIn2 properties.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
ModeConstantDescription
0cvCount

Each cycle of the oLogic Object pointed to by the ClockIn1 property is considered to be a "Clock-Tick" and the Value of the Output Object is incremented or decremented in the direction specified by the Direction Property.

1cvPhase

If the Mode property is set to cvPhase or 1, the oLogic Objects pointed to by the ClockIn1 and Clockin2 properties are Quadrant-Encoded and the Value of the Output Object is incremented or decremented in the direction specified by Quadrant change. The Direction Property is then updated to reflect the direction of the change.

Tick
A value that selects how the oCounter object values each Clock-Tick.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
The Tick property is similar to a clear or reset function with the difference being that the Tick property is only evaluated when a "Clock-Tick" has occurred.
TickDescription
0

The Value of the Output object is incremented or decremented by a value of 1.

1

The Value of the Output object is cleared.

Direction
A value that selects the direction of the count.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
DirectionModeConstantDescription
00cvPositive

Count positively (Increment)

01cvPositive

Output was incremented

10cvNegative

Count negatively (Decrement)

11cvNegative

Output was decremented

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 page Examples:
 In the following examples, the oCounter Object is used
'This program creates a Virtual 
'Circuit that will increase the 
'value of a oDio8 60 times per 
'second.

Dim A As New oCounter
Dim B As New oDIO8

Sub Main()
  A.Output.Link(B)
  A.ClockIn1.Link(ooPIC.Hz60)
  A.Operate = 1
  B.IOGroup = 3
  B.Direction = cvOutput
End Sub
'This program creates a 
'Virtual Circuit that will 
'read a Quandrant Encoder 
'and will limit the count 
'value to 10.

Dim A As New oCounter
Dim B As New oDIO8
Dim G As New oByte
Dim Q1 As New oDIO1
Dim Q2 As New oDIO1

Sub Main()
  ooPIC.PullUp = cvTrue
  A.Output.Link(B)
  A.ClockIn1.Link(Q1)
  A.ClockIn2.Link(Q2)
  A.Mode = 1
  A.Input.Link(G)
  A.Operate = 1  
  G.Value = 10
  Q1.IOLine = 8
  Q1.Direction = cvInput
  Q2.IOLine = 10
  Q2.Direction = cvInput
  B.IOGroup = 3
  B.Direction = cvOutput
End Sub

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oCountDownAn Object that counts down to 0.xxx
Back to top of page Version History and Bug List:
 Firmware Ver A1: Introduced.

Bugs: No known bugs.


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