oNavCon Object

Back to top of page Description:
 The oNavCon Object provides differential steering calculations that can be used to control two motor objects.  It takes a speed and turn values and produces two output values, one for each of the two motors, in a dual drive robotic base. This object can be used in conjunction with an oTracker and two oServoSP or oDCMotor objects to implement a perfect line tracker that works entirely within a Virtual Circuit.
 The following table lists the size and availability of the oNavCon Object.
 ObjectSizeDescriptionA1A2B1B2C1
oNavCon7 BytesAn Object that provides differential steering calculations.xxx
oNavConC8 BytesAn Object that provides differential steering calculations.xxx
oNavConI7 BytesAn Object that provides differential steering calculations.xxx
oNavConIC8 BytesAn Object that provides differential steering calculations.xxx
Back to top of page Operation:
 The oNavCon Object takes the value of the Object pointed to by the Input1 property (which is considered to be the speed value) and both add and subtract the value of the Object pointed to by the Input2 property (Which  is considered to be the turn value). The resulting two numbers (considered to be the two motor's speed values) are then stored in the Objects pointed to by the Output1 and Output2 properties where Output1 = (Input1 + Input2) and Output2 = (Input1 - Input2).  

If the Input2 value is 0, then both of the outputs will be set to the Input1 value.  For example, if the Input1 value (speed) is 97 and the Input2 value (turn) is 0, then both of the Output values (right speed and left speed) will be set to 97. 

If the Input1 value is 0, then the Output values will be set to the positive and negative forms of the Input2 value.  For example, if the Input2 value (turn) is 32 and the Input1 value (speed) is 0 then the Output1 value (right) will be 32 and the Output2 value (left) will be -32.

If both the Input1 and Input2 values are 0 then both the Output values will be set to 0.

A Limit property is provided for the cases where either of the output Object's value properties cannot exceed +127/-128 (8-Bits signed). The oDCMotor Object is an Object which may require use of the Limit property. Setting the Limit property to cvTrue (1) prevents either of the Output values from exceeding the 8-Bit limitation.  For example: if the Input1 value (speed) is 120 and the Input2 value (turn) is 10 then the Output1 value (right) will be 130 and the Output2 values (left) will be 110.  The output Object will use the 8th bit of the number as a sign bit which results in the value of 130 being seen erroneously as a negative 126. By setting the Limit property to cvTrue, the value of 130 is limited to +127 which will be seen correctly by the output Object. 

A Adjust property is provided to adjust the turn value to compensate for mechanical differences in the drive motors.  This value is added to the Input2 value (turn) before the calculations are performed and allows an Input2 value of 0 to drive the motors at different speeds.

In normal operation, the two calculations are performed once each 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.

Back to top of page Property Options:
 The oNavCon Object has 4 variants which are selected with 2 property options: I and C.
  • I specifies that the Input2 property is replaced with a Value property.
  • C specifies that a clocked version of the object is used.
 Continuous
operation
Clocked
operation
Pointers for inputs and output:oNavConoNavConC
Signed 8-Bit Value on input 2:oNavConIoNavConIC
Back to top of page Properties:

The following table lists the properties of the oNavCon Object:

Property

Description

Operate
A value that selects whether or not the values are updated.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
The following table lists the values of the Operate Property:
OperateConstantDescription
0cvFalseThe data is not updated.
1cvTrueThe data is updated.
Value
An Optional signed 8-Bit value that optionally replaces the Input2 property which is used as the turn value in the calculations.
Object Class: oChar Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Availability: oNavConI, oNavConIC
Input1
A pointer to an Object whose value is to be used as the speed in the calculation.
Object Class: oValuePtrI Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Input2
A pointer to an Object whose value is to be used as the turn in the calculation.
Object Class: oValuePtrI Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Availability: oNavCon, oNavConC
Output1
A pointer to an Object whose value will be updated with the result of the (Input1+Input2) calculation.
Object Class: oValuePtrO Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Output2
A pointer to an Object whose value will be updated with the result of the (Input1-Input2) calculation.
Object Class: oValuePtrO Value Range: Any oValue Object
Data Type: Pointer Default Value: Null
Adjust
A value that specifies an adjustment to the turn value.
Object Class: oAdjust Value Range: -128 to +127
Data Type: Numeric Default Value: 0
This value is added to the Input2 value (turn) before the calculations are performed.
Limit
A value the selects if the outputs are limited to within -128 to +127.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
ValueConstantDescription
0cvFalseDo not limit the output values.
1cvTrueLimit the output values to within -128 to +127.
Process
Clock
See Clocked Objects for detail
Object Class: oClockedOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
Availability: oNavConC, oNavConIC
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, a Virtual Circuit is created that uses the oNavCon Object to take two inputs from the X and Y potentiometers of a joystick which are read with two oA2DX Objects and calculate the speed for two wheels so that the robot will travel in the direction that the joystick is pressed.
' Controlling two two DCMotor  
' Objects with two oA2Dx Objects.

Dim Speed As New oA2DX
Dim Turn As New oA2DX
Dim Nav As New oNavCon
Dim Right As New oDCMotor
Dim Left As New oDCMotor

Sub Main()
  Speed.IOLine = 3
  Speed.Operate = cvTrue
  Turn.IOLine = 4
  Turn.Operate = cvTrue
  Right.IOLineP = 17
  Right.IOLineD = 27
  Right.IOLineB = 25
  Right.Operate = cvTrue
  Left.IOLineP = 18
  Left.IOLineD = 26
  Left.IOLineB = 24
  Left.Operate = cvTrue
  Nav.Input1.Link(Speed)
  Nav.Input2.Link(Turn)
  Nav.Output1.Link(Right)
  Nav.Output2.Link(Left)
  Nav.Limit = cvTrue
  Nav.Operate = 1
End Sub

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oDCMotorControls a DC motor that is driven by an LMD18200 H-Bridge driver.xxx
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.