Reviving an old inaccurate analog joystick
to a modern,accurate and a capable,
Before we start…
As this is my first blog,especially about technical stuff,i appreciate your ‘patience’ with my way of explaining something or for any vocabulary mistakes.I’ve tried my best to simplify the whole process so that it’s easier to follow and understand.Every info’s in this post are correct by the time it was written.Any corrections,feedback’s are humbly welcomed by the author…of course,me!😀
RessJoy was created to understand how the USB HID Class works (in this case as gamecontrollers).An old analog joystick (which was given to me as a gift from my friends when i was 15..no idea with the brand) was used for the application.The old joystick that has 2-Axis (X,Y),Throttle,4 buttons & an AUTO Function (no idea what’s it for??) connects to the host with a gameport connector.
Unfortunately,the days of gameport connectors have long gone,even applies to serial & parallel ports as well.Interested in knowing how the USB HID Class works in a real world environment,i decided to convert this old joystick to a new,’Pimped’ up USB Joystick that can perform way better than it used to be.And Voila!Came RessJoy!What is USB HID Class?.What’s the purpose?
USB functionality is defined by it’s class codes.In order to understand what it stands for,please visit USB.org for more information’s.If you plan to develop further USB applications ,i recommend you to purchase this book titled “USB Complete” from Jan Axelson.It’s a fantastic book to refer & to keep for guidance.
USB HID (Human Interface Device) is a part of USB specifications which is used to identify computer peripherals.It’s used to specify a device class ( type of hardware) for interfacing.Some of the famous examples would be keyboards,mice,game controllers…the list goes on.For some specific devices,a device driver will be provide together with the hardware but most of the standard consumer products will be supported automatically since the OS will have the driver included.So when you plug in your device,in this case RessJoy,the OS will detect**,search for the related drivers & pair it according to it’s device class.
** – Refer Expected Problems.
So what’s inside the RessJoy.Tell us about the Hardware’s?
RessJoy has been slightly modified to accommodate for more functions.Old wires & circuits have been completely removed to give in for new,built in hardware.Figure 1 shows the positions of buttons & potentiometers.The new joystick accommodates four more buttons & 3 more Axis since the hardware is capable to do so.
TARGET RESET & BOOTLOAD/RUN functions are still in progress.This is to enable & provide learning opportunity about USB Bootloaders with the fraction of cost & time.The USB Bootloading method can be used to create new applications with using the same hardware or even upgrade the existing firmware without the need of dedicated programmer & messy wires.Mechanical stress on IC can be avoided as well since,through the USB Bootloading method,one can avoid removing the IC from the IC Socket & place it in the ZIP package.Even extra designs for ICSP can be avoided too.
The EXP(S) stands for Expansion Serial.This connection enables the RessJoy to have more Axis or Buttons through serial communications with other microcontrollers which is attached with more switches (buttons) & potentiometers (Axis,Hut..).Another purpose for this connection is to enable Debugging for the joystick.However,a level converter is required in order for it to communicate with the host(computer) when Debugging.The physical connections are made with Sub-D IDC connectors (Figure 2).Again,the above mentioned functions are still in progress.Maybe…i will save it for another version ; D.
What are the modification made inside the RessJoy to fit the new hardware?
Well,minimal modification were made inside the joystick as the size of the new hardware is small & in simple form.Figure 3.shows a simple view of top & bottom part.
Figure 3.(Click to enlarge)
Figure 4. display the modifications done in order to fit in the new hardware.Only 2 molded latches were removed as it clashes with the new hardware mountings.Couple of holes were drilled to mount Led’s & potentiometers and indirectly for ventilation (guess it does…LOL!)
Figure 4.(Click to enlarge)
How about the Electrical connections?
Taking info’s from Figure 4.,there are 2 types of wires used in this project.Stripped ribbon cables were used to carry analog signals to the controller board.Although twisted wire method was planned at the first place,i felt it’s not that important since the distance between the controller board & the pot’s which is soldered with 0.1uF caps, are quiet near (less than 3 inches).Further testing by powering the pot’s with USB power supply reveals that the pot’s are able to provide stable analog signals without to much drift (maybe the pot’s are in good shape or well made..) & less susceptible to temperature change (took the reading by closing the joystick back to one piece for an hour..no idea about leaving it for more than a week!😀 ).The buttons are wired with multicore wires.Electronics?
RessJoy V.10 Schematic (Click to enlarge)
The main part in this interface board is the midrange Microchip PIC18F2550 -A.Personally,i choose this micro because (besides i bought couple of it to play around) it has a built in hardware USB with endpoints support.Apart from it,this micro carries other attributes of hardware peripherals as well such as 10 -Bits resolution ADC,which is used to capture & process analog signals from the potentiometers,GPIO for detecting buttons press & to turn On and Off the Led’s,USART for Serial Expansion & Debugging (in progress) and so on..This micro is also featured with an on board PLL generator which reduces overall RF interference by using low frequency resonators, consumes very little power & saves footprints as well.A digital to analog power supply are designed with an inductor & a tantalum capacitor to power the analog potentiometers which separates from digital power supply to increase efficiency & to eliminate interference in the circuit.The rest of the discreet components can be viewed in the schematics.
*NOTE*-Basic design knowledge is expected from the viewer.
Figure.5 shows the corresponding use of the pinheads.The analog signals is processed on the left side of the board while the digital signals are on the right.This gives an advantage in reducing SNR (Signal To Noise Ratio) as the pinheads were placed near to the dedicated ADC port pins.
Now the Software part..
The PicBasicPro,MPLAB & the EasyHID Wizard..
This project was developed & compiled in microEngineering Labs PicBasicPro.Although i plan to do it in a C-compiler (for better manipulations),i changed my mind & plan to study how USB functions work in an embedded BASIC language.Furthermore,it’s also easier & straightforward to work in a PBP language and more importantly,will be easier for the beginners to understand.Another thing is,PBP can be seamlessly used in a MPLAB environment.This project was compiled in a PBP Version 2.47* & MPLAB V.7.4* .Referring related files in the RessJoy.zip will help you to get the clear picture.
The USB related files are generated through EasyHID Wizard which is part of the MicroCode Studio IDE.This wizard is absolutely easy to understand & to use.However it’s only valid for testing and it’s more than enough to develop RessJoy.The EasyHID Wizard will produce 2 different folders for different targets.One folder will be for the microcontroller while another for host.The files generated for host side is to allow custom manipulations of data’s from the microcontroller which in this project is not used.Referring related files in the RessJoy.zip will help you to get the clear picture.
* – This is the only version i have.After this i’ve moved completely to C.Not tested in newer versions.
DESC and the USB DT-HID Descriptor Tool.
If you want to develop USB HID applications,you need to prepare the right data’s to be moved in the right order from the slave to the master (host).This is the most important part in the process because that’s how the host will identify the hardware type when connected.In order to simplify & create the HID descriptor file, USB.org have came up with a software to lift the burden.Figure.6 shows the software in action.This software makes the development of descriptor file much faster & easier.Numerous examples were included in order to help the new comers in USB developments to understand better.For more information’s about how to use & develop in this software,please refer USB.org as it will be really-really long for me to explain it in here.Perhaps,i might start a new post to ‘explain’ &’ show how’ in the future : D.
DESCRessJoy,in the RessJoy folder, is a good example to refer how it works.I use HID Descriptor Tool (DT) to figure out and later insert it manually inside the DESCRessJoy file.In the DESCRessJoy,the first & the middle part in the file represents Endpoint zero buffer size (default data),Number of Endpoints,Current draw,polling time & so on.After that,Report Descriptors ,which is the part you will define about what type of hardware & data will be transferred.And the final parts in the file represents your product name & stuff like that.It takes a while to understand what each of them do but hey…it ain’t rocket science!.😀
Testing in action!
(Click to enlarge)
Watch the Video…
Watch it here ≥ RessJoy in YouTube (Xp,Vista,JXInput,Linux)
Please keep in mind that this device might encounter connection conflict with other devices such as PICKIT or any Microchip USB related devices.The conflict might prohibit you from using RessJoy.
In short,RessJoy features :
- HEAVILY expandable through Serial Communication(Needs slight adjustments in DESCRessJoy.In progress).
- Powered through USB.No more parasitic or separate power supply required.
- Compiled using Microengineeringlabs PicBasicPro.
- Microchip PIC18F2550 was selected for it’s USB endpoints support + hardware peripherals.
- Normal Carbon Potentiometer(50K) is used for Axis.
- Original tact switches inside the Joystick are modified to suit the new hardware.
- Premium quality switches is used as extra buttons.
- 1 Led represents Fault where,if one of the Pots failed it will turn on the Led (Experimental).
- 2 Led’s represents Pilots,which will turn On if any of the buttons is pressed(to check button failures as well).
- 1 Led for Power indicator.
- 2 separate tact switches-one to enter Bootloading mode & another for Target Reset(MCLR)(Still in progress).
- Dualrow,5 pin pinheads which is attached to PIC’s USART pins for Debugging & expansion(Daisy Chaining)(Requires Level Converters for debugging)(Still in progress).
Hmm…lots of it…
- USB Bootloader.
- Replacing carbon pots to wirewounds or even to a new level by using magnetic encoders for higher resolutions.
- Use bigger PIC micro (Ex:PIC18F4550 or greater).
- Enabling Serial Expansion ,using I2C to access more pins & axis..
- Going wireless!
- Improving firmware (auto calibration or even self learning joystick!!).
- Completely going to another level by having Force Feedback.
- Using IMU with Kalman Filtering.😀
- Hmmm….what else…care to share??😀
- Or maybe another version of RessJoy?😀
Download:Press here to download.
http://www.starlino.com/usb_gamepad.html – Nice site.
http://helmpcb.com/electronics/usb-joystick – In mikroC.
http://www.usb.org/developers/hidpage/ – HID tool.
“USB Complete” – By Jan Axelson.