oDCMotorWZ Object

Back to top of page Description:
 An oDCMotorWZ Object is a Hardware Object that controls the direction, speed, and braking of a DC Motor.  It is capable of driving a DC Motor at multiple speeds, in forward or reverse plus free spinning, active braking, and friction braking modes. 

The oDCMotorWZ Object uses two digital I/O lines to communicate with two motor drivers which in turn handle the voltage and current requirements of the DC Motor.  The H-Bridge that the oDCMotorWZ Object is designed to work with has one direction input and one PWM input.  The Wirz 203 Motor Driver H-Bridge is configured in this way.  An optional I/O line controls a mechanical braking device.

How fast the motor turns and in which direction it turns is controlled by a single value with a range of  -128 to +127.  When this value is 0, the motor is at free-spinning rest.  When the value is a positive number from 1 to 127, the motor turns forward at the speed indicated by the value.  The higher the value, the faster the motor turns.  When the value is a negative number from -1 to -128, the motor turns backwards at the speed indicated by the value.  The lower the number, the faster the motor turns in reverse.

The physical direction that the motor will turn can be configured to:  forward turns clockwise and reverse turns counter-clockwise  or  forward turns counter-clockwise and reverse turns clockwise.

When brakes are activated, the speed value is ignored so that the motor can be stopped. The method used to stop the motor can be either active braking or friction braking.  For friction braking, an output is provided to activate a mechanical braking device.

 The following table lists the size and availability of the oDCMotorWZ Object.
 ObjectSizeDescriptionA1A2B1B2C1
oDCMotorWZ5 BytesControls a DC motor that is driven by a Mondo-Tronics H-Bridge driver.xx
Back to top of page Operation:
 The oDCMotorWZ Object monitors the Speed and the Brake properties, and based on their numeric values controls the power, polarity, and braking properties of a oHBridgeH object which in turn controls two drivers connected to the motor.  

When the oDCMotorWZ object is initialized, it configures the oHBridgeH object to use the Wirz 203 Motor Driver H-Bridge by setting the oHBridgeH object's properties.  It then sets the oDCMotorWZ object's properties as specified in the arguments to the Init method.

The Speed property controls the speed of the motor.  When operating, a 0 in the Speed property will cause the motor to be at a full stop. If the Speed property is greater than 0, then the DC Motor will go forward at a speed specified by the Speed property. The higher the number (up to 127), the faster the motor will turn. If the Speed property is less than 0, then the DC Motor will go backwards at a speed specified by the Speed property. The lower the number (down to negative 128), the faster the motor will turn in reverse.

The actual direction that the DC Motor spins when going in the "forward" direction can be reversed by setting the Invert property.

When the Brake property is set to 1, the I/O line specified by IOLineB is activated and the two drivers are set to the same voltage rail which causes the motor to generate power back into itself, effectively driving itself back the other way which causes it to come to an abrupt stop without the need for mechanical braking.

The Operate property specifies if the motor is on or off.  When the Operate property is set to 1 the two drivers control the motor based on the Speed and Brake properties. When the Operate property is set to 0 the two drivers shut off and the motor stops.

The HBridge property is an instance of the oHBridgeH object which is created when the oDCMotorWZ object is.  The oDCMotorWZ object configures the oHBridgeH object in such a way that it will provide the proper I/O control for the two drivers and the physical brake.  Attributes of the motor's operation can be adjusted by directly manipulating the oHBridgeH object. Note that doing so may change the way the motor behaves to something different than the way described in this document.  (see oHBridgeH object for more detail)

The oDCMotorWZ object is functionally identical to the oDCMotor object.

The maximum number of oDCMotor objects that can be dimensioned in a single application program is 2, limited only be the number of PWM channels available in the ooPIC.

Back to top of page Properties:
 

The following table lists the properties of the oDCMotorWZ Object:

Property

Description

Speed
A value that specifies how fast and in what direction the motor turns.
Object Class: oPower Value Range:-128 to +127
Data Type: Numeric Default Value: 0
When operating, a 0 in the Speed property will cause the motor to be at a full stop. When the Speed property is greater than 0, the motor will go forward at a speed specified by the magnitude of the Speed property. The higher the number (up to 127), the faster the motor will turn. If the Speed property is less than 0, then the motor to go backwards at a speed specified by the magnitude of the Speed property. The lower the number (down to negative 128), the faster the motor will turn in reverse.
SpeedDescription
-128Full Reverse
-96 
-64Half Reverse
-32 
0Stopped
32 
64Half Forward
96 
127Full Forward
The Speed property is an oPower object which has properties and methods such as SetFullForward and Stop that can also be used to control the speed of the motor.  Examples: 

 

IOLineP
A value that specifies which PWM I/O Line is connected to the motor driver's first drive line.
Object Class: oIOLineP Value Range: 0 - 1
Data Type: Numeric Default Value: 0
IOLinePDescription
0

The PWM signal is outputted on I/O Line 18. 
18 can be assigned to IOLineP in place of 0 but it will read back as 0.

1

The PWM signal is outputted on I/O Line 17. 
17 can be assigned to IOLineP in place of 1 but it will read back as 1.

IOLineD
A value that specifies which I/O Line is connected to the motor driver's second drive line.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
IOLineB
A value that specifies which I/O Line is connected to the braking system's control line.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
Invert
A value that selects if the physical direction the motor turns is inverted.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
InvertDescription
0Motor turns in the direction specified by the Speed property.
1Motor turns in the direction opposite the one specified by the Speed property.
Brake
A value that selects if the brake is on or off.
Object Class: oSelect0to1L Value Range: 0 - 1
Data Type: Numeric Default Value: 0
When the Brake property is set to 1, the I/O line specified by the IOLineB property is set to 5 volts and IOLineP is set to 5 Volts. When the Wirz 203 Motor Driver H-Bridge is being used for the motor's brakes, setting the Brake property will cause the motor to generate power back into itself, effectively driving the it back the other way which causes it to come to an abrupt stop without the need for mechanical braking.
BrakeBrake Output
0Brakes are off.
1Brakes are on.
Operate
A value that selects if the motor is on or off.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe motor is off.
1cvOnThe motor is on.
Direction
A value that indicates the direction that the motor is turning.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
HBridge
The I/O function object used to control the Motor Driver.
Object Class: oHBridgeH Value Range: 
Data Type: Numeric Default Value: 0
When the oDCMotorWZ object is created, it configures its oHBridgeH object to use Wirz 203 Motor Driver H-Bridge  by setting its properties to:
  • HBridge.PWM.Period = 254

The HBridge.Mode property can be set to control the state that the PWM Line is set to when the motor is braking.  Other attributes of the motor's operation can be adjusted by directly manipulating the oHBridgeH object, but note that doing so may change the way the motor behaves to something different than the way described in this document.

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 Connections:
 Wirz 203 Motor Driver H-Bridge use 2 power lines and each half uses 2 I/O lines. 
IOLineD can be any I/O line of the ooPIC's 31 I/O lines.  The IOLineP can be I/O line 17 or 18. 
The Wirz 203 Motor Driver H-Bridge requires 4.5 Volts with enough current to dive the attached DC motor.
Wirz 203 Motor Driver H-Bridge and DC Motor.
Wiring for first of two possible motors.
PinNameDescriptionI/O NameooPIC
I/O Line
1Digital GroundSignal Ground Gnd
2VccOutput to DC Motor 5 Volts
3PWM AControls the speed of the motor A.IOLineP17 or 18
4Dir AControls direction of motor A.IOLineBAny*
5PWM BControls the speed of the motor B.IOLineP17 or 18
6Dir BControls direction of motor B.IOLineBAny*
7N/C   
8N/C   
9N/C   
10N/C   
Caution:
 Do NOT connect the outputs of the ooPIC directly to a DC Motor. The TTL circuitry of the ooPIC is not designed to drive the power requirements of a DC Motor.  Doing so can potentially damage the ooPIC's TTL outputs.

*Caution: I/O lines 16 through 23 are used for special purposes.  Be sure not to specify any of these I/O lines if these special functions are in use.

Back to top of page Examples:
 In the following example, the oDCMotorWZ Object is used.
' This program ramps a DC Motor's speed
' up and down / forwards and backwards.

Dim A As New oDCMotorWZ 

Sub Main() 
  A.IOLineP = 17
  A.IOLineD = 24
  A.Operate = cvTrue
  Do
    For A = -100 To 100
      ooPIC.Delay = 2
    Next A
    For A = 100 To -100 step -1
      ooPIC.Delay = 2
    Next A
  Loop 
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
oDCMotor2Controls a DC motor that is driven by an L293 H-Bridge driver.xx
oDCMotor3Controls a DC motor that is driven by two drivers.xx
oDCMotorMTControls a DC motor that is driven by a Wirz 203 Motor Driver.xx
oNavConAn Object that provides differential steering calculations.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B2: Introduced.

Bugs: No known bugs.


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