oCompare Object

Back to top of page Description:
 A Processing Object that takes a value from one object and compares it to the values of up to two other objects. 
 The following table lists the size and availability of the oCompare Object.
 ObjectSizeDescriptionA1A2B1B2C1
oCompare4 BytesCompares an Object's Value to set points.xxx
oCompare04 BytesCompares an Object's Value to 0.xxx
oCompare0C6 BytesCompares an Object's Value to 0.xxx
oCompare25 BytesCompares an Object's Value to set points.xxx
oCompare2C7 BytesCompares an Object's Value to set points.xxx
oCompareC6 BytesCompares an Object's Value to set points.xxx
Back to top of page Operation:
 The oCompare Object takes the value of the Object that the Input property points to and performs 2 comparisons on it. These comparisons result in one of 3 properties (Above, Between and Below) to be set while the remaining two are cleared to 0.  The normal operation of the oCompare Object is to make these comparisons once every Object List Loop

If the property option "C" is used, then the operation is modified so that this function only occurs once each time an oLogic Object transitions.

In normal operation, the input value is first compared to the value of the Object pointed to by the ReferenceIn property plus the value of the fuzziness property.  If the Input value is greater than the ReferenceIn value plus the fuzziness value, then the Above property is set to 1.  If the Input value is equal to or less than the ReferenceIn plus fuzziness value, then a second comparison is made where the Input value is compared against the ReferenceIn1 value minus the fuzziness value. If the input value is less than the ReferenceIn value minus the fuzziness value, then the Below property is set to 1; otherwise, the Between property is set to 1.

Property options are also available that change the number of references with which the compare is made .

If the "0" (for zero references) property option is specified, then the oCompare Object operates as it does normally, except that the ReferenceIn value is replaced with 0.

If the "2" (for two references) property option is specified, then the oCompare Object operates as it does normally except that in the second comparison, the ReferenceIn1 property is used with a ReferenceIn2 property.

Back to top of page Property Options:
 The oCompare Object has 6 variants which are selected with 3 property options: 0, 2, and C.  
  • 0 (zero) specifies that the ReferenceIn property is replaced with a value of 0.
  • 2 specifies that the ReferenceIn2 property is added and a ReferenceIn1 property replaces ReferenceIn..
  • C specifies that a clocked version of the object is used.
 Continuous
operation
Clocked
operation
Compare is made with 1 reference:oCompareoCompareC
Compare is made with 0:oCompare0oCompare0C
Compare is made with 2 references:oCompare2oCompare2C
Back to top of page Properties:
 

The following table lists the properties of the oCompare Object:

Property

Description

Operate
A value that selects whether or not the data is updated.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe compare function is not performed.
1cvOnThe compare function is performed.
Above
A value that indicates the value of the object pointed to by Input, is higher than the value of the object pointed to by ReferenceIn plus the value specified by the Fuzziness property.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Below
A value that indicates the value of the object pointed to by Input is lower than the values of the objects pointed to by the References minus the value specified by the Fuzziness property.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Between
A value that indicates the value of the Object pointed to by Input is lower than the value of the Object pointed to by Reference 1 minus the value specified by the Fuzziness property and is higher than the value of the Object pointed to by Reference2 plus the value specified by the Fuzziness property.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
In the case of oCompare0 and oCompare0C, the between property indicates that the value of the Object pointed to by Input is with the values of -Fuzziness and +Fuzziness.
Fuzziness
A value that specifies a dead area around the references in which the input value must pass before the Above or Below properties are set.
Object Class: oVar4 Value Range: 0 - 15
Data Type: Numeric Default Value: 0
Input
A pointer to an oValue Object whose value is compared to the value of the objects pointed to by ReferenceIn1 and ReferenceIn2.
Object Class: oValuePtrI Value Range: 0 - 127
Data Type: Pointer Default Value: Null
ReferenceIn
ReferenceIn1
ReferenceIn2
A pointer to an oValue Object whose value is compared to the value of the object pointed to by Input.
Object Class: oValuePtrI Value Range: 0 - 127
Data Type: Pointer Default Value: Null
Availability: oCompare oCompareC
Process
Clock
See Clocked Objects for detail
Object Class: oClockedOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Availability: oCompareC,  oCompare0C,  oCompare2C
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 example the oCompare0 Object is used
Visual Basic Syntax C and Java Syntax
'This program uses the oCompare0 
'Object to detect when a compass
'is heading north. When it is,
'turn on a LED on I/O line 15

Dim X As New oCompassVX
Dim D As New oDIO1
Dim W As New oWire
Dim C As New oCompare0

Sub Main()
  X.IOGroup = 3
  X.Operate = 1
  C.Input.Link(X.Heading)
  C.Fuzziness = 15
  C.Operate = 1
  D.IOLine = 15
  D.Direction = cvOutput
  W.Input.Link(C.Between)
  W.Output.Link(D.State)
  W.Operate = 1
End Sub
// This program uses the oCompare0
// Object is used to detect when a
// compass is heading north and when
// it is, turn on a LED on I/O line 15

oCompassVX X = New oCompassVX;
oCompare0 C = New oCompare0;
oDIO1 D = New oDIO1;
oWire W = New oWire;

Void Main(Void){
  X.IOGroup = 3;
  X.Operate = 1;
  C.Input.Link(X);
  C.Fuzziness = 15;
  C.Operate = 1;
  D.IOLine = 15;
  D.Direction = cvOutput;
  W.Input.Link(C.Between);
  W.Output.Link(D);
  W.Operate = 1;
}
Basic Syntax
'This program uses the oCompare0 
'Object to detect when a compass
'is heading north. When it is,
'turn on a LED on I/O line 15

X Var oCompassVX(3,1)
D Var oDIO1(8,cvOutput)
W Var oWire(C.Between,,D.State,,cvOn)
C Var oCompare0(X.Heading,15,1)

Back to top of page Related Items:

 The following table lists objects that use the oCompare Object.
 ObjectDescriptionA1A2B1B2C1
oCompareCompares an Object's Value to set points.xxx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oBusFAn Object that can indicate when an Object's value has changed.x
oMathProvides mathematical functions.xxxxx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


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