Zedomax DIY121 – How to make your own “PS3 SIXAXIS controller” style BASIC-programmable USB device!

video://www.youtube.com/watch?v=gIlhhBVr8Fk

USB devices are easy for users to install and set up (as long as everything is working correctly). Often, you just plug in a USB device and it works immediately. This is especially true for input devices, such as mice and keyboards.

Those devices conform to a specification layered on top of the USB protocol: Human Interface Device. Almost any possible type of input is defined; an entire “report descriptor” language is used to tell the computer how to process the input. This is not very simple to implement; dozens of specific requests must be handled properly. There are many steps between plugging in a USB device and being able to use it; these all take place in a few milliseconds and failure of any step means the device will not work.

What if you didn’t have to worry about any of that? What if you could use your favorite microcontroller, do “something” and the input appears on the computer in the correct format? You wouldn’t have to worry about complex USB code, HID specifications, or breaking your USB code when adding the other functions you need. You wouldn’t have to worry much about writing optimized code, or always getting in the way of USB interrupts.

HID Portal

That’s exactly what I decided to do. A couple of years ago, I developed a USB device and went through all the headaches of getting a USB HID up and running. Since I already had the hard work done, I decided to add a method of receiving data from another microcontroller and using that data as the input stream for the HID code. I wanted to use a Cubloc BASIC-programmable controller to process my input data and send it to the HID Portal. My test application would be an accelerometer-based HID joystick; simply plug the device into the computer and it will work.

It doesn’t have to be a joystick; it could be a keyboard, a mouse, or many other controls defined by the HID standard. It’s possible to add volume control buttons to a device…maybe have a circuit mute your computer when the phone rings? Turn any voltage input into a joystick axis, any switch into a button? Anything is possible!

Update:I decided to shrink the CUBLOC hardware down to a CB220, and fit everything into an airplane model. The model was chosen to match an airplane available in the Heroes of the Pacific game we used to test the joystick interface.

Hardware Explanation

The HID Portal is based on an old project of mine, based on an MC68HC908JB8 microcontroller and programmed in assembly language. For certain reasons I can’t actually release the code right now, but there are plenty of other USB projects out there which could be adapted for this purpose. There’s an open-sourced soft USB implementation for the ATtiny microcontroller, for example.

My microcontroller doesn’t have built-in I2C or SPI, so I needed to implement one of my own. I also didn’t have interrupt pins available, meaning my solution needed to be based on polling. When all was said and done and optimized, I couldn’t detect edges faster than 16Khz. This is about ten times slower than the shift output available from the CUBLOC controller, so I couldn’t use that. I ended up writing my own shift-out routine in BASIC to get the data to the HID Portal. This could be avoided by using a microcontroller that has SPI or I2C built in already, but the JB8 is what I had on hand.

I use three signals to communicate with the CUBLOC controller. First, there is a CLK signal. The HID Portal detects a rising edge. At that point, it reads the value present on the DATA line. This is shifted into a register until a byte has been received, and the code moves to the next byte. The /RST line is a way to synchronize the start of each data packet in case there was any spurious input; when LOW it sets the packet and bit indexes to zero.

The HID Portal is currently programmed to act as a joystick with three axes and eight buttons. I’ve also tested it as a keyboard. In future development, I’d like to make the HID Portal more flexible; let the external controller select the device type and how many of each input are required. It would be the most flexible if it directly accepted HID report descriptors, but that opens up the possibility to make more mistakes and end up with a non-working device.

The accelerometer is a DE-ACCM3D from Dimension Engineering. The CUBLOC simply reads the voltage on its ADIN ports and converts to a value between -127 and 127.

Continued on Next Page

19 Responses to Zedomax DIY121 – How to make your own “PS3 SIXAXIS controller” style BASIC-programmable USB device!

  1. Joe Brock says:

    Am interested in building same/similar type project. Have been fussing with VB.net, and am not into all that.
    Haven’t messed with pic’s (microcontrollers) How to program these for USB port or is that part already done?

  2. Phil says:

    Hey guys awesome project….

    Do you tihnk you could apply similiar process to allow a keyborad and mouse setup to work with PS3 games? What I was thinking was if you knew the output that the controller sends, you oculd use a computer program to simulate a button press when u pressed a button on the keyboard. I.e. when i press the enter key on my keyboard, a program sends the command for “start” to the playstation… any feedback/idea on how one could begin on such a project?

  3. Steve Ellis says:

    i think you are absolutely amazing how can i get in touch with you i have a few questions about a project i am trying to start that i think you may be able to answer my email is ellis90002@gmail.com please email me if you are willing to answer some questions

  4. doesn'tmatter says:

    i saw hjm fidiling with the front of the plane with his left hand all throughout the video

  5. horisly says:

    well.
    i come back to see friend.

  6. max says:

    hey, welcome back horisly! Did the playoffs get to you? hehe…

  7. Napsey says:

    Hi, after crashing my rather expensive model aircraft for the third and final time I figured it was due to the tiny controls on the radio control box that I find difficult to master with my clumsy thumbs at my age. What I need is to to be able to do something like plug a computer joystick into a laptop and let the laptop drive the model aircraft out there in the real world through the buddy-box connection. I could also then place a small remote TV camera in the cockpit which could relay the video feed to the laptop through another port. This would help me fly the aircraft and give me a real view of the world through the model. The next step would be to make the model less crashable with say, a model helicopter gyro installed in the works so that by letting go of the controls, the plane would find its own straight and level. Does this requirement sound too far fetched in the backyard scheme of things?

  8. andy says:

    hey i have a game shark sp with usb cable and was trying to run linux on it but the game shark is HID (tell me how that works) and all i can send is cheats with the cheat program! anyway i can edit the files on the flash on the gameshark?

  9. max says:

    You might want to email the HID expert Garrett at garrett@comfiletech.com

  10. evance says:

    Hi~
    nice DIY

    May I have a question?
    PS3 controller USB Endpoint size is 32Byte ?
    or should use 64Byte ?
    I capture package is 64 byte
    but its seem 32 byte can be work ???

  11. m07 says:

    nice one once again.keep up the good work.

  12. Top Seo Blog says:

    Hope i can make it….. 🙂

  13. max says:

    yes do make it! I didn’t even try…

  14. Mike Touch says:

    Wow this is great!
    Brilliant idea, well done.

  15. Clint Fishburne says:

    Awsome and it is just what I have been looking for. Can I buy one assembled?

  16. name002 says:

    Could I go direct from computer to console? I'd like to toy with interfacing the controller with a custom program I would right..

  17. name002 says:

    Could I go direct from computer to console? I'd like to toy with interfacing the controller with a custom program I would right..

  18. boobs mghee says:

    I look like I have aids and smell of corn…

Leave a Reply

Your email address will not be published.