Control an Xbox 360 controller analog stick

I have the Uno and I'm trying to wire the buttons and joysticks of an Xbox 360 controller to it so that I can use the Arduino to control the controller (which will be wirelessly connected to the Xbox). I've figured out how to get the buttons to work, that was simple enough (IO pin to a resistor to the base lead of a 2N3906 transistor, positive button pad to the collector, negative button pad to the emitter, pull the pin low to "push" the button), but I'm having a hard time getting the analog sticks to work. The sticks are just pots used as voltage dividers. Looking at the front of the controller, the left pin is positive, middle is the wiper, and right is ground. The voltage at the wiper is how the Xbox decides how far to the left or right the stick is pushed. I tested the leads with a multimeter and found that there is 1.5V going across the pot, but since it's just a voltage divider, voltage doesn't really matter at all. I soldered a wire to the middle lead (without removing the pot itself) and connected it to a PWM pin and wrote a value of 127 to it, so it should have read as perfectly centered, but it just completely ignored it. I talked to a buddy of mine and he told me to put a cap between the wiper and ground leads, so I found a 10 nanofarad ceramic disk cap in my parts bin and soldered it in (still leaving the pot in place) then tried again. This time it took the input, but it was really erratic, and it affected the other analog controls (the other axis on the same stick, both axis' on the other stick, and both triggers) in a very sporadic way. I haven't tried it again since I made one last change, but I decided to power the controller using the Arduino by connecting the controller's VCC line to 3.3V and GND on the controller to GND on the arduino. It powers on just fine, the button pressing works fine, but I haven't tried to see if that changed anything with the analog control.

Having read this, is there anything that anyone here can help with. Am I doing things right, or is there a different way I should be going about it? Should I remove the pot completely, or add a resistor in series between the PWM pin and the wiper? Any help or information I can get will be extremely useful. I know quite a bit about electronics, but some things just confuse me, not sure why this is, but it is.

Anywho, thanks in advance!

a few points.

  1. using analog write for a value of 127 is a duty cycle of 50%. NOT the same as the middle of a pot.

  2. the voltage into the pot absolutly makes a difference in what you need to make your controller work.

  3. a digital pot induces much less noise and a smoother transition than you will see with filtered pwm.

the controller processor is expecting a voltage sweep from 0 volts to 1.5 volts according to your information so the sweeper of the pot should sit at .75 at null. the best way to do this ,that I know of, is a digital pot.

I know a guy who got a wiimote to work with his xbox 360 using this method and he said it was very
smooth with the digital pot using the tap in method you are describing.

digital pot at sparkfun

I did some calculations with a multimeter and setting an analog write value of 80 gave me 1.51V, so I tried sending that to the wiper of the voltage divider and it spun to the right, indicating that the wiper was closer to GND. I set it to 127 and it centered, but jittered, setting it to 255 made it go full spin to the left, 0 made it full spin to the right. No clue why, but that's what's happening. I've read on multiple Xbox hacking forums that the voltage going through the pot really doesn't matter since it's just a voltage divider, replacing the 100k variable resistor with a 1k or a 1m would yield the same results, it's just dividing the voltage, whatever voltage is going from positive to ground, the controller uses it.

Unfortunately I'm not really in a financial situation where I can spend any money getting any extra stuff, even if it is only $1.50. Is there a way to do it without the digital pot?

A multimeter is not your best choice of devices to look at a PWM signal.

Essentially a multimeter takes a sample of voltage data over a small amount of time the shows you the average of that information. A pulsed signal or PWM signal will not show you the high or the low it will show you the average reading over the time of the sample.

PWM as you are sending it to my understanding is directly from the arduino. So the processor that is expecting to see a smooth sweep from 0 to 1.5 volts is actually seeing a TTL level signal (5 Volts that it shouldn't see in any case because the controller run on 3.3 if i am not mistaken).

So instead of a constant voltage the controller is seeing:

505050505500550055005500505050055000055500005555000505500550505050

At no time is this voltage ever in the range the controller wants to see.
*edit: I suppose this statement is incorrect, it doesn't mind seeing the 0 volts..... :-/

This voltage does matter. The resistance (typically) less so. Your statement that a 1K, 100K, or 1M will work is partially correct, but not for the reason you think. The 3 pots you list will take the voltage off the wiper in exactly the same fashion because when the pot is centered up the resistance between the wiper and ground is == to the resistance between the wiper and ground. See this Wiki to understand the principle better Voltage divider - Wikipedia.

Something looking for an analog input may or may not care about the resistance but the voltage absolutely matters unless the 360 controller is doing something completely out of the norm (which is very unlikely as many other people have modded these controllers).

If you take a chip that expects to see an analog voltage, that's what it knows how to handle, and give it the above string of on's and off's it won't be able to decipher that information. That is why there are chips that accept PWM and chips that accept analog in... but rarely is it in one chip and i have never seen one where it is on the same pin.

It may be possible to do with the capacitor to filter the PWM which functionally makes the PWM into an analog voltage as long as you narrow the output voltage into the range the controller is expecting to see. This would involve doing some research on how best to set it up, what resistor you would want in line, and which type/rating of cap will best suite the purpose.

Could you post some links to these multiple forums that say the voltage doesn't matter? I would be very interested in what they are doing to make that statement true.

Personally if I couldn't find 1.50 in the couch to buy a chip and do the job then i would probably postpone until a better time to tackle projects. But that's just me.

Similar issue from the archived forums.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285266211

Ok then, I'll go ahead and get that digital pot from SparkFun, that should be a simpler solution, right? Basically it does the exact same thing that a physical potentiometer does, but can be controlled via digital signals, meaning that I could use the Arduino to set the pot to a specific value between 0 and 1.5V and it would be a real analog signal? The whole reason I'm doing this is because I want very fine control of the sticks, particularly the rotation (right stick/triggers). For my application, I need there to be no chance of bumping the left stick (movement) at all, else I waste a lot of time and have to redo everything. Before I was simply holding the controller and keeping my fingers as far away from the right stick and triggers as possible, but my hand starts to cramp holding the controller like that, so I want to be able to control it from the computer. Plus, writing some macros would be nice.

At any rate, that digital pot you linked would be the way to go?

Edit: From what I've read, the pots in the controller are linear 10k, but I used a multimeter, set to the 20k setting, to test the resistance between the two outer leads and I got a reading of 1.5 (which I assume means 1.5k, since the meter was set to the 20k setting). I tested between the right and middle leads, then the left and middle leads and got a reading of 4.1k then tested the left and middle leads and got 3.3k. That doesn't make any sense to me. I'm 100% positive I wasn't pushing the sticks at all, I had the thing clipped in my helping hands tool.

Edit 2: Since I don't really know anything about digital pots, could you point me in the direction of a really good, high resolution one. Looks like the SparkFun one you linked to only has 129 steps, which might not be enough to accomplish that fine control that I need. Like I said, I really know very little about these things, so any help I can get will be useful.

My typical projects use DAC instead of digital pots. I have not used any specific ones to speak of.

You could probably use a DAC chip if you wanted. My current project is with a LTC1660CN chip.

Quick search shows this guy (http://forums.hak5.org/index.php?showtopic=13959) intending to use these 256 step ones AD5206 Datasheet and Product Info | Analog Devices.

Maybe a better explanation of why the stick needs to be precisely held a certain spot would shed more light as to the resolution you need on it. I would say most cases 127 or 256 steps would be fine because most people really cant hold their finger within 1/127th of the joystick swing anyway.

I don't know if you're familiar with or have ever played Halo: Reach, but there is a theater mode in which you can take screenshots and move the "camera" around. in theater there is a feature called pan cam which shows the position and heading of the camera. I make spherical panoramas using this feature (example: http://hrci.me/pano/reflection) by placing the camera at a certain place and taking multiple screenshots. I'll start with the camera pointing at, say, 90 degrees, take a screenshot, then rotate exactly 30 degrees and take another, and repeat 12 times for a full rotation. Then I'll rotate the camera up 15 degrees and do it again. In total I get 13 full rotations spaced by 15 degrees vertically, I end up with 156 screenshots which I stitch together into a full spherical panorama. I have to be very careful not to tap the left stick or triggers because that will move the camera and even the slightest difference in camera position totally screws up the stitch and I have to redo it all.

The reason I want this mod is because rotating exactly 30 degrees is a pain in the arse, even with the controller sensitivity turned all the way down, and I'm a perfectionist. If I were able to very finaly control the sticks without touching the controller (and so not risking moving the camera) it would be a LOT easier to make these panoramas. I could make a macro that would rotate the camera at a certain speed for a specific amount of time, then hit the appropriate buttons to take and save a screenshot. I could essentially automate the entire picture taking process with a few simple loops and some logic.

Also, sorry for the very verbose explanation, I tend to do that, but I hope I gave you enough information to understand what I'm going for.

1 Like

Absolutely. That looks really cool. It's just nice to see what the end result is. My friend is here now and just read through the posts and says he will get on later and give you a more detailed idea of what he did to get it all working.

*edit. This chip is that he used. http://www.arduino.cc/en/Tutorial/SPIDigitalPot

Hey Halo2Freeek, I'm GoofBallTech's friend. Glad to meet a fellow halo enthusiast! Like you, I'm an avid halo fan and not just for its gameplay. Between 2003 and 2007, and I made many mods and maps for Halo 1 & 2 and thoroughly enjoyed making my own levels for Halo 1 on Xbox. My gamertag is Agnt 007 (yes Zeros) and we should play sometime together on Reach or Anniversary!

I did a similar project when I got a Wiimote to work on an Xbox 360. What I recommend (and what I did) is to use the chip referenced in the above post. This chip has 6 Digital Potentiometers on board and is connected through SPI. First thing i did was unsolder the joysticks. I'm not sure if you're using a Common Wire (CW) or Common Ground (CG) controller, but I used a CG. That means I took one of the 6 power supplies from the Analog Pots (2 Triggers and 4 on the Joysticks), and I used that one source for all 6 "A" pins on the IC. Then I used the GND from the battery pack for the the 6 "B" pins on the IC. The Wiper arms should go to the 6 Wiper pins. The simple code that I used to set the value of the chip was:

// Take the CS pin low to select the chip:
cs=0;
// Send in the address and value via SPI:
jst.write(address);
jst.write(value);
// Take the CS pin high to de-select the chip:
cs=1;

Address is between 0 - 5 (1 - 6) and value is 0 - 255.

Therefore, you would write 128 for the value initially to let it sit still. Then you can change it +/- 3 to get very slow moving camera. You'd have to record the time yourself to see how fast to move each one but after getting this system set up, you'll be able to walk (or fly in forge) into a spot, and hit your macro, go heat you up a hot pocket, and before you're finished tending to the burns on the roof of your mouth, you'll have all your screenshots! I'm not sure what your tech level is but just post back if you need any help. I'd like to see some progress on this because it does have potential.

Dude, sorry it took me so long to reply, the site hasn't been loading for me for the last few days. I'd love to play (I haven't played much Halo lately, what with Skyrim and all), I'll send you a FR.

Anywho, thank you so much for all the awesome information, I've placed a sample order for that specific digital pot from analog.com (it was free!), I expect to get it on the 16th. When I do, I'll definitely refer back to your post and figure this out. If all goes well, I'll let you know.

Thanks again, I really appreciate it. It's nice to talk about this kind of thing to someone who understands exactly what I'm going for (not that GoofBallTech didn't, but you know the Arduino side of this, and also the Halo side)

One thing though, how do I tell if my controller is a common wire or common ground? How does it matter, like, how would I wire it differently for one or the other?

You can find out your version at Xbox-scene.com. I would link you but I'm at work and the site is blocked.

Now I have a few questions for you. First of all, you said it was free, and I was paying >$6 per chip when I ordered so if you could link me the free one I'd really like that.

And second, are you soldering to the controller board for the buttons? I had to use enameled wire and it is the biggest pain to scratch off the coated traces and have the smallest exposed metal trace to solder to. How did you do your button connections?

Thanks!

Edit: Ordered on Analog.com! Awesome find, thanks.

I am soldering to the button pads. I found that using a small piece of fine-grit sandpaper works great to scratch off the coating, and it also etches the contacts a little so solder sticks to it no problem. I just checked with a multimeter which contact was + and which was -, then had to figure out why pulling the pin high wasn't causing a button press (turned out that I was using a PNP transistor instead of an NPN one, so I had to set the pin to high, then pull it low to "push" the button). I wrote a simple program in C# to communicate with the Arduino through serial and allow me to assign buttons (in the program) to "push" the buttons on the controller.

Dude that's an awesome idea! Definitely going to try that when I bust it out again. Also, I see you're using transistors and pull up/down resistors. I recommend this Quad Bilateral Switch IC! It has 4 digital transistors on board. Power it with the Arduino, connect to ground, and all you have to do is set a pin High to enable the button press, and it condenses the circuit very well due to no resistors or individual transistors! I started with transistors like you but this was so much easier to manage. Use 4 of those ICs (~50 cents each) and you can control all the buttons.

I already documented my + & - on my controller, so I'm looking forward to trying this. I've never scratched off this black coating, how long does it take? I'm not sure what I'll be seeing under it.

It only took me about 3 seconds with the sandpaper. Make sure it's fine-grit though, 220 should be about as low as you go. It's just metal contacts underneath.

And I'll look into that switch, thanks.

@nintendo9713 Don't suppose you can guide a total EE newbie through the process of wiring up an Uno to a 360 controller can you? I've got very limited hardware knowledge, more of a software guy. I've got some quad bilateral switches and a wired controller I can afford to lose.