oA2DX Object
An Object that detects when an analog value has exceeded a threshold.
Description:
 

A Hardware Object that takes an analog voltage presented to one of the OOPic's I/O lines and converts it to a signed digital value. This Object is an expanded oA2D Object and has the additional functionality of shifting the resulting value so that part of the result is a negative number.  Whether the value is negative or positive can be monitored and used to signal that a threshold has been passed.

Operation:
  An oA2DX Object takes the voltage present on the I/O Line specified by the IOLine property and compares it to a reference voltage. It then generates a digital value ranging from 0 to 255 which represents this voltage as a  percentage of the reference voltage. This digital value is then split in two by subtracting 128.  This results in voltage levels which are greater than half the reference voltage being represented as a positive number from 0 to 127, and voltage levels which are less than half the reference voltage being represented as a negative number from -1 down to -128.  After the digital value is split, the value specified by the Center property is added, resulting in shifting where 0 shows up on the analog voltage range, and the final value is stored into the Value property.  

Because the Center property is used to shift where 0 shows up on the analog voltage range, the final range of the Value property is 256 steps within the range of -256 to +255. A Limit property is provided for the cases where this value needs to stay within the -128/+127 (8-Bits signed) range.  When the Limit property is set to 1, values below -128 are set to -128 and any values above +127 are set to +127.  For example,  If the Center property is set to 10 and 5 volts is presented to the I/O line, then the resulting value would be +137.  Setting the Limit Property to 1, would force that value back down to +127.

The ExtVRef property of the OOPic Object determines the analog reference voltage which is selectable to either +5 volts or the voltage level supplied on the OOPic’s I/O line 4. If the ExtVRef property is set to 0, then +5 volts is used as the reference voltage. If the ExtVRef property is set to 1, then the voltage applied to the OOPic’s I/O Line 4 is used as the maximum voltage in the voltage conversion range. 
Caution: The maximum voltage allowed on I/O Line 4 is +14 Volts DC.

Each dimensioned instance of an oA2DX Object shares the analog-to-digital converter (A/D) module which converts the analog input signals to a corresponding digital number with all of the other Analog to Digital Objects. The A/D module has seven analog inputs available on the OOPic’s I/O lines 1 - 7 which are multiplexed into a single sample and hold register. The sample and hold register is the input into the A/D module which generates the result via successive approximation.

The analog-to-digital conversion process takes approximately 14µs. Each dimensioned instance of an Analog to Digital Object with an Operate property set to 1 will in turn request an analog-to-digital conversion be done on the voltage present on the I/O line specified in the Analog to Digital Object’s IOLine property. When the conversion is completed the resulting value will be placed in the Objects Value property and the next Analog to Digital Object instance will follow the same until all active Analog to Digital Object instances have been addressed. After the last Analog to Digital Object instance has been addressed the process begins again with the first Analog to Digital Object instance. With all 7 possible Analog to Digital Object instances dimensioned and all 7 Operate properties set to 1 the entire conversion process takes 98µs.

Remarks:
When any Analog to Digital Object is in use, I/O lines 1, 2, 3, and 4 are set to read an analog value, and any Digital-I/O Object using these I/O lines will read 0. If any Analog to Digital Object is set to use I/O Lines 5, 6, or 7, then all I/O lines 1 to 7 are set to read analog values.
Storage size & Availability:
 

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

ObjectSizeVersion
oA2DX 5 Bytes B.1.0
Properties:
 

The following table lists the Properties of the oA2DX Object:

PropertyDescription
Address

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

Data-Type: Address, Read-Only

Data-Range: 0 - 127

Center

A value that is used to adjust the center point of the value property.  

Data-Type: Byte

Data-Range: -128 to 127

IOLine

A value that specifies which one of seven analog enabled Input Lines on the OOPic to use. 

Data-Type: Nibble

Data-Range: 0 - 7

Value Constant Description
0   No analog input is specified.
1 - 4   Using any of these I/O Lines will set all I/O Lines 1 - 4 as analog inputs.
1 - 7   Using any of these I/O Lines will set all I/O Lines 1 - 7 as analog inputs.
Limit

A value that specifies if the Value property is limited to +/- 127

Data-Type: Bit

Data-Range: 0 - 1

Negative

A value that specifies if the Value property is a negative number.

Data-Type: Bit, Flag

Data-Range: 0 - 1

NonZero

A value that specifies when the analog voltage is at 0 volts.

Data-Type: Nibble, Flag

Data-Range: 0 - 1

Operate

A value that is used to activate the oA2DX Object. When set to 1 the oA2DX Object continuously performs an analog-to-digital conversion and update its Value property with the result. When the Operate property is cleared to 0 the oA2DX Object enters a dormant state, thus leaving the Value property at the value of the last conversion.

Data-Type: Bit, Flag

Data-Range: 0 - 1

Unsigned

The Unsigned property modifies the operation so that the entire percentage is represented by a positive number 0 to 255.  

Data-Type: Bit

Data-Range: 0 - 1

Value Constant Description
0 cvFalse The Value is shifted down by 128.
1 cvTrue The Value is not shifted down by 128.
Value

The adjusted Analog-to-Digital value.

Data-Type: Word, Default

Data-Range: -256 to +255

Example:
  In the following example the oA2DX Object is used.
' This program reads an oA2DX Object and 
' positions a servo based on that value.

Dim A as new oa2dX 
Dim S as new oServoX
Dim B as new oBus

Sub Main()
  S.IOLine = 31
  S.Operate = cvTrue
  A.IOLine = 1
  A.Limit = cvTrue
  A.Center = 0
  A.Operate = cvTrue
  B.Input.Link(A)
  B.Output.Link(S)
  B.Operate = 1
End Sub
See Also:
 

oA2D - An Object that provides a numerical measurement of a voltage.
oA2D10 - An Object that converts a voltage to a 10-Bit number.