Virtual Circuit Application Note #2
Creating a Virtual Circuit for Servo Devices.
This Virtual Circuit Application Note demonstrates how to use various Objects to provide the logic and I/O necessary to control a DC motor driver in a servomechanism style.
Introduction: A Servomechanism is a device that is capable of positioning it's mechanical actuator to a specified position.

The current mechanical position of the servomechanism's actuator is read by its control circuit and compared to a desired position provided by an external input. If the current position is different than the desired position, then the control circuit determines which direction the actuator need to be moved and activates the actuator's mechanical movement apparatus to move the actuator in the direction of the desired position. This process is repeated continuously until the current position matches the desired position, at which time, the actuator's mechanical movement apparatus is stopped. This process continues to operate continuously, checking for the need to move the actuator again.

In this application note, we will construct a Virtual Circuit for an OOPic that provides the basic framework of a control circuit for a servomechanism.

Theory of Operation: For this servo control circuit, an Analog-To-Digital converter will read a voltage from a potentiometer that is physically connected to the actuator and will be used to provide the external input of the actuator's current position. A Pulse-Width-Modulated signal will be generated to drive the DC Motor at a specified speed and a single TTL signal will be used to select the direction that it will travel. These signals will be used to drive a DC motor which will be used as the actuator's mechanical movement apparatus.

Six different Object Classes will be used to create the Servo Device's Virtual Circuit.

The following table lists the six Object Classes:

 
Icon Object Description
oA2D A Hardware Object that provides a numerical measurement of a voltage.
oDIO1 A Hardware Object that provides a 1 bit digital I/O.
oPWM A Hardware Object that provides a Pulse-Width-Modulated output.
oMath A Processing Object that provides mathematical functions.
oGate A Processing Object that provides logic-gate functions.
oByte A Variable Object that maintains an 8-bit (1-byte) variable.

The 3 Hardware Objects, oA2D, oDIO1 and oPWM, will provide the I/O that will physically connect to our servo actuator's hardware. Each of these 3 Objects have an IOLine property that specifies which I/O Line on the OOPic to use.

The 2 Processing Object, oMath and oGate, will provide the control logic.

The oByte Object will be used to specify the desired location.

Construction: The Link method will be used to progmatically assembled these Objects into a Virtual Circuit.

The following diagram shows the Virtual Circuit's schematic:

 

The following listing shows the program to assemble the Virtual Circuit.

 
Dim MotorLoc As New oA2D
Dim MDirection As New oDio1
Dim MSpeed As New oPWM
Dim PositionComp As New oMath
Dim Buffer1 As New oGate
Dim Buffer2 As New oGate
Dim TargetLoc as New oByte
   
Sub Main()
  Call SETUPVC
  ' Insert your code here
End Sub
   
Sub SETUPVC( )
  MSPeed.IOLine = 17
  MDirection.IOLine = 31
  MDirection.Direction = cvOutput
  MotorLoc.IOLine = 1
  MotorLoc.Operate = cvTrue
  PositionComp.Input1.Link(MotorLoc.Value)
  PositionComp.Input2.Link(TargetLoc.Value)
  PositionComp.Mode = cvSubtract
  PositionComp.Operate = cvTrue
  Buffer1.Input1.Link(PositionComp.Negative)
  Buffer1.Output.Link(MDirection.Value)
  Buffer1.Operate = cvTrue
  Buffer2.Input1.Link(PositionComp.NonZero)
  Buffer2.Output.Link(MSpeed.Operate)
  Buffer2.Operate = cvTrue
End Sub
Enhancements: Several other Object are available within the OOPic that allow enhancements to be made.

Home   Send mail and comments to: Savage Innovations.