oCounter Object
An Object that provides counting functions.
Description:
 

A Processing Object that performs counting operations by increasing or decreasing another Object's Value property for each "Clock-Tick"

Operation:
 

The oCounter Object will increment or decrement the Value of the Object to which the Output property links 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 or 0, each cycle of the Flag property 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 or 1, the Flags 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. 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.

Storage size & Availability:
 

The following table lists the size and availability of the oCounter Object:

ObjectSizeVersion
oCounter5 BytesA.1.0 and greater
Properties:
 

The following table lists the Properties of the oCounter Object:

PropertyDescription
Address

Returns a pointer to the address of the oCounter Object instance.

Data-Type: Address, Read-Only

Data-Range: 0 - 127

ClockIn1

A pointer to an Object's Flag property 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.

Data-Type: Flag-Pointer

Data-Range: Any Object's Flag property

ClockIn2

A pointer to an Object's Flag property whose value is used as the ClockIn1's complement when the Mode property is set to cvPhase.

Data-Type: Flag-Pointer

Data-Range: Any Object's Flag property

Direction

Specifies the direction of the count.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table list the values of the Direction Property.
DirectionModeConstantDescription
00cvPositive

Count positively (Increment)

01cvPositive

Output was incremented

10cvNegative

Count negatively (Decrement)

11cvNegative

Output was decremented

Input

A pointer to an Object whose Value property is used as a count limit value.

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.

Data-Type: Number-Pointer

Data-Range: Any Object with a Value property

Mode

A value that specifies how the counter evaluates the ClockIn1 and ClockIn2 properties.

Data-Type: Nibble

Data-Range: 0 - 1

The following table list the values of the Mode Property:
ModeConstantDescription
0cvCount

Each cycle of the Flag property 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 Flags 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.

Operate

A value that specifies whether or not the count is updated.

Data-Type: Bit, Flag, Default

Data-Range: 0 - 1

The following table list the values of the Operate Property.
OperateConstantDescription
0cvFalse

The count is not updated.

1cvTrue

The count is updated.

Output

A pointer to an Object whose &Value property is incremented or decremented for each "Clock-Tick".

Data-Type: Number-Pointer

Data-Range: Any Object with a Value property

Tick

A value that specifies how the oCounter Object values each "Clock-Tick".

If the Tick property is set to 1, the Value property of the Output Object is cleared.

If the Tick property is cleared to 0, the Value property of the Output Object is incremented or decremented by a value of 1.

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.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table list the values of the Tick Property:
TickConstantDescription
0 

Change the Output Object by 1.

1 

Set the Output Object to 0.

Example:
 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
See Also:
 

oQencode - An Object that reads a Quadrant Encoder.
oCountDown - An Object that counts down to 0.