Nathan Roseborrough

53
EE – 3332 – 001 Project Lab 3: Group #6 B.E.S.T. Remote / Alternative System Nathan Roseborrough December 10, 2004 Instructor: Dr. Dickens Advisor: Dr. Parten Team Members: Joshua Crabtree, Muneem Shahriar, Chris David, Chuck Morton Department of Electrical Engineering Texas Tech University 1

description

 

Transcript of Nathan Roseborrough

Page 1: Nathan Roseborrough

EE – 3332 – 001

Project Lab 3: Group #6

B.E.S.T. Remote / Alternative System

Nathan Roseborrough

December 10, 2004

Instructor: Dr. Dickens

Advisor: Dr. Parten

Team Members: Joshua Crabtree, Muneem Shahriar, Chris David, Chuck Morton

Department of Electrical Engineering

Texas Tech University

1

Page 2: Nathan Roseborrough

Abstract

This report will detail the design and construction of a wireless control system intended for

usage by the B.E.S.T. organization. Traditionally, a four channel commercial hobby transmitter and

receiver have been used. Due to the ever-improving nature of the B.E.S.T. organization, a more

advanced and less costly system is needed. The goal of this project is to design one such system. The

alternative system has expanded user interface capabilities and is intended to be less costly than a

traditional hobby system.

2

Page 3: Nathan Roseborrough

Table of Contents

Abstract …………………………………………………………………….. 2

Table of contents …………………………………………………………………….. 3

List of Figures …………………………………………………………………….. 4

Introduction …………………………………………………………………….. 5

Design Considerations …………………………………………………………………… 6

Input Device …………………………………………………………………….. 7

Transmitter …………………………………………………………………….. 10

Receiver …………………………………………………………………….. 15

Power Supplies …………………………………………………………………….. 17

Conclusions …………………………………………………………………….. 18

References …………………………………………………………………….. 16

Appendix A: Code listing, PSX.BAS – Playstation controller interpreter …………….. 17

Appendix B: Playstation controller information …………………………………….. 26

Appendix C: Code listing – transmitter control code …………………………………….. 31

Appendix D: Transmitter and receiver prototype pictures ……………………………….. 36

Appendix E: Transmitter schematic …………………………………………………….… 37

Appendix F: Amplifier Biasing data table ……………………………………………….. 38

3

Page 4: Nathan Roseborrough

List of Figures

Figure 1: B.E.S.T. Competition Event ……………………………………………………. 5

Figure 2: Typical Futaba transmitter and receiver ……………………………………………. 5

Figure 3: Speedy-33 DSP …………………………………………………………………….. 6

Figure 4: Game controllers …………………………………………………………………….. 7

Figure 5: Playstation controller cable adapter …………………………………………….. 8

Figure 6: Diagram of Playstation controller connector …………………………………….. 9

Figure 7: Sequence of data during controller communication …………………………….. 10

Figure 8: Transmitter Block Diagram (courtesy Muneem Shahriar) …………………………….. 11

Figure 9: Output of transmitter when modulating serial data and in idle state …………………… 11

Figure 10: DDS output before and after filtering …………………………………………………. 12

Figure 11: Amplifier gain versus supply voltage …………………………………………………. 13

Figure 12: Output spectrum of primary amplification stage ……………………………………….13

Figure 13: Additional filter and amplifier on transmitter and resulting output spectrum. …………14

Figure 14: Received spectrum when transmitter is two feet away …………………………………14

Figure 15: Receiver Block Diagram (courtesy Muneem Shahriar) …………………………….. 15

Figure 16: MC3362 receiver chip …………………………………………………………….. 16

4

Page 5: Nathan Roseborrough

Introduction

The B.E.S.T. (boosting engineering science and technology) organization is a volunteer-run non-profit

robotics competition for students. Held annually, the national competition draws 8000 students from over 700

schools.

Figure 1: B.E.S.T. Competition Event

Each school is given an identical kit consisting of building materials and remote control components. Using

only materials from the kit, students engineer and build a robot for competition. The robots use a traditional

four channel hobby radio control system, operating in the 75MHz frequency range.

Figure 2: Typical Futaba transmitter (left) and receiver (right)

The existing system is becoming increasingly expensive to maintain, and many feel that the limited

control capabilities are hindering the full creativeness of the competing teams. The “speedy-33” digital signal

5

Page 6: Nathan Roseborrough

processor is part of the solution, allowing full programmability of robot behavior. However at the time of

writing there is no suitable system to allow remote control of the speedy-33.

Figure 3: Speedy-33 DSP

It is the intention of the project lab 3 students to design and build an alternative replacement system that will

both expand the control capabilities and cost less to implement than the existing control system. This

alternative system is to use the same frequencies designated by the FCC for hobby remote control usage, as

well as conform to all requirements placed on RF devices operating in this range.

Design Considerations

To replace the existing system effectively it is important to understand the full functionality of a hobby radio

control system. The user interacts with the handheld transmitter via 2 joysticks. Each joystick consists of a

vertical stick which manipulates two internal potentiometers. The resistance of these potentiometers is

encoded and used to modulate an FM signal at a frequency dependent upon one of thirty crystals. These

frequencies are 20kHz apart, and span 75.41 MHz to 75.99 MHz. The modulated signal is then transmitted to

the receiver and demodulated using a dual downconversion scheme. The demodulated signal is processed

into seven servo-compliant pulse width modulated signals. The receiver module is able to decode signals

from a transmitter using up to seven inputs, however the system currently in place uses only four. The end

6

Page 7: Nathan Roseborrough

result is a system which allows a user to alter servo positions (or other compatible peripherals) in a manner

directly proportional to the input applied on the joysticks.

Input Device

Many input devices were analyzed for usage in a replacement system. Early candidates included computer

keyboard, mouse, trackball, analog joysticks (for computer use), and game console controllers. The computer

keyboard, mouse, and trackball were eliminated since they did not provide 4 axis analog control. Computer

joysticks, while allowing the same four axis control, use USB interfaces. Older designs used a strict analog

signal which was then encoded by the host computer, but retailers which offer this type of joystick are

dwindling. The USB interface requires a host controller. These are difficult and costly to develop and require

software drivers to communicate properly. These drivers are often copyrighted and patented by the

manufacturer and are unavailable in formats other than x86 binary files. Game console controllers are the

obvious choice for this system. Game controllers are designed specifically to provide a comfortable, intuitive,

inexpensive, and versatile method for interaction with a large variety of games. These also prove ideal for the

control of a robot. The controllers for gaming systems currently in production were compared. The three

competing systems are the Microsoft Xbox, Sony Playstation, and the Nintendo Gamecube.

Figure 4: Game controllers, left to right, Sony Playstation, Microsoft Xbox, Nintendo Gamecube

The Microsoft Xbox controller is a USB device with an incorporated two port hub, used for memory

cards. It provides the user with two analog joysticks, two single axis analog triggers, and 16 digital buttons.

7

Page 8: Nathan Roseborrough

This controller was eliminated due to its requirement of a costly USB host controller. The Nintendo

Gamecube controller provides two analog joysticks, two triggers, and ten digital buttons. The interface is a

proprietary protocol used by the Nintendo game system family, and could easily be decoded using a

microcontroller. The Sony Playstation “dual shock” controller sports two analog joysticks and sixteen digital

buttons. The interface protocol is comprised of bi-directional clock controlled serial data transfer. This

controller was chosen since Playstation controllers offer backwards compatibility, and interface information is

readily available.

The Playstation controller uses a proprietary nine pin connector. An aftermarket female connector was

selected to allow usage of the controller without need for modification.

Figure 5: Playstation controller cable adapter

To communicate with the controller, a PIC16F676 was chosen. This microcontroller is programmed

in “picbasic” using the PicBasic Pro compiler from MeLabs. The pins of the controller are directly connected

to the PIC microcontroller, with only a single pull-up resistor on the “data” pin. The goal of the PIC is to

emulate communications from a Playstation game console.

8

Page 9: Nathan Roseborrough

LOOKING AT THE PLUG

------------------------------- PIN 1-> o o o | o o o | o o o |

\_____________________________/

Figure 6: Diagram of Playstation controller connector

The VCC and GND pins are connected directly to the same power supply used by the microcontroller. The

“data” pin is connected to an I/O pin on the microcontroller and pulled high by a 20Kohm pull-up resistor.

This pin is an open collector input, and is pulled low by the Playstation controller to transmit data to the

microcontroller. The “command” pin is driven directly by an I/O pin and is used to send data to the

Playstation contoller. The “att” pin is also driven directly, and is used to control data transfer to and from the

controller. The “clock” pin is directly driven and controls the actual data transfer. The “ack” pin is used for

error correction and is unused in this system.

To read the state of the buttons and joysticks, a simple transmit and receive algorithm is used. The controller

is polled indefinitely in a loop to provide continuous control data. To initiate communications, the “ATT” pin

is driven low. The PIC then drives the “command” pin high or low, depending on the least significant bit of

the byte being transmitted. The clock pin is then driven high, which triggers the controller to read the state of

the “command” pin. The PIC then reads the state of the “data” pin. A slight delay occurs, the “clock” pin is

driven high, another delay occurs, and the process repeats. Each time a bit is read it is placed into the most

significant bit and shifted right. After this process occurs eight times, a full byte of data is buffered and the

next byte is ready to be read.

To poll the controller, the byte 0x01 is sent, then the byte 0x42 is sent at the same time the controller sends its

identifier. The “command” pin then idles (high) as the controller streams six bytes. These six bytes

correspond directly to the state of the buttons and the position of the analog joysticks.

9

Page 10: Nathan Roseborrough

BYTE CMND DATA

01 0x01 idle 02 0x42 0x73 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data SLCT JOYR JOYL STRT UP RGHT DOWN LEFT 05 idle data L2 R2 L1 R1 /\ O X |_| 06 idle data Right Joy 0x00 = Left 0xFF = Right 07 idle data Right Joy 0x00 = Up 0xFF = Down 08 idle data Left Joy 0x00 = Left 0xFF = Right 09 idle data Left Joy 0x00 = Up 0xFF = Down

Figure 7: Sequence of data during controller communication

After receiving a full packet, the microcontroller formats and sends the data at 1200 baud on a standard RS-

232 connector. The sent data consists of a start byte followed by the controller identifier, which is then

followed by the button and position data, then ended with a stop byte.

The Playstation controller communication system is housed in a separate enclosure, and interfaces with the

transmitter (or a computer) via a standard RS-232 port. This arrangement is advantageous for several reasons.

Interference between the input system and the transmitter will be reduced, for example, and the usage of an

RS-232 connector allows the transmitter to be used with any device capable of serial communication (e.g. a

laptop.)

Transmitter

The existing transmitter system is incorporated into the same housing as the joysticks. The existing system is

designed for operation on one of 30 channels, which is changed by swapping the oscillator crystal. FM

modulation is used to send encoded data corresponding to the joystick positions.

The replacement for this system will operate on the same frequencies, but will transmit encoded serial data.

This will allow operation as a one-way serial modem. The transmitter will use FM FSK modulation.

10

Page 11: Nathan Roseborrough

Figure 8: Transmitter Block Diagram (courtesy Muneem Shahriar)

The transmitter system uses a DDS chip produced by Analog Devices. DDS (direct digital synthesis)

is a relatively new technology which uses high speed logic to synthesize a sinusoidal output. This is

advantageous to the design since channels can be changed without swapping crystals. The DDS requires a

high precision 30Mhz crystal as a reference oscillator, which is then multiplied internally to a speed of

180Mhz. Since the employed FSK modulation method is characterized by changing between two frequencies,

the DDS is programmed in real time to synthesize the necessary frequency at a given moment.

Figure 9: Output of transmitter when modulating serial data (left) and in idle state (right).

An MSP-430 is used to program the DDS upon stimulation from the input interpreter system. The

input interpreter and the MSP are coupled with an RS-232 connector. In order to initialize and change

11

Page 12: Nathan Roseborrough

frequencies on the DDS, programming words must be sent over a parallel bus. Due to the differences in logic

voltage (3.3v versus 5v) level shifting chips are employed between the MSP and the DDS. The transmission

speed is not currently limited, however, by the time necessary to program the DDS between bits. The DDS

was tested by switching between high (mark) and low (space) frequencies at high speed, far surpassing any

baud rate requirements employed by the system. The output of the DDS consists of two current sources,

which are 180 degrees out of phase. These sources are connected to a 1:1 center tapped transformer to

produce a useable output. When coupled directly to a spectrum analyzer the output of the DDS peaked at -

4dBm. Transformer coupling also eliminates common mode signals, which have undesirable effects on

amplification and filtering stages. The output is then routed through a bandpass filter to remove the

significant harmonics inherent in DDS implementation.

Figure 10: DDS output before (left) and after (right) filtering

The bandpass filter output is fed directly into the primary amplification stage. The amplifier employed is a

Minicircuits ERA-50SM surface mount broadband amplifier. Biasing voltages for the amplification stage

were tested from 0 to 8 volts DC.

In testing, the optimal gains were achieved at the highest voltage applied. Unfortunately, at voltages above

6.5 volts the amplifier would run for a short time then move into breakdown.

12

Page 13: Nathan Roseborrough

Amplifier Gain vs Supply Voltage @ 75mHz

-50

-40

-30

-20

-10

0

10

20

Volts

dB

m Amplifier 1

Amplifier 2

Figure 11: Amplifier gain versus supply voltage

After breaking down, a short is created and the system ceases to function. In ideal conditions the

output of the on-board amplifier is 4dBm. This does not prove sufficient for transmission and an additional

amplifier stage is required.

Figure 12: Output spectrum of primary amplification stage

Additionally, the nature of the broadband amplifier chosen does not lend itself to this application, as it will

amplify any harmonics which escape filtering by the primary bandpass filter. Note the amplified image of the

local oscillator in figure 12. To improve the output spectrum, an additional filter and amplification stage is

13

Page 14: Nathan Roseborrough

used. They are separate from the main board and are attached to the BNC output in series from the

transmitter.

Figure 13: Additional filter and amplifier on transmitter and resulting output spectrum.

Again, the usage of a broadband amplifier was not advantageous, since it continued to counteract the filter and

amplify unwanted signals. With the additional amplification and filtering stage, the system yielded an output

of 14dBm. To test the ability of the transmitter to transmit, a 50 ohm telescoping antenna was attached to the

final filtering stage. An antenna was in turn attached to the spectrum analyzer.

Figure 14: Received spectrum when transmitter is two feet away.

14

Page 15: Nathan Roseborrough

The spectrum analyzer was able to detect a signal at 75mHz, so the transmitter was indeed transmitting. At a

magnitude of -30dBm, however, the signal will not usable by the receiver. To make the output usable an

additional amplifier is needed, and would ideally be a high power tuned amplifier.

Receiver

The existing receiver module utilizes a dual downconversion demodulation process to extrapolate 7 servo

positions from an FM signal. It requires a crystal 10.7Mhz lower than the transmitted frequency. The

replacement receiver also employs a dual downconversion system, but will only need to extrapolate a binary

state from the signal. The design is centered around the MC3362 receiver chip. This IC incorporates several

features that are useful in demodulation of an FM signal. A power amplifier is ideally not required since the

IC has a high input sensitivity, requiring a minimum of 0.6 uV rms.

Figure 15: Receiver Block Diagram (courtesy Muneem Shahriar)

The diagram of the chip was broken into numbered sections for discussion (courtesy Josh Crabtree).

Stage 1 is the input stage, coupled directly to the antenna. At stage 2, the input signal is mixed with first local

oscillator. The first local oscillator is a crystal oscillator which is 10.7Mhz below the transmitted frequency.

Initially, the first local oscillator was to be a crystal identical to those used in the hobby system. Through

repeated tests, we were unable to cause the crystal to oscillate. It was replaced by an integrated crystal

oscillator, which seemed to function adequately.

15

Page 16: Nathan Roseborrough

Figure 16: MC3362 receiver chip

Pin 20 provides a buffered output allowing analysis of the input network without disrupting the impedence.

Mixing the input signal with this oscillator results in a signal at the first intermediate frequency, 10.7MHz.

This signal is then filtered in stage 3 using a ceramic filter. At stage 4 the first intermediate frequency is

mixed with a 10.245MHz local oscillator, providing the second intermediate frequency of 455kHz. The

signal is then passed through a second ceramic filter in stage 5. Stage 6 represents the stage at which the

signal is passed through the chips internal detection circuitry. At stage 7, the onboard comparator is used to

determine a logic state of high or low. The comparator output is fed directly into a microcontroller which

then decodes the data back in to a usable serial data format. This data is then served directly to the Speedy-33

DSP. During testing, the MC3362 chip ceased to function soon after the crystal oscillator was activated.

After several repetitions with new MC3362 chips, the conclusion was drawn that the crystal oscillator’s high

output was destroying the first mixer.

16

Page 17: Nathan Roseborrough

Power Supplies

The main power supplies for both the transmitter and receiver are variable. For testing, a nine volt battery

was used, but the system could just as easily be run from the on board 7.2 volt battery. The power supplies

for the various onboard components are regulated with linear regulators. A total of three regulators are used

on the transmitter. The MSP-430 requires a 3 volt supply, the other components which use 5 volt logic

require a 5 volt supply, and the power amplifier requires an 8 volt supply. The receiver uses 2 regulators, a

five and a three volt. The five volt could easily be eliminated by removing the crystal oscillator, which is the

only component which requires the five volt supply.

17

Page 18: Nathan Roseborrough

Conclusions

The alternative system at the time of writing is not a viable replacement for the existing system. The

transmitter amplification stage is in need of considerable redesign. A tuned high power amplifier should have

been used. The receiver is far from production ready. The input stage is apparently in need of an amplifier,

and the broadband amplifier originally intended for this purpose is not suitable. The main component of the

receiver, the MC3362, is no longer in production. While suitable replacements exist, the receiver board

would require a ground-up redesign to function properly. The first local oscillator used in the receiver system

is in need of replacement. The suggested crystal was not usable, and the crystal oscillator which replaced it

causes damage to the chip. The circuit could be modified to reduce the voltage output from the crystal

oscillator, or the oscillator could be replaced by a DDS to provide crystal-less frequency switching capability.

The amplifiers used are misapplied in this design. They do not provide enough gain for transmission, and

their broadband design counteracts filtering and amplifies unwanted components. Given several weeks more

development time, these changes could be implemented and the system would theoretically be viable for

usage.

18

Page 19: Nathan Roseborrough

REFERENCES

Playstation controller data:

http://www.gamesx.com/controldata/psxcont/psxcont.htm

B.E.S.T. Website

http://www.bestinc.org/MVC/

B.E.S.T. competition photo

http://www.pchs.pickens.k12.al.us/RobotClub.htm

Futaba transmitter picture

http://web.ticino.com/Submarine/Futaba.jpg

Controller Pictures

http://www.skycityuniversal.com.hk/

Speedy-33 Picture

http://www.hyperception.com/pdf/datasheets/

19

Page 20: Nathan Roseborrough

Appendix 1: PSX.BAS Playstation controller interpreter program code listing

'****************************************************************'* Name : PSX.BAS *'* Date : 9/13/2004 *'* Version : 0.1.0 *'* Notes : This program is designed to communicate with a *'* Playstation 1 "dual shock" controller. Originally*'* written as part of a larger control system, this *'* implementation can be used as a generic PSX *'* controller interpreter. *'* : *'* Author : Nathan Roseborrough *'* *'* Version *'* Info 0.0.1 First successful 0.0.1 compile *'* 9/15/04 - 12:06pm *'* Project enters 0.1.0 *'* 0.1.1 Target processor changes from 18F1320 to *'* 16f676 to overcome cross assembling issues *'* 1.0.0 First successful communication *'* 1.0.1 Added: *'* -Weak Pull-up resistors * '* Fixed: *'* -Bit shifting issue in psx comm rountine*'* 1.1.0 Demonstration version for proof of comm. *'* 1.1.1 Removed demo setup, added streaming packet * '* *'* Todo -powerup calibration routine *'* -steering wheel support *'* -external serial detection and support *'* -GPS-like packets to save bandwidth *'* -implement ACK checking *'****************************************************************

'****************************************************************'*** BUG TRACKER SECTION ******************************* :) *****'****************************************************************'*** Date: Bug: ***'** **'* 10/5/04 While in digital controller mode, the "square" *'* button does not report to the proper bit. a *'* simple change in bit assignment may fix this. *'* 10/5/04 While in digital controller mode, serial output *'* timings are distorted. Delays in program and *'* controller interference may be culprits. *'* Fixed - output format change fixed problem. *'** **'*** ***'****************************************************************

include "modedefs.bas" 'used for mode definitions

Define OSC 4 'clock frequency is 4mhz

20

Page 21: Nathan Roseborrough

'****************************************************************'* Chip Configuration *'****************************************************************'* Configure registers specific to the 16F676. This is vital *'* since the on-board peripherals (comparator, A/D conv.) can *'* interfere horribly with digital I/O. *'****************************************************************OPTION_REG = OPTION_REG | %10000000 'enable porta weak pull-up resistorsADCON0 = %00000000 'disable analog to dig convertersANSEL = %00000000 'select digital mode for a/d pinsCMCON = %00000111 'disable comparitor mode on port ATRISA = %00000010 'set up PortA.1 as an inputWPUA = %00000011 'turn on porta.0 and 1 resistorsTRISC = %00010001 'port c direction register

'****************************************************************'* I/O Pin Aliases *'****************************************************************'* Making plain-english aliases to the physical pins eases *'* programming and allows changes to pin numbers without further*'* modification of the source code (e.g. porting to a different *'* target PIC device) *'****************************************************************SerialOut VAR PORTA.0 'serial out to targetCData var PORTA.1 'Controller Data inCommand var PORTC.1 'Command OutATT VAR PORTC.2 'Attention PinClock VAR PORTC.3 'ClockACK VAR PORTC.4 'Acknowledge pin

'****************************************************************'* Variable Declarations *'****************************************************************

clockdelay con 2 'delay constant for serial transmissiondeadzone con 20 'thumbstick deadzoneButtons VAR BYTE 'to optimize compilation, bits are part of a larger bytedpad_up var Buttons.0 'direction pad updpad_down var Buttons.1 'direction pad downdpad_left var Buttons.2 'direction pad leftdpad_right var Buttons.3 'direction pad righttriangle var Buttons.4 'triangle buttonX var Buttons.5 'X buttonsquare var Buttons.6 'square buttoncircle var Buttons.7 'circle buttonTriggers Var Byte 'triggers encompases the remaining buttonsselct var Triggers.0 'select buttonstart var Triggers.1 'start buttonlt1 var Triggers.2 'left trigger 1lt2 var Triggers.3 'left trigger 2rt1 var Triggers.4 'right trigger 1rt2 var Triggers.5 'right trigger 2pushdown_l var Triggers.6 'analog stick pushdown buttons

21

Page 22: Nathan Roseborrough

pushdown_r var Triggers.7LanY var byte 'left analog stick y axisLanX var byte 'left analog stick x axisRanY var byte 'right analog stick y axisRanX var byte 'right analog stick x axiscont_id var byte 'controller identifier byteinbuffer var byte 'playstation input bufferoutbuffer var byte 'playstation output bufferI var BYTE 'integer used in loops

'****************************************************************'* Main Program Start *'****************************************************************

'****************************************************************'* Power on initialization *'****************************************************************'* Variables are initialized and the clock and attention pins *'* are pulled high to prepare for communication. *'****************************************************************Initialize: Buttons = $FF 'All buttons are active low Triggers = $FF 'Set initial state as no buttons pressed LanX = $80 LanY = $80 RanX = $80 RanY = $80 high ATT 'Attention goes low when data is sent/received high clock 'the data is read on the rising edge of the clock, idle high pauseus(clockdelay) 'pause for a moment for the PSX controller pauseus(clockdelay) pauseus(clockdelay) inbuffer = $00 'initialize input buffer outbuffer = $00 'initialize output buffer'****************************************************************'* Controller Polling Routine *'****************************************************************'* The controller is polled for its type and the program *'* branches to the appropriate processing routine. *'**************************************************************** Poll: low ATT 'pull ATT low to get controllers attention outbuffer = $01 'buffer the start command gosub readwrite 'send start command with readwrite routine outbuffer = $42 'buffer the data request command gosub readwrite 'send buffer command cont_id = inbuffer 'received byte is controller identifier outbuffer = $FF 'set output buffer to idle state gosub readwrite 'this should return $5A in the input buffer if cont_id = $41 then digital 'setup for digital controller (has no analog sticks) if cont_id = $23 then negcon 'negcon controller (steering wheel?) if cont_id = $73 then analog 'standard analog controller in red mode if cont_id = $53 then analog 'these are so similar that they can use the same routine high ATT 'if controller id was bad or wasnt available, lose attention pauseus(clockdelay) 'pause (may not be necessary

22

Page 23: Nathan Roseborrough

pauseus(clockdelay) pauseus(clockdelay) goto Poll 'if identifier was invalid, keep retrying

'****************************************************************'* Digital Controller Mode *'****************************************************************'* This is the simplest controller type, consisting of only *'* digital input buttons. The states of the buttons are read *'* and the button bits are assigned. Buttons are active low. *'**************************************************************** digital: gosub readwrite 'input the first word selct = inbuffer.0 'set variables to proper state start = inbuffer.3 dpad_up = inbuffer.4 dpad_right = inbuffer.5 dpad_down = inbuffer.6 dpad_left = inbuffer.7 gosub readwrite 'input the second word lt2 = inbuffer.0 'again parse word to attain button states rt2 = inbuffer.1 lt1 = inbuffer.2 rt1 = inbuffer.3 triangle = inbuffer.4 circle = inbuffer.5 X = inbuffer.6 square = inbuffer.7'<============= ERROR HERE!! pauseus(clockdelay) high ATT 'Pull ATT up since it is the end of command goSUB packet_out 'output the packetgoto Poll 'rinse, repeat, wipe hands on pants

'****************************************************************'* Steering Wheel Controller Mode *'****************************************************************'* The playstation steering wheel has inputs similar to the *'* analog controller. While unique, this is still a viable *'* input device. *'****************************************************************negcon: 'This section is for the usage of the steering wheel controller 'No support at this timegoto poll

'****************************************************************'* Analog Controller Mode *'****************************************************************'* This is the most popular controller type and is most *'* recommended for robot control applications. The buttons *'* present on the digital controller are augmented by two *'* bi-axis analog thumb sticks. *'****************************************************************analog: gosub readwrite 'get first byte

23

Page 24: Nathan Roseborrough

selct = inbuffer.0 'parse input byte pushdown_l = inbuffer.1 pushdown_r = inbuffer.2 start = inbuffer.3 dpad_up = inbuffer.4 dpad_right = inbuffer.5 dpad_down = inbuffer.6 dpad_left = inbuffer.7 gosub readwrite 'get second byte lt2 = inbuffer.0 rt2 = inbuffer.1 lt1 = inbuffer.2 rt1 = inbuffer.3 triangle = inbuffer.4 circle = inbuffer.5 X = inbuffer.6 square = inbuffer.7 gosub readwrite 'get third byte RanX = inbuffer 'the entire byte is an 8-bit position gosub readwrite 'get fourth byte RanY = inbuffer gosub readwrite 'fifth byte LanX = inbuffer gosub readwrite 'sixth byte LanY = inbuffer gosub calibrate gosub packet_out 'go to output stagegoto Poll 'Lather, rinse, repeat

'****************************************************************'* Calibration Routine *'****************************************************************'* This routine adjusts the analog values to the center position*'* if they are within tolerence of the deadzone. This prevents *'* creep issues that would need to be fixed with trim. *'****************************************************************calibrate: if RanX < ($80 + deadzone) and RanX > ($80 - deadzone) then RanX = $80 if RanY < ($80 + deadzone) and RanY > ($80 - deadzone) then RanY = $80 if LanX < ($80 + deadzone) and LanX > ($80 - deadzone) then LanX = $80 if LanY < ($80 + deadzone) and LanY > ($80 - deadzone) then LanY = $80 return

'****************************************************************'* Output Routine *'****************************************************************'* This routine formats the data from the controller and formats*'* it for usage by the target. Eventually this will control a *'* transmitter system. *'****************************************************************packet_out: serout SerialOut,N1200,[cont_id,Buttons,Triggers,LanX,LanY,RanX,RanY,13,10] return

24

Page 25: Nathan Roseborrough

'****************************************************************'* Playstation Communication Routine *'****************************************************************'* The playstation controller uses an asynchronous communication*'* protocol. This routine both sends and receives data from the*'* controller bit by bit, LSB first. *'* Data is passed between this subroutine and the main program *'* by way of the variables inbuffer and outbuffer. *'****************************************************************readwrite: inbuffer = $00 for I = 0 to 7 low Clock 'pull clock low for setup stage if (outbuffer & %00000001) = %00000001 then high Command 'set command pin high if LSB is high else Low Command endif pauseus(clockdelay) 'pause for setup time high Clock 'set clock to high for read stage pauseus(clockdelay) 'pause for read time if CData = 1 then 'read the pin state and place it in the MSB inbuffer = inbuffer | %10000000 'put Ith bit of the input data into the input buffer else inbuffer = inbuffer & %01111111 endif pauseus(clockdelay) if (I != 7) then 'only do this for the first 7 bits inbuffer = inbuffer >> 1 'shift input buffer to right for next bit outbuffer = outbuffer >> 1 'do the same for the outbuffer endif Next I return

25

Page 26: Nathan Roseborrough

APPENDIX B:

SONY PLAYSTATION®

CONTROLLER INFORMATIONWhat you will find here

The Playstation Controller Pinouts The PSX Controller Signals The PSX Controller Data A Circuit to Emulate a PSX Controller in 74XX Logic A Microcontroller to Emulate a PSX Controller

The Playstation Controller Pinouts

LOOKING AT THE PLUG ------------------------------- PIN 1->| o o o | o o o | o o o | \_____________________________/

PIN # USAGE 1. DATA2. COMMAND3. N/C (9 Volts unused)4. GND5. VCC6. ATT7. CLOCK8. N/C9. ACK

DATASignal from Controller to PSX.This signal is an 8 bit serial transmission synchronous to the falling edge of clock (That is both the incoming and outgoing signals change on a high to low transition of clock. All the reading of signals is done on the leading edge to allow settling time.)

COMMANDSignal from PSX to Controller.This signal is the counter part of DATA. It is again an 8 bit serial transmission on the falling edge of clock.

VCCVCC can vary from 5V down to 3V and the official SONY Controllers will still operate. The controllers outlined here really want 5V.

26

Page 27: Nathan Roseborrough

The main board in the PSX also has a surface mount 750mA fuse that will blow if you try to draw to much current through the plug (750mA is for both left, right and memory cards).

ATTATT is used to get the attention of the controller.This signal will go low for the duration of a transmission. I have also seen this pin called Select, DTR and Command.

CLOCKSignal from PSX to Controller.Used to keep units in sync.

ACKAcknowledge signal from Controller to PSX.This signal should go low for at least one clock period after each 8 bits are sent and ATT is still held low. If the ACK signal does not go low within about 60 us the PSX will then start interogating other devices.

It should also be noted that this is a bus of sorts. This means that the wires are all tied together (except select which is seperate for each device). For the CLK, ATT, and CMD pins this does not matter as the PSX is always the originator. The DATA and ACK pins however can be driven from any one of four devices. To avoid contentions on these lines they are open collectors and can only be driven low.

The PSX Controller Signals

All transmissions are eight bit serial LSB first. All timing in the PSX controller bus is syncronous to the falling edge of the clock. One byte of the transmissions will look kinda like this. |BIT 0|BIT 1|BIT 2|BIT 3|BIT 4|BIT 5|BIT 6|BIT 7| CLOCK -----___---___---___---___---___---___---___---___-----------

DATA -----000000111111222222333333444444555555666666777777-------- * * * * * * * * CMND -----000000111111222222333333444444555555666666777777--------

ACK ----------------------------------------------------------__-

The logic level on the data lines is changed by the transmitting device on the falling edge of clock. This is then read by the receiving device on the leading edge (at the points marked *) allowing time for the signal to settle. After each COMMAND is recieved by a selected controller, that controller needs to pull ACK low for at least one clock tick. If a selected controller does not ACK the PSX will assume that there is no controller present.

When the PSX wants to read information from a controller it pulls that devices ATT line low and issues a start command (0x01). The Controller Will then reply with its ID (0x41=Digital, 0x23=NegCon, 0x73=Analogue Red LED, 0x53=Analogue Green LED). At the same time as the controller is sending this ID byte the PSX is transmitting 0x42 to request the data. Following this the COMMAND line goes idle and the controller transmits 0x5A to say "here comes the data".

27

Page 28: Nathan Roseborrough

This would look like this for a digital controller ATT -______________________________________________________________ | Byte 1 | | Byte 2 | | Byte 3 | CLOCK ---_-_-_-_-_-_-_-_-----_-_-_-_-_-_-_-_-----_-_-_-_-_-_-_-_----- 0xFF 0x41 0x5A DATA -------------------------__________--__----__--__----__--__---- 0x01 0x42 CMND -----_____________-----__--________--__------------------------

ACK --------------------__-------------------__-----------------__-

After this command initiation proccess the controller then sends all its data bytes (in the case of a digital controller there is only two). After the last byte is sent ATT will go high and the controller does not need to ACK.

The data transmision for a digital controller would look like this (where A0,A1,A2...B6,B7 are the data bits in the two bytes). ATT _______________________________________------- | Byte 4 | | Byte 5 | CLOCK ---_-_-_-_-_-_-_-_-----_-_-_-_-_-_-_-_--------

DATA ---D0D1D2D3D4D5D6D7----E0E1E2E3E4E5E6E7-------

CMND ---------------------------------------------- *** ACK --------------------__------------------------

NOTE: No ACK.

The PSX Controller Data

Below are five tables that show the actual bytes sent by the controllers Standard Digital Pad

BYTE CMND DATA

01 0x01 idle 02 0x42 0x41 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data SLCT STRT UP RGHT DOWN LEFT 05 idle data L2 R2 L1 R1 /\ O X |_|

All Buttons active low.

28

Page 29: Nathan Roseborrough

NegCon

BYTE CMND DATA

01 0x01 idle 02 0x42 0x23 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data STRT UP RGHT DOWN LEFT 05 idle data R1 A B 06 idle data Steering 0x00 = Right 0xFF = Left 07 idle data I Button 0x00 = Out 0xFF = In 08 idle data II Button 0x00 = Out 0xFF = In 09 idle data L1 Button 0x00 = Out 0xFF = In

All Buttons active low. Analogue Controller in Red Mode

BYTE CMND DATA

01 0x01 idle 02 0x42 0x73 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data SLCT JOYR JOYL STRT UP RGHT DOWN LEFT 05 idle data L2 R2 L1 R1 /\ O X |_| 06 idle data Right Joy 0x00 = Left 0xFF = Right 07 idle data Right Joy 0x00 = Up 0xFF = Down 08 idle data Left Joy 0x00 = Left 0xFF = Right 09 idle data Left Joy 0x00 = Up 0xFF = Down

All Buttons active low. Analogue Controller in Green Mode

BYTE CMND DATA

01 0x01 idle 02 0x42 0x53 03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 04 idle data STRT UP RGHT DOWN LEFT 05 idle data L2 L1 |_| /\ R1 O X R2 06 idle data Right Joy 0x00 = Left 0xFF = Right 07 idle data Right Joy 0x00 = Up 0xFF = Down 08 idle data Left Joy 0x00 = Left 0xFF = Right 09 idle data Left Joy 0x00 = Up 0xFF = Down

All Buttons active low.

29

Page 30: Nathan Roseborrough

PSX Mouse

(credit to T.Fujita

http://www.keisei.tsukuba.ac.jp/~kashima/games/ps-e.txt)

BYTE CMND DATA

01 0x01 idle

02 0x42 0x12

03 idle 0x5A Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7

04 idle 0xFF

05 idle data L R

06 idle data Delta Vertical

07 idle data Delta Horizontal

All Buttons active low.

© 1998 Andrew J McCubbin

Maintained by [email protected]

Last Updated August 13, 1998.

This pages URL is HTTP://home.quicknet.com.au/andrewm/electron/psxcont.html

30

Page 31: Nathan Roseborrough

APPENDIX C:

#include <msp430x44x.h> // MSP430F449 Declarations

#include "LCD449.h" // Must be included to use LCD functions

//(also don't forget to add LCD449.c file in your project workspace

before compiling)

#include "buzzer449.h" // code for buzzer to work on this kit

/* ---------------------------------------------- Function Declarations --------------------------------------*/

// Note: Interrupt function routines don't have function declarations

void makeString(int long number, char format[], int display);

void tune_frequency(int offset);

/* ---------------------------------------------- Global Variables ------------------------------------------*/

// variables for the main function

int channel_matrix[31][10] = { // 0 1 2 3 4 5 6 7 8 9

current_channel consequence

/* 0 */ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0

-> No output

/* 1 */ {0x01,0x6B,0x41,0xC3,0x78,0x01,0x6B,0x45,0x3E,0x20}, // 1

-> Ch 61 / 75.415 MHz / 75.425 MHz

/* 2 */ {0x01,0x6B,0x49,0x0B,0x9B,0x01,0x6B,0x4C,0xDF,0x40}, // 2

-> Ch 62 / 75.435 MHz / 75.445 MHz

31

Page 32: Nathan Roseborrough

/* 3 */ {0x01,0x6B,0x50,0x53,0xBE,0x01,0x6B,0x54,0x80,0x60}, // 3

-> Ch 63 / 75.455 MHz / 75.465 MHz

/* 4 */ {0x01,0x6B,0x57,0x9B,0xE0,0x01,0x6B,0x5B,0x3F,0xF1}, // 4

-> Ch 64 / 75.475 MHz / 75.485 MHz

/* 5 */ {0x01,0x6B,0x5E,0xE4,0x03,0x01,0x6B,0x62,0x88,0x14}, // 5

-> Ch 65 / 75.495 MHz / 75.505 MHz

/* 6 */ {0x01,0x6B,0x66,0x2C,0x25,0x01,0x6B,0x69,0xD0,0x37}, // 6

-> Ch 66 / 75.515 MHz / 75.525 MHz

/* 7 */ {0x01,0x6B,0x6D,0x74,0x48,0x01,0x6B,0x71,0x18,0x59}, // 7

-> Ch 67 / 75.535 MHz / 75.545 MHz

/* 8 */ {0x01,0x6B,0x74,0xBC,0x6A,0x01,0x6B,0x78,0x60,0x7C}, // 8

-> Ch 68 / 75.555 MHz / 75.565 MHz

/* 9 */ {0x01,0x6B,0x7C,0x04,0x8D,0x01,0x6B,0x7F,0xA8,0x9E}, // 9

-> Ch 69 / 75.575 MHz / 75.585 MHz

/* 10 */ {0x01,0x6B,0x83,0x4C,0xB0,0x01,0x6B,0x86,0xF0,0xC1}, // 10

-> Ch 70 / 75.595 MHz / 75.605 MHz

/* 11 */ {0x01,0x6B,0x8A,0x94,0xD2,0x01,0x6B,0x8E,0x38,0xEF}, // 11

-> Ch 71 / 75.615 MHz / 75.625 MHz

/* 12 */ {0x01,0x6B,0x91,0xDC,0xF5,0x01,0x6B,0x95,0x81,0x06}, // 12

-> Ch 72 / 75.635 MHz / 75.645 MHz

/* 13 */ {0x01,0x6B,0x99,0x25,0x17,0x01,0x6B,0x9C,0xC9,0x29}, // 13

-> Ch 73 / 75.655 MHz / 75.665 MHz

/* 14 */ {0x01,0x6B,0xA0,0x6D,0x3A,0x01,0x6B,0xA4,0x11,0x4B}, // 14

-> Ch 74 / 75.675 MHz / 75.685 MHz

32

Page 33: Nathan Roseborrough

/* 15 */ {0x01,0x6B,0xA7,0xB5,0X5D,0x01,0x6B,0xAB,0x59,0x6E}, //

15 -> Ch 75 / 75.695 MHz / 75.705 MHz

/* 16 */ {0x01,0x6B,0xAE,0xFD,0x7F,0x01,0x6B,0xB2,0xA1,0x90}, // 16

-> Ch 76 / 75.715 MHz / 75.725 MHz

/* 17 */ {0x01,0x6B,0xB6,0x45,0xA2,0x01,0x6B,0xB9,0x39,0xB3}, // 17

-> Ch 77 / 75.735 MHz / 75.745 MHz

/* 18 */ {0x01,0x6B,0xBD,0x8D,0xC4,0x01,0x6B,0xC1,0x31,0xD6}, //

18 -> Ch 78 / 75.755 MHz / 75.765 MHz

/* 19 */ {0x01,0x6B,0xC4,0xD5,0xE7,0x01,0x6B,0xC8,0x79,0xF8}, // 19

-> Ch 79 / 75.775 MHz / 75.785 MHz

/* 20 */ {0x01,0x6B,0xCC,0x1E,0x0A,0x01,0x6B,0xCF,0xC2,0x1B}, // 20

-> Ch 80 / 75.795 MHz / 75.805 MHz

/* 21 */ {0x01,0x6B,0xD3,0x66,0x2C,0x01,0x6B,0xD7,0x0A,0x3D}, //

21 -> Ch 81 / 75.815 MHz / 75.825 MHz

/* 22 */ {0x01,0x6B,0xDA,0xAE,0x4F,0x01,0x6B,0xDE,0x52,0x60}, // 22

-> Ch 82 / 75.835 MHz / 75.845 MHz

/* 23 */ {0x01,0x6B,0xE1,0xF6,0x71,0x01,0x6B,0xE5,0x9A,0x83}, // 23

-> Ch 83 / 75.855 MHz / 75.865 MHz

/* 24 */ {0x01,0x6B,0xE9,0x3E,0x94,0x01,0x6B,0xED,0xE2,0xA5}, // 24

-> Ch 84 / 75.875 MHz / 75.885 MHz

/* 25 */ {0x01,0x6B,0xF0,0x86,0xB6,0x01,0x6B,0xF4,0x2A,0xC8}, // 25

-> Ch 85 / 75.895 MHz / 75.905 MHz

/* 26 */ {0x01,0x6B,0xF7,0xCE,0xD9,0x01,0x6B,0xFA,0xD2,0x80}, // 26

-> Ch 86 / 75.915 MHz / 75.925 MHz

33

Page 34: Nathan Roseborrough

/* 27 */ {0x01,0x6B,0xFF,0x66,0x60,0x01,0x6C,0x02,0xBB,0x0D}, // 27

-> Ch 87 / 75.935 MHz / 75.945 MHz

/* 28 */ {0x01,0x6C,0x06,0x5F,0x1E,0x01,0x6C,0x0A,0x03,0x30}, // 28

-> Ch 88 / 75.955 MHz / 75.965 MHz

/* 29 */ {0x01,0x6C,0x0D,0xA7,0x41,0x01,0x6C,0x11,0x4B,0x52}, // 29

-> Ch 89 / 75.975 MHz / 75.985 MHz

/* 30 */ {0x01,0x6C,0x14,0xEF,0x63,0x01,0x6C,0x18,0x93,0x75}, // 30

-> Ch 90 / 75.995 MHz / 76.005 MHz

};

int current_channel = 0;

int W0 = 0;

int W1 = 1;

int W2 = 2;

int W3 = 3;

int W4 = 4;

#define RESET BIT1;

#define FQ_UD BIT2;

#define W_CLK BIT3;

// variables for the DIPSWICTHES interrupt subroutine

int dip_channel = 0;

int dip[6] = {0,0,0,0,0,0};

int dip_flag = 0;

34

Page 35: Nathan Roseborrough

/* ---------------------------------------------- Main function ----------------------------------------------*/

void main(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

initLCD(); // These functions must be provided for the LCD to work

clearLCD();

/* LCD */// writeSentence("DEMONSTRATION PROGRAM. INITIALIZING SYSTEM

PARAMETERS.",0);

35

Page 36: Nathan Roseborrough

APPENDIX D:

Milled prototypes of transmitter and reciever

36

Page 37: Nathan Roseborrough

APPENDIX E:

Transmitter Schematic

37

Page 38: Nathan Roseborrough

APPENDIX F:

Amplifier biasing data

Amplifier 1

Amplifier 2

RefRef -3dBm

0 -21.05 -29 75.0mhz0.2 -21.02 -290.4 -21.02 -290.6 -21.05 -290.8 -21.05 -29

1 -21.05 -291.2 -21.43 -29.11.4 -24.5 -31.11.6 -37.12 -37.91.8 -26.1 -38.9

2 -19.3 -29.72.2 -15.5 -25.12.4 -13.36 -22.22.6 -12.03 -20.72.8 -11.45 -20.02

3 -11.2 -19.83.2 -11.08 -19.83.4 -11 -19.013.6 -5.93 -17.83.8 -2.37 -15.06

4 0.11 -8.334.2 3.5 -3.74.4 5.14 -0.444.6 6.21 2.074.8 7.5 3.93

5 7.7 5.595.2 7.55 6.885.4 9.63 7.845.6 10.07 8.745.8 9.85 9.46

6 10.14 10.256.2 9.53 10.56.4 10.61 10.986.6 11.1 11.446.8 11.57 11.69

7 12.13 11.977.2 11.57 12.257.4 11.35 12.567.6 9.38 12.567.8 9.23 12.84

8 9.23 12.84

38

Page 39: Nathan Roseborrough

39