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
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 6
2. System Design Overview 7
3. USB Controller 8
3.1. Firmware Design 9
3.2. Force Feedback Data 9
4. Motor Controller 11
5. Position Sensor 12
6. Construction 13
7. Test Procedures and Design Verification 14
7.1. Verifying the Wheel Position 14
7.2. Verifying the Force Feedback Operation 15
7.3. Verifying the Force Feedback Steering wheel using the simulator software 16
8. Conclusion 17
9. Recommendation 17
10. References 18
Appendix A 19
List of Figures
Figure 1 System Block Diagram of the Force Feedback Steering Wheel 7
Figure 2 Data format of the Set Effect Output Report 9
Figure 3 Data format of the Constant Force Report 10
Figure 4 Schematic of a H Bridge Motor Controller 11
Figure 5 Logic States of an Optical Encoder 12
Figure 6 USB Device Enumeration Verificaton 13
Figure 7 Position Verification using DXTweak 14
Figure 8 Screenshot of the Live For Speed Driving Simlator 16
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 H-bridge 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.