|
Status
Jul 25, 2013 8:46:28 GMT -5
Post by Frisbone on Jul 25, 2013 8:46:28 GMT -5
I started this thread because the "Plan" thread had so many pictures it was taking too long to load. Basically I want to update this to track progress.
As of last night I had the majority of the driver software written - but not tested much. I have verified the ability to read data from the accelerometer and initialize the PWM device, and initialize the IO - but I haven't gotten to the point yet of making sense of the inputs - that is what is next.
Unfortunately I don't have much of a test platform to verify inputs. I'm going to create a new Test Tools thread to identify what I need to do.
|
|
|
Status
Jul 30, 2013 5:47:36 GMT -5
Post by Frisbone on Jul 30, 2013 5:47:36 GMT -5
After a long period of failing to achieve the results I've seen others achieve tapping off of one lead of a controller button and taking it to a common ground (through a transistor) - I decided to straddle the contact instead. I scraped off the dielectric coating and added a pool of solder to both contacts. Then I connected the NPN (2222) transistor Collector to the hot contact (the one with 1.6V on it) and the Emitter to the other contact that seems to be tied to ground through a 4700 Ohm resistor.
From there I connected a 100k resistor to the base (direct solder) and connected a wire to that with a crimp make end on the far side - concluded with putting a shrink tubing over the resistor & base transistor lead. Hooked this up directly to my output from the RPi - and Voila - I had an operating virtual button.
I then added a 1MOhm resistor in series with the 100Kohm one - the signal still got through. Added a 2nd one and it did not. So I'm going to stick with a 1MOhm resistor on the outputs to minimize circuit current and battery drain.
So at this point I have a plan for all 8 software controller outputs:
A, B, X, Y, LB, RB, LSTK, RSTK
The other digital inputs on the joystick: DPAD (4 contacts), < (typically options button), PWR, Start, and Sync - will all be directly wired.
I do have 4 additional GPIO I can use on my rev2 RPi board on a separate jumper, but I'd have to wire them direct to the board. But at most it would give me 2 more mapped buttons, not enough to map all of them (I'd need 14 more). Perhaps when I move to an arduino I can find one that has more I/O available so all can be mapped.
The remaining buttons will be "remoted", meaning the two contacts will be extended off the board and connected to another switch that is relocated to another controller location. All but the d-pad will be easy.
|
|
|
Status
Jul 31, 2013 11:35:24 GMT -5
Post by Frisbone on Jul 31, 2013 11:35:24 GMT -5
Last night I soldered all 7 transistors onto the xbox controller across:
A, B, X, Y, RB, LB, RSTK
RB, LB and RSTK were thru-hole while the others had to be soldered on the surface due to the poly-dome switches (with graphite coating). It was a pain to scrape off the graphite. Also wrote code (but not tested - just compiled) to add in support for a DAC chip. I wrote it so that both PWM and DAC are accessed in similar manners (though a parent Analog... class). The DAC is basically a simple device, but it has a lot of options that I think I don't need to worry about.
I can only have 2 DACs - so I need to map RT to a discrete output and use that to drive a circuit that puts max voltage on the Microsoft MC input pin. Need to do the same thing for AIM software trigger. So I need two additional digital inputs - I'll get it from #29, and #31 (on P5). NOTE: #28 and #30 are also available but they aren't accessible without removing the solder from the holes (they are oddly filled in).
|
|
|
Status
Aug 1, 2013 6:04:16 GMT -5
Post by Frisbone on Aug 1, 2013 6:04:16 GMT -5
Last night after chasing down the escapee dog and trying to fix my trunk that won't close I finally had a chance to work on a couple of things. I soldered on extending wires to the remaining outputs (7 of them) and ensured they all had a 1Mohm resister on the base. After updating the code so I output RT/LT as digital outputs I started to investigate the left/right trigger and how my parallel resistor circuit could be used to replace a POT. I measured the resistance of that pot and it went from around 250ohm to almost 10Kohm. so I used 220ohm and 10K ohms in my test circuit. I had very odd results which I'll document in another entry. Attachments:
|
|
|
Status
Aug 7, 2013 6:35:21 GMT -5
Post by Frisbone on Aug 7, 2013 6:35:21 GMT -5
So I switched back to PWM output last night and made some headway. I was able to see a proper signal according to the settings of my test code. However, the output voltage was 1/6th of what it should have been (400mv vs 3.3V).
I researched the outputs a bit more and it seems they can be configured for open-drain or totem-pole. I'm not sure what my code is currently doing - but its possible its defaulting to open-drain. The only issue would be why do I see any signal at all? Not convinced this is my problem unless what I see is some kind of leakage. Here is something I found on wikipedia:
Small current - but possible this is why I saw a signal??
In any event it looks like I might be close to a signal to test on the board. Next step is to check the output configuration and then hook up the 4.7K resistor & 10uF capacitor to smooth out the signal (check on o-scope) - then measure using a volt meter. See what the voltage range ends up being. In the end I'm going to need to match the voltage range so I don't put too much (or too little) into the Microsoft MC.
|
|
|
Status
Aug 8, 2013 6:08:58 GMT -5
Post by Frisbone on Aug 8, 2013 6:08:58 GMT -5
Ok - so last night I looked at the code and the device defaults to totem-pole, so that wasn't the issue. I put in the RC circuit and saw the effect that had - which was to essentially level out the voltage on the line to a constant voltage (with ripples of course) proportional to the DC - kind of cool to see and remember from school. The higher the frequency, the smoother it became. Unfortunately I'm limited to 1KHz with this PWM device (Smeitink's approach was running at 30Khz I think he said). But it looked ok, should still work at 1KHz.
The low voltage problem remained. Once the RC circuit smoothed out I figured I'd test it with a regular volt meter. Low and behold, at full DC it was reading 3.3V. Whhaat? So then I thought maybe my oscope was out of calibration (majorly). So I re calibrated it. no effect.
As I was ruminating in my "broken" scope blues I was thinking back to my days of old remembering that there were always different types of probes that affected readings and you needed to select the right probes. I of course only had one type of probe. But as I looked at the probe I noticed a slide switch on it. I flicked it.
BAM
I saw it go up a factor of 10 to from almost 400mV to 3.3V. So it was acting as a voltage splitter? Maybe disabling some internal resistor? Will have to look into that and figure out what its purpose is so I don't make that mistake again.
So, now I have what appears to be a good PWM signal and I need to next figure out what the allowable voltage bounds are. For example. I know that the controller typically operates up to 3V (two AA 1.5V batteries) versus 3.3V from the PI. I know that we are at least 300mV higher than it could normally expect. On top of that, the voltage going into the normal controller POTs may be lower than 3.3V. So I'll handle this by plugging in the battery first and measure the high voltage on the 3-pin POT connectors. Then I'll plugin a POT and measure the range of resulting voltages (may need to solder it in). Finally I'll repeat the test with the 3.3V PI supply.
I'll end up with a valid voltage range to the Microsoft MC. I'll then figure out what DC's produce the required range and change the code to "block out" DC's that make it go above or below that range. by changing the translation algorithm to only translate into the allowable range.
|
|
|
Status
Aug 9, 2013 5:32:35 GMT -5
Post by Frisbone on Aug 9, 2013 5:32:35 GMT -5
Last night I got busy measuring voltages. I first measured the high side of the POTs and saw it as 1.610 and then verified the resulting voltages from the POT output (4mV to 1.610V).
So the big task was then figuring out how to limit the current 3.3V output to 1.610. What I did was hook the original RC circuit back up to the output, connected to my RPi and wrote some test code to slowly increment the PWM from 0 to get to on/off values as close to producing those results as possible (as measured by a standard DC voltmeter). I posted the results under the PWM thread.
So now I need to rewrite the PWM driver so that I don't drive the output any higher then 1.610 volts using the on/off info as a guide (protection mechanism).
I started working on a board that will interface the PWM outputs to the controller. Basically the output needs to go to a 4.7Kohm resister first that is then tied to both ground through a 10uF capacitor and to the input of the Microcontroller (Microsoft) - that input is the center lead on the lead of three. I'll be wiring up the RSTK X/Y and the LT/RT
But before I waste time on that wiring I need to make sure that the PWM adjustments actually work to control the device. I'll use the DNF game as a guide and Wire in just the X axis first - and write some test code to go left/right without going operational. I'll then do the same with the right trigger. If both check out, I'll lash it all up.
|
|
|
Status
Aug 10, 2013 20:32:22 GMT -5
Post by Frisbone on Aug 10, 2013 20:32:22 GMT -5
Last night I built this 4 port RC circuit that smooths out the PWM circuit. I color coded the input from the PWM device and the output to the Microsoft controller to match the existing wires coming off the PWM device. Attachments:
|
|
|
Status
Aug 10, 2013 20:36:57 GMT -5
Post by Frisbone on Aug 10, 2013 20:36:57 GMT -5
I didn't initially have much success with having the PWM signals drive the xbox controller. But I noticed in the 1st person game I was using to test (Duke Nukem Forever Demo) that controls related to the left joystick were being triggered as well as random movements of the right joystick and left/right triggers. So to eliminate potential issues with nothing being connected to the left joystick I wired up about 1.5 feet of wire connecting the left Joystick's X and Y axis as well as the stick down button and the chassis ground as seen in the attached photo. After doing this and ensuring that all 4 other POT controlled devices (right joystick and L/R triggers) were connected to the PWM I instantly got much better behavior.
|
|
|
Status
Aug 10, 2013 21:05:12 GMT -5
Post by Frisbone on Aug 10, 2013 21:05:12 GMT -5
In order to test as much output as possible I reorganized the input/output mapping so that A/B/X/Y/RB/LB/RSTK are all wired to a physical button on my breadboard. Right to left the functions are: A (gpio29,TRIG) B (gpio22, RLOD) Y (gpio9, THMB) X (gpio25, LIDX) LB (gpio23,PINK) RB (gpio10, RING) RSTK (gpio11, GRIP) TRIG is supposed to be unmapped so it can go to the RT PWM output. The A button in the game is jump and is software controlled.
|
|
|
Status
Aug 10, 2013 21:12:17 GMT -5
Post by Frisbone on Aug 10, 2013 21:12:17 GMT -5
I modified the controller so that the left stick is completely remoted and the RT/LT and RStick X/Y are all extended and connected to female crimp connectors (as are the wires coming from the PWM device). I only had one issue. When I connected everything up its seems that RT and LT functions were switched. So I swapped the port definitions in the software so I didn't have to track down the problem in the wiring. It seems like 0V is considered "triggered" for the triggers so I had to reverse them in the software. It was also the case that a negative % meant right, and positive % meant left - for stick control - so I reversed these in the software as well. Current controller connections are shown in attached figure.
|
|
|
Status
Aug 10, 2013 21:24:46 GMT -5
Post by Frisbone on Aug 10, 2013 21:24:46 GMT -5
Ok, so I have a fairly functional demonstration that can be enabled before the software goes operational. Its an interactive menu where you can select the PWM output and issue a Percentage (-1.0 to +1.0 for axis, 0 to 1.0 for triggers).
In a first person game (I used COD BlackOpsII) I can rotate freelook left and right and halt, and I can look up/down as well. I also could trigger the fire and aim functions (RT/LT respectively). This coupled with the 7 mapped inputs shows things work fairly well - but the buttons did not reliably produce interrupts. A full shutdown and reboot would rectify the problem however.
When I tried to map a trigger (TRIG) to the RT and then run without the PWM demo I ran into problems where the main loop would stall. A couple of times it ran long enough for me to see the TRIG to RT work.
Its clear I have some bugs to work out somewhere to get things more stable.
|
|
|
Status
Aug 11, 2013 16:38:32 GMT -5
Post by Frisbone on Aug 11, 2013 16:38:32 GMT -5
Some good progress today. Figured out why my program was freezing (bug of course) and I found an issue with my emulation of the Arduino Wire library (which I avoided rather than solved). With that I put the PWM conversion code back in and had a mildly successful demo that I posted on Youtube: youtu.be/xxVhBNiKl0wBasically it shows the entire setup, buttons on my breadboard affecting the game (COD BO2) and .... me shaking around the accelerometer and watching the free look move around. Now for a lot of fine tuning! -but I might need to assemble the gun for that, have to give it some thought.
|
|
|
Status
Aug 13, 2013 9:23:26 GMT -5
Post by Frisbone on Aug 13, 2013 9:23:26 GMT -5
So I fixed the Wire library emulation problem that I had - which doesn't really move me forward - just made it easier to transition to Arduino when the time comes.
I decreased the factor used for both horizontal and vertical adjustments by a factor of 2 on the horizontal side, 4 on the vertical side - did seem to make it more sensitive - but its hard to determine what it is doing when I can' control orientation very well. So I have a few plans of attack:
1. Fully assemble the controller so I can move it around as it is intended (a lot of work).
2. Create some raw test data that represents %of max G movements in all 3 AXIS and step through the code to see how its translating it and debug.
3. Do a full code review - perhaps have someone review it - just on the translation algorithm.
4. All of the above starting 3, then 2, then 1.
|
|
|
Post by Frisbone on Aug 24, 2013 10:53:26 GMT -5
So I'm on my way back from my vacation having made good progress on modifying my gun. All buttons are in place. I have a mounting for the Xbox controller board. I put in an led for configuration feedback.
I put in female header wires for all of the Xbox controller outputs. All of the switch inputs also as well as the LED output.
I put the RC board in close location to the Xbox controller so it can be mounted above it. Permanent wires on one side, jumper block on the input side from the PWM.
I put in a grounding harness on both sides of the gun where all the input switches are tied to.
Also made an I2C harness that isn't yet installed.
Todo:
- make mounting for PWM board. - mount Xbox controller (connect A override wires first) - add silicon to RC board and place on top of Xbox controller to right of dpad - mount accelerometer and add in ground clamp and wire to ground harness. Put in 3v clamp and connect a female header wire to it (red). - put in PWM board (velcro mount) and connect up 3v using header wire tied to 3v clamp. Connect up I2C and ground wire to ground clamp. Connect up PWM output header to RC board. - figure out a way to access video and sd card while keeping RPi in place . Same for USB. - Mount RPI. Add red 3v female header to go to 3v clamp. Connect up all headers
|
|