oA2DX Object

Main Index
Object List
Back to top of page Description:
 

A Hardware Object that measures the level of a voltage on an input line with a signed 8-Bit resolution.

This object can be used to detect when an analog value has exceeded a threshold because the voltage level that is used as the dividing point between a positive result and a negative result can be adjusted. 

The following table lists the size and availability of the oA2DX Object.
 ObjectSizeDescriptionA1A2B1B2C1
oA2DX5 ByteA Hardware Object that measures the level of a voltage.xxx
Back to top of page 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 which generates a digital value ranging from 0 to 255 representing the voltage as a percentage of the reference voltage. This digital value is then split in two by subtracting 128.  This results in positive numbers from 0 to 127 representing voltage levels which are greater than half the reference voltage, and negative numbers from -1 down to -128 representing voltage levels which are less than half the reference voltage.

After the digital value is then split, the value of the Adjust property is added, resulting in shifting where a Level of 0 shows up on the analog voltage range.  Because adding the Adjust property creates a final range of -256 to +255, the final value is adjusted so that values below -128 are set to -128 and any values above +127 are set to +127.  For example,  If the Adjust property is set to 10 and 5 volts is presented to the I/O line, then the resulting value would be +137 which would set the Level property to +127.

When created, the oA2DX Object also creates an instance of the oA2D object which it uses to do the actual Analog-to-Digital conversion.  Most properties of the oA2D instance can be adjusted and will affect the oA2DX Object's operation such as Converter.ExtVRef which is used to specify an analog reference voltage.  See the oA2D Help for more detail on how analog signals are converted to values.

Back to top of page Properties:

The following table lists the properties of the oA2DX Object:

Property

Description

Level
A value that indicates the adjusted analog level.
Object Class: oPower Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Below
A value that indicates if the Level property is below the center value of 0..
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
IOLine
A value that specifies which I/O Line is used to measure the analog signal.
Object Class: oIOLineA Value Range: 0 - 7
Data Type: Numeric Default Value: 0
ValueDescription
0No analog input is specified.
1 - 4Using any of these I/O Lines will set all I/O Lines 1 - 4 as analog inputs.
1 - 7Using any of these I/O Lines will set all I/O Lines 1 - 7 as analog inputs.
Adjust
A value that specifies an adjustment to the analog level to calibrate the center position.
Object Class: oAdjust Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Availability: This property was added in firmware version B.2
Operate
A value that selects whether or not the measurement is performed.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
This value is used to activate the oA2DX Object. When set to 1 the oA2DX Object continuously performs an analog-to-digital conversion and update its Level property with the result. When the Operate property is cleared to 0 the oA2DX Object enters a dormant state, thus leaving the Level property at the value of the last conversion.
OperateConstantDescription
0cvOff

The measurement is not performed.

1cvOn

The measurement is performed.

Converter
The PIC Hardware object used to convert the analog signal.
Object Class: oA2D Value Range: (See oA2D object)
Data Type: Numeric Default Value: 0
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 Example:
 In the following example the oA2DX Object is used.
Visual Basic SyntaxC and Java Syntax
' This program reads an 
' oA2DX Object and positions
' a servo based on it.

Dim A As New oA2DX 
Dim S As New oServoX

Sub Main()
  A.IOLine = 1
  A.Operate = cvTrue
  S.IOLine = 31
  S.Operate = cvTrue
  Do
    S.Position = A.Level
  Loop
End Sub
' This program reads an 
' oA2DX Object and positions
' a servo based on it.

oA2DX A = New oA2DX;
oServoX S = New oServoX;

Void Main(Void){
  A.IOLine = 1;
  A.Operate = cvTrue;
  S.IOLine = 31;
  S.Operate = cvTrue;
  Do{
    S.Position = A.Level;
  }
}
Basic Syntax 
' This program reads an 
' oA2DX Object and positions
' a servo based on it.

A As oA2DX(1,,cvOn)
S As oServoX(31,,,,,,,cvOn)

Do
  S.Position = A.Level
Loop
Back to top of pageRelated Items:
 The following table lists objects that use the oA2DX Object.
 ObjectDescriptionA1A2B1B2C1
oCDSReads a CdS Cell.xxx
oIRRangeReads a Sharp GP2D12 IR ranging module.xxx
oKnobXReads the position of a Knob with a signed value.x
 The following table lists other objects with related functions.
 ObjectDescriptionA1A2B1B2C1
oA2DControls the PIC's A2D Hardware Module.xxxxx
oA2D10Measures the level of the voltage on an input line with an 10-bit result.xx
oA2D8Measures the level of the voltage on an input line with an 8-bit result.xxxxx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.
Firmware Ver B2: The Adjust property was added.

Bugs: No known bugs.


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