One might think, and experienced hardware creators would know one would be wrong, that when the PCBs come in you can populate them and everything will work just fine.
The PCBs I ordered were exactly what I had requested but it turns out they are not exactly what I wanted. My design for a 4922 DAC based board was just wrong and I’ll have to revisit that. The 4251 dual potentiometer design was also wrong and in a way I decided not to debug yet. I decided to focus on the 41010 design that I prototyped on a breadboard.
My plan for testing the circuit was to drive it with the simple software I had written to sweep the potentiometers and alternately press and release the joystick buttons and then measure the voltages and continuity on the socket on the board. What this unveiled was that nothing at all was working. I had to step back and troubleshoot.
I was at a loss for a while but decided that the approach to take was to get an unpopulated board and continuity check between pads on the PCB to make sure that the circuit on the PCB matched what I had on the breadboard. What I found was that I had completely left out one connection, that I had connected another trace to the wrong arduino pin.
I soldered in a bodge wire to connect the missing trace and updated the software to use the incorrect pin. Then I proved to myself a fact I already somewhat assumed, digital pins 0 and 1 of the arduino uno are connected into the serial transfer for the system and using the pin for other purposes conflicts with that and causes trouble. Serial communication just quit working fully correctly so I had to make a change. Out came the sharp knife to cut the trace connecting to pin 1 and then a jumper wire was used to connect the pin of the IC using pin one to pin 5.
After that change I could edit the software and it “worked” in that I was able to measure the continuity changes for button presses and I was able to measure voltage changes expected from the potentiometer voltage dividers. Perfect, time to plug it into the coco and test it with the simple test program. Great, except it did not work at all.
This was a bit more difficult to trouble shoot but basically came down to the fact that when you read a pinout you need to keep track of whether it is drawn from the view of the cable or the view of the port on the computer as those are mirrors of each other. I had connected everything exactly backwards in my design. Well that can be fixed too so I built a cable that swapped pins 1 and 5 and pins 2 and 4. Finally I was able to see results on the coco with my BASIC test program.
The next step was adding software to read the Xbox control. The approach I used for this is to check the examples provided with the USB host library to create code to read the inputs I cared about, for now the left analog stick and the four main buttons. I echoed the values from those inputs over the serial monitor to see what was returned. Once I knew the analog range and what the values for the buttons looked like I was able to easily write some conversions to map from the input to the output. A simple routine was written that quickly looped over reading the input and setting the output was written and I went back to testing on the coco. I was able to use the analog stick and buttons to control the coco in my simple test software. A couple of changes were needed to get the joystick axis reading in the correct direction and I was happy.
Making a test program go is cool, but at this point I figured it was time to try and play a game. It was late at night and I was trying to hit a personal deadline to have something working by the morning of CoCoFest so I really hoped that a game would work. Unfortunately it did not. The first problem was that I had to switch to the correct joystick port, and the second problem I still don’t know. Finally I had to sleep and planned to share my results with the coco community and ask them why it might be acting up because I was at a loss. I shut everything down and went to bed a bit disappointed.
I woke up the the next morning and set things up to be ready to present to the community. I tested that I could still control the test program as expected and decided one more time to play a game. Strangely it just worked. I did notice through the day that the adapter would either fall asleep or crash, unknown which, and that a quick reset would get things working again. The demo was a success and I was quite happy.
Future work includes correcting mistakes in my pcb design for the potentiometer based adapters, breadboard the DAC based design and draft up a PCB for that, and play a bit with the software to support multiple types of controls as well as possibly USB mice.