engr446-ffb-report - University of Victoria

advertisement
Gerald Leung
Faculty of Engineering
ENGR 446 Technical Report
Initial Design and Implementation of a USB
Force Feedback Steering Wheel
Gerald Leung
V00659924
Computer Engineering
gleung86@uvic.ca
In partial fulfillment of the University of Victoria
Bachelor of Engineering degree requirements
April 8, 2010
Jonothan Forewaker
Co-op Coordinator
Faculty of Engineering
University of Victoria
P.O. Box 3055
Victoria, B.C.
V8W 3P6
Dear Mr. Forewaker,
Please accept the accompanying Engineering 446 Technical Report entitled “Initial Design and
Implementation of a Force Feedback Steering Wheel”. This report is fulfillment of my obligation
pertaining to the Bachelor of Engineering program requirements.
This report contains confidential material that has been used for personal engineering consulting work.
Sincerely,
Gerald Leung
Computer Engineering 4B
Enclosure: ENGR446 Technical Report.
Table of Contents
1.
Introduction .......................................................................................................................................... 7
2.
System Design Overview ....................................................................................................................... 8
3.
USB Controller....................................................................................................................................... 9
3.1.
Firmware Design ......................................................................................................................... 10
3.2.
Force Feedback Data ................................................................................................................... 10
4.
Motor Controller ................................................................................................................................. 12
5.
Position Sensor.................................................................................................................................... 13
6.
Construction........................................................................................................................................ 14
7.
Test Procedures and Design Verification ............................................................................................ 15
7.1.
Verifying the Wheel Position ...................................................................................................... 15
7.2.
Verifying the Force Feedback Operation .................................................................................... 16
7.3.
Verifying the Force Feedback Steering wheel using the simulator software ............................. 17
8.
Conclusion ........................................................................................................................................... 18
9.
Recommendation................................................................................................................................ 18
10.
References ...................................................................................................................................... 19
Appendix A .................................................................................................................................................. 20
List of Figures
Figure 1 System Block Diagram of the Force Feedback Steering Wheel ...................................................... 8
Figure 2 Data format of the Set Effect Output Report................................................................................ 10
Figure 3 Data format of the Constant Force Report ................................................................................... 11
Figure 4 Schematic of a H Bridge Motor Controller .................................................................................... 12
Figure 5 Logic States of an Optical Encoder ................................................................................................ 13
Figure 6 USB Device Enumeration Verificaton............................................................................................ 14
Figure 7 Position Verification using DXTweak ............................................................................................ 15
Figure 8 Screenshot of the Live For Speed Driving Simlator ....................................................................... 17
Glossary
Summary
This report documents the design and implementation of a force feedback steering wheel. The purpose
of this project is to create a force feedback steering wheel device that mimics the characteristics of a
steering wheel in a real car for gaming and simulation applications.
A computer driving simulator will be used to create a virtual environment of driving a car. The simulator
provides digital data that relates the characteristics of the steering wheel being driven in the simulator.
This information is then sent out through the USB communication protocol.
The force feedback steering wheel device consists of a USB controller to capture the steering wheel data
from the simulator, a motor controller to drive the motor, a motor coupled to a steering wheel, which
will generate physical torque and various vibration effects to allow the user to feel, or sense the
behavior of the car on the road and a position sensor to determine the position of the steering wheel.
This report will discuss the design and specifications of all the elements mentioned above. The
implementation and construction of the device will then be documented in this report. Test procedures
will follow after to discuss the overall performance of the system.
This report will end with a conclusion to recap the design and implementation of the force feedback
steering wheel with recommendations on how the system can be improved based on the test procedure
and the performance of the system.
1. Introduction
Computer driving and auto racing simulators serves a purpose of not just for entertainment applications,
but for also allowing the general public to experience what it’s like to drive a high-performance vehicle
in a high adrenaline race competition environment where such event in real life would cost millions of
dollars to participate. A force feedback steering wheel can further mimic the experience of driving a
physical car to allow the user to sense or feel what it’s like to hold onto a steering wheel in an actual car.
Popular manufacturers of gaming peripheral devices such as Microsoft, and Logitech has been selling
force feedback devices for more than 10 years. Due to the low demand and interest of auto simulators
from the general public, companies tend to design and manufacture force feedback steering wheels at
an affordable price. However, this effect is directly proportional to the quality of the devices. Motor
actuator used in their force feedback devices are cheap and provide low torque power and response and
plastic bearings and gears are used, which feels like a toy instead of grabbing onto a steering wheel in a
real car.
In order to create a high quality force feedback steering wheel, a high quality industrial graded motor
must be used to generate adequate torque and smooth rotation. Plastic gears and bearings can be
replaced with metal gears and ball bearings to give the user a better feel of driving a physical car in the
virtual world. A custom force feedback electronic controller must be designed to accommodate this
revised mechanical specification.
This report will outline the design and implementation of a force feedback controller, which will be
responsible for retrieving digital data containing information of the steering wheel in the simulator from
a PC, interpret the data and drive the motor to generate the torque or vibration effect to the steering
wheel.
2. System Design Overview
The following block diagram provides a top level overview of the system components.
Figure 1 System Block Diagram of the Force Feedback Steering Wheel
The USB controller consists of a microprocessor with USB functionality, and various I/O features to drive
the motor and read the data from the position sensor. The USB controller is responsible for retrieving
and reporting data to and from the computer that is running the driving simulator. A simple DC motor
will be used as the actuator to generate torque and vibration effects. Finally, an optical encoder will be
mechanically coupled to the steering wheel shaft to read the position and send it back to the USB
controller. The following section will discuss the design and implementation of each system block
element in detail.
3. USB Controller
The USB controller is responsible for retrieving and reporting data to and from the computer that is
running the driving simulator. The particular USB controller used in this project is the Microchip
18F4550.
The USB controller can be configured to various device classes that specify the functionality of the
device such as bulk transfer, where large amounts of data is sent at one time for applications such as
USB printers, or mass storage class for devices such as USB flash drives.
The device class used in this project is the Human Interface Device (HID). This class allows the device to
interact directly with the human user by taking inputs and delivering outputs to the user. Based on the
system overview discussed in the previous section, the input to the USB device is the position of the
wheel read by the position sensor and the output from the USB device is the analog signal that will
power the motor.
Unlike the bulk transfer and mass storage class where large amounts of data is sent continuously in one
time interval, the HID class is interrupt driven. This implies that data will only be sent from the PC to the
USB controller (or vice versa) when a particular event occurs. In this project’s point of view, the USB
controller will only report the position of the steering wheel to the PC only when the position of the
wheel has changed, and requires the PC to update the steering wheel location in the driving simulator
software. The PC will only send data to the USB controller when the driving simulator detects change in
the car movement, such as driving over a bump on the road. The USB HID class also does not require
any custom drivers that need to be installed on the computer. Windows operating system will
automatically load a pre-configured USB HID driver to allow the computer to communicate with the
device based on its configurations.
The USB communication protocol is highly complex. Fortunately, Microchip provides a USB stack that
contains various libraries for USB functionality. The particular firmware is the 18F4550 USB controller is
the USB HID firmware provided by Microchip. Once the firmware is programmed into the controller, it is
now ready to be plugged into the PC to send and receive data to and from the USB controller
respectively. Slight modifications to the firmware were made to enable the USB controller to
enumerate as a force feedback USB device.
3.1.Firmware Design
The data exchanged between the PC and the USB controller is sent in the form of a packet. The packets
received and sent to a PC must be interpreted correctly in the USB controller by following the standard
USB specifications.
3.2.Force Feedback Data
The PC sends various packets to the USB controller containing force feedback data computed by the
driving simulator. The particular data packet of interest is the constant force and the set effect report
packet. The set effect report packet contains direction of the force, and the constant force packet
contains the magnitude of the force to apply to the motor. The following figure taken from the USB
specifications illustrates the data packet format. The first byte of each packet contains the report ID,
which is how the data packets received from the PC can be identified. The firmware code written
detects the first byte to identify what packet it is.
Figure 2 Data format of the Set Effect Output Report
Since the force feedback steering wheel can only turn left and right, which is only one axis, the particular
data of interest in the set effect output report packet is the X axis Direction. This data field is
represented in an 8-bit 2’s complement number ranging from -128 to +127. The firmware simply
detects the direction of the force by determining whether this field is negative or positive. A negative X
axis direction means the direction of force is left, and the wheel should turn counter-clockwise, and a
positive X axis means the direction of force is right, and the wheel should turn clockwise.
Figure 3 Data format of the Constant Force Report
The constant force packet contains a report ID of 5. The data field of interest is the 8-bit Magnitude
value ranging from 0 -255, where 255 is the maximum magnitude. The USB controller is responsible for
driving the motor direction and controlling the amount of power delivered to the motor relative to the
set effect, and the constant force packet respectively.
4. Motor Controller
Since the USB controller can only provide 5 volts at a maximum of 25 mA, a H-bridge motor controller
interfaced to the USB controller is required to amplify the output signal from the USB controller to drive
DC motors rated at 12 to 24 volts with a maximum of 2 Amps.
The USB controller generates a Pulse Width Modulation (PWM) signal that is fed to the inputs of the Hbridge controller. The duty cycle of the PWM signal will determine how much torque the motor is
generating. Two separate output pins that generate the PWM signal from the USB controller are used
to control the direction of the motor. The following H-bridge schematic is used in this design.
Figure 4 Schematic of a H Bridge Motor Controller
The main components of the H-bridge controller are the mosfet transistors. The mosfet transistors are
switched on and off to allow current to flow through the motor. When a transistor is turned on, the
Drain and Source terminals are essentially a short circuit. The NPN and PNP transistors are used to
provide adequate voltage to the gates of the mosfet transistors to drive the mosfet transistors to
saturation in order to fully switch them on. The voltage applied to the Q3 and Q5 transistors have to be
at least 5 to 7 volts higher than the voltage of the Drain terminal. In this schematic, 24 volts is applied to
the Gate of the Q3 or Q5 transistors to fully switch them on. The mosfet transistors used is the IRF 520,
rated at 9.2Amps and maximum of 100 volts.
The operation of the H-bridge controller is simple. In order to drive the motor clockwise, transistors Q3
and Q6 are turned on, the 12 volt supply is applied to the motor, allowing current to flow from the
positive to negative terminals of the motor. To drive the motor counter-clockwise, transistors Q5 and
Q4 are turned on, where current will flow from the negative to the positive terminals of the motor. The
direction and power of the motor is controlled by applying the PWM and varying its duty cycle with
respect to the given table on the schematic.
5. Position Sensor
The position of the physical force feedback steering wheel needs to be reported back to the PC via the
USB controller to let driving simulator software know which direction to turn the car when the user
turns the force feedback steering wheel. An optical encoder is used as a position sensor, which is
mechanically coupled to the motor shaft.
An optical encoder converts the angular position into a digital code through two digital outputs. As the
shaft of the optical encoder rotates, the logic states of the two output changes. The optical encoder
used I When the optical encoder shaft is rotated counter-clockwise, the top waveform will lag the
bottom waveform. This is how the direction can be detected in the USB controller firmware. The
optical encoder used in this design is the HP QEDS-9500. The counts per revolution (CPR) of the optical
encoder determines the resolution of the optical encoder. The CPR of the optical encoder used is 2000.
This implies that the state of the digital outputs changes every 0.18 degrees, which is computed by
dividing 360 degrees in one revolution by 2000 counts. The following waveform illustrates the
operation of an optical encoder as the shaft is rotated in a clockwise direction.
Figure 5 Logic States of an Optical Encoder
The two digital outputs from the optical encoder are interfaced to two digital inputs in the USB
controller. When the state of the optical encoder output changes, the USB controller will generate an
edge-triggered interrupt and the logic states of the optical encoder are compared to determine whether
the direction of the optical encoder was turned clockwise, or counter-clockwise. A position counter
variable in the USB firmware is either incremented or decremented when the optical encoder an
interrupt event occurs. This value is then sent back to the PC through the USB port to notify the driving
simulator of the new position of the force feedback steering wheel.
6. Construction
The components of the USB controller were soldered together on a circuit board. The firmware was
then programmed into the 18F4550 microprocessor using the Microchip’s chip programmer. The USB
controller was then plugged into the PC and the game controller manager in Windows Vista was used to
verify that the computer enumerated the USB device correctly. The following figure is a desktop
screenshot that verifies the successful enumeration of the USB controller.
Figure 6 USB Device Enumeration Verificaton
7. Test Procedures and Design Verification
Once the device is successfully enumerated by the computer, the USB controller can be tested and
verified to ensure that it is capable of sending and receiving information from the computer.
7.1.Verifying the Wheel Position
The information sent from the USB controller to the computer contains the position of the steering
wheel using the optical encoder as described in the previous section. The DXTweak application was
used to verify the correct operation of the position sensor. This application monitors and displays the
status of a connected USB game controller. To verify the operation of the position sensor, the optical
encoder was rotated clockwise and counter-clockwise by a user while monitoring the status of the XAxis in DXTweak. The following is a screenshot of running DXTweak for testing the position sensor. The
information outlined in the thick rectangle contains the data of interest for this particular test
procedure.
Figure 7 Position Verification using DXTweak
7.2.Verifying the Force Feedback Operation
The Fedit application was used to verify the correct operation of the force feedback operation of the
USB controller. The Fedit application allows the user to alter the magnitude and direction of the force of
the force feedback device. This implies that, the greater the magnitude of the force is set in the Fedit
application, the faster the motor will spin. The direction of the force is also verified to visually
monitoring the direction of rotation of the motor. The following figure contains a screenshot of the
Fedit application used for verifying the force feedback operation.
This test procedure was successfully verified. When the user holds onto the motor shaft tightly, the
magnitude and the direction of the torque felt by the user are updated with respect to the magnitude of
the force parameter set in the Fedit application.
7.3.Verifying the Force Feedback Steering wheel using the simulator
software
The Live for Speed simulator was used to verify the overall operation of the Force Feedback Steering
Wheel. This test procedure should allow the user to manually rotate the motor shaft by hand to drive
the car in the steering wheel while being able to feel, or sense the torque and vibration effects that
simulate the behavior of driving an actual car in the virtual world. The overall user experience worked
quite well. The motor gives the user a good sense of the road and the car under various conditions such
as making sharp turns, or driving over bumpy roads. However, this setup omits the mechanical setup of
using a larger motor coupled to a physical steering wheel.
The following figure is a screenshot of the Live for Speed application.
Figure 8 Screenshot of the Live For Speed Driving Simulator
Finally, the following link to a website is a video of the final result of the Force Feedback Device under
test operation: http://www.youtube.com/watch?v=8ZKv0dJCjiA
8. Conclusion
A force feedback steering wheel device allows the user to experience driving an actual car in computer
simulator software by mimicking the characteristics of a steering wheel in a real car for gaming and
simulation applications. The force feedback steering wheel device consists of a USB controller to
capture the steering wheel data from the simulator, a motor controller to drive the motor, a motor
coupled to a steering wheel, which will generate physical torque and various vibration effects to allow
the user to feel, or sense the behavior of the car on the road and a position sensor to determine the
position of the steering wheel. The USB device is required to send and capture the wheel position and
force feedback data through the USB port. A motor is used to generate torque and vibration effects to
the user with respect to the force feedback data retrieved from the computer simulator. A H-bridge
motor controller is interfaced to the USB controller to be able to provide sufficient power to drive the
DC motor. An optical encoder is used in this design to obtain the angular position of the steering wheel
to notify the driving simulator where to turn the car.
9. Recommendation
This project mainly consisted of the electronics and firmware design of the force feedback
steering wheel, which only allows the user to drive the car by turning the motor shaft using a
miniature DC motor. This project lacks the mechanical design of coupling a more powerful DC
motor to an actual steering wheel for the user to drive the car in the simulator. It is also
recommended to use a simple mechanical gear system between the motor and the steering
wheel to amplify the torque on the steering wheel to give the user a better experience.
References
[1] Microchip PIC18F4550 Reference Data Sheet, www.microchip.com, Microchip Technology
Incorporated
[2] IRF 520 N-Channel Mosfet Reference Data Sheet, www.irf.com, International Rectifier
[3] USB PID Device Specifications, www.usb.org, USB Implementers Forum
[4] Jan Axelson (2001). USB Complete fourth edition. Lakeview Research. ISBN-10: 0965081958
[5] HP QEDS-9500 Optical Encoder Reference Data Sheet, www.hp.com, Hewlett Packard Corporate
Appendix A
Schematic of Microchip 18f4550 USB Controller Interface
Download