I have come to the conclusion that my problems with the displays are likely due to the build approach that I took. Lots of temporary connections; plugs and sockets. I decided to go with a more “production”-style approach instead of the “prototype”-style that I have taken so far. That means permanent solder connections in favor of temporary plugs. I am also not going to stack the Arduinos anymore. To manage the wiring, I am going to distribute the Arduinos so that they are near the displays they are controlling. I will daisy-chain the input wires, which should also result in a much cleaner build. The one concession I will make is to use socket headers for the Arduinos on the boards so that they can be removed for programming.
So now I am waiting for parts. I laid out the circuit boards in KiCad, and submitted them to PCBWay. I also ordered new Arduinos so that I don’t have to unsolder the angle connectors on the existing ones. And I needed some more standoffs to mount all the circuit boards.
So I am waiting for:
Curcuit Borads
Headers
Arduinos
Standoffs
I didn’t order screws or nuts for the standoffs, because I plan to just get those at a hardware store once the standoffs are here.
I have accepted that I may have to replace some of the LCDs. That means that I will have a mix of Rev A and Rev B displays, but with the new layout it will be possible to match the software on each Arduino with the display it is connected to.
I tested loading games 63 and 64, which are Vulcan Venture and Warlords. Then I ran the test a second time, because I was suspicious of the header that never lit up at all. And I was right to be suspicious. Here are the videos:
I mentioned that measuring the voltage on the Arduino input pins would be helpful for figuring out the issues with the images not displaying correctly. But that would be a time-consuming hassle, so I came up with another idea. Since the Arduinos have the stacking connectors, I could build a board with LEDs for each of the input pins. Here are some images from brainstorming:
It’s not immediately obvious, but in that last photo you can see the pins sticking through the board. I realized later that for the negative side of the board, I would only want one pin, because I didn’t want to ground out all the pins on that side.
I didn’t want to deal with in-line resistors, so I ordered some 5V-rated LEDs from DigiKey. Then I stared cutting up the circuit boards. I used the time-honored score-and-snap method.
It turned out that for the “snap” bit, I needed pliers.
Here are the pins all laid out on my breadboard for easy soldering:
soldering:
To ground all the pins on the negative side, I used a stripped wire and wove it in and out of the connector holes.
<
Then I added the LEDs
And here are a couple of tests with the LEDs connected.
As I said in the last post, the best way to get a full picture of what’s going on with the Arduino inputs will be to load game 63 and then load game 64. This should exercise all of the LEDs and will therefore identify all the non-working inputs.
I cleaned up the wiring on the blue side of the control panel. At one point, I had to re-solder one of the wires for controlling the backlight and LED:
Here is the blue side all cleaned up:
And a shot of the whole thing:
So now that everything was wired, it was time to test it out! And here’s how it went:
So, as I said, I have some things to figure out. The first thing that I noticed was that Button 5 (bottom row, left) on the blue side never lit up, even initially. This turned out to be because the power wires had come off of that one. That was a relatively easy fix
My next step for troubleshooting will be to load game 63, and then measure the voltage on all of the input pins for the arduinos. Pins 2-7 should be 5 volts, and pin 1 should be 0. Then I will load game 64 and measure again. This time, pin 1 should be 5 volts, while the rest are 0.
I have done quite a bit of wiring. First, I moved the negative wire to the correct relay and tested the image loading on the single display. The offset of 64 was gone, and the correct image was now loading. I tried a few different games just to be sure.
I still had to glue the extenders into the remaining 16 LCDs. Here they are curing overnight.
Once the glue had cured, it was time to reassemble the board – put the LCDs in place, put on the background paper and plexiglass, and reinstall the buttons. In order to reconnect the button wires, I had to undo my cable management, because with all the wires zip-tied together it was impossible to be sure that I was wiring things correctly.
Once the buttons were wired up, I reconnected the power to the LCDs, and then added the wiring from the Arduinos to the LCDs. Here are some photos of the chaotic mess that I had on my hands once all the connections were made:
It is kind of amazing how much wiring is required just for the LCDs. For contrast, here is the other side of the control panel with the buttons wired up, as well as the power for the LCDs.
To clean up the mess, I carefully zip-tied the wires together. I had two goals:
Make the wiring look nice
Keep the SD cards accessible
Here is the result:
I ran into a small issue when wiring the other side of the control panel. The A0 pin on the Arduino is used to control both the backlight on the LCD and the LED in the button. If there is no image on a particular button for a particular game, that button will not light up and the LCD backlight will be off.
In order to accomplish this, I made 20 of these connectors:
The single end goes to the Arduino, and the wire splits to connect to the backlight pin in the LCD and the positive connection for the button LED.
One of these connectors was missing. It would not be such a big deal to make another one, because I have plenty of wire. For the Arduinos, I am using sections of this cabling (which can be separated out into individual wires or smaller groups of wires):
Since I am only using six colors for the Arduino connections, there is plenty of extra. But I still need one with a connector that is compatible with the button. Then I remembered that the controller kit came with an extra button connector:
I clipped the red wire off of the white plastic connector and made a new connecting wire. I got the second side all wired up, but have not had time to do the cable management yet. Here is what the whole thing looks like at the moment:
UPDATE:
While reviewing this post, I noticed that one of the Arduinos was plugged in incorrectly. I may have to cut off a couple of the zip ties to fix it:
Since I had the code working for loading a single image, I went ahead and modified it to load the images based on the states of the digital input pins as I had before. This time, as I mentioned, I kept all of that in the setup() function and left the loop() function empty.
The sample code from Adafruit already has a check for the status of the LCD so I don’t have to add any kind of wait to be sure it’s initialized before the image is loaded. I did add a wait to be sure that the input pins are in a stable state before they are read. I made the delay 2 seconds, which is dramatic overkill, but it’s also less time than it takes most of the emulators to load. So once the game is ready to be played, the buttons should be labeled.
I uploaded this new code to all of the Arduino Pro Minis. This was a frustrating experience, because about 2/3 of the time, when I plugged in a new Arduino, the IDE would say that it could not find the device on the COM port. Sometimes trying to upload with nothing connected would clear out whatever the problem was and then the upload would go fine once the Arduino was connected. Sometimes it required logging out a of and back in to Windows. And sometimes I had to reboot.
I added superglue to four of the LCDs to hold the SD extenders in place. There are a couple of square holes on the socket, so I put a drop in each of those.
I let that cure overnight. Meanwhile, I put all of the newly programmed Arduinos into the circuit boards I have for them.
I wanted to test things out before putting everything back together, but of course the buttons are all disconnected and their wires are just kind of sitting there where they could make accidental contact. So I unplugged the controller boards for the Raspberry and connected a generic PS-like USB controller.
I connected one of the Arduinos to one of the LCDs with the glued-in extender.
I loaded up a ColecoVision game on the emulator, and after two seconds, an image appeared on the screen! But it was the image for X-Men, not the image for ColecoVision. I was really worried that I would have to change the code on the Arduinos, which would have been quite the hassle.
I looked as my list of games, and saw that ColecoVision is number 5, while X-Men is number 69. Or, in binary:
Coleco: 0000101
X-Men: 1000101
I took a look at the code for decoding the input pins:
int convertPinsToInt() { int out = 0; if (digitalRead(7)) out += 1; if (digitalRead(6)) out += 2; if (digitalRead(5)) out += 4; if (digitalRead(4)) out += 8; if (digitalRead(3)) out += 16; if (digitalRead(2)) out += 32; if (digitalRead(1)) out += 64; return out; }
The input pins on the Arduino float high, so I thought that Pin 1 must not be properly connected. That pin being high when it should be low would account for the difference. I took a look at the relay for pin 1, and found that the negative wire was not connected. Instead, it was connected to the relay that I am using to control power to the Arduinos and LCDs.
So the next step is to move that wire and make sure it’s working as expected. Then, glue all the other extenders into the LCDs!
I thought that the reason that the SD extenders were not staying securely in the sockets on the backs of the LCDs was that they are not as thick as an actual SD card. But it turns out that those sockets aren’t great about holding on to regular SD cards, either:
So now my plan is to take the control panel apart, and for each LCD, make sure that the extender is making good contact, and then drop some liquid superglue on it and let it run around the extender inside the socket.
I got the buttons out and removed the plexiglass, background paper, and top layer of hardboard. You can see that the extenders are not all inserted to the same extent.
I updated the Arduino code to load up the button image in the setup() function and deleted the code from the loop. I uploaded the sketch to one of the arduinos and connected it to a display. And it didn’t work.
Since it has been so long since I worked on this code, and since I’m changing its structure, I decided to go back to the original sample code from Adafruit, and get it working on my arduino uno (since that has debug support). So I did all that and it still didn’t work. The error message I got said that it failed to initialize the SD card. I pulled one of the screens out of the control panel and plugged the SD card directly into it. Now it worked. I went back to the SD extender, and it didn’t work. Then I pushed on the SD extender to make sure it was all the way in, and it worked.
It turns out that the part of the SD extender that goes into the SD socket is not quite as thick as an actual SD card. Here is a close-up photo of the adapter on top of an SD card, and you can see the difference in thickness.
I don’t think this would have mattered for most types of SD sockets, but the mini LCDs have the push-to-release socket:
And with the extender being slightly thinner than an actual card, it is not held securely in the socket:
So now I’m pretty sure that I have to disassemble the control panel (remove all the buttons, remove the plexiglass and paper) and pull each display out and then glue a thin piece of plastic onto each extender.
Arduino software structure consists of a setup function and a loop function. When power is applied, the setup function is executed once, and then the loop function is executed over and over until power is removed.
Adafriut, the maker of the mini LCD screens, provided a library and sample code for loading an image onto the screen. In their Arduino code, they loaded the image in the setup function and the loop function was empty. When modifying the code for this project, I moved the loading of the image to the loop function, because I wanted to be able to change the image when the Arduino inputs changed. This would happen when a new game was loaded.
And then … and then I decided to switch the power to the LCDs and Arduinos so that they are only energized when a game is loaded. They are powered down in between games, so there is no need to have the loop keep checking whether the inputs have changed. I can move the image load back to the setup function and make the loop empty again. I will put a delay in the beginning of the setup to allow time for the LCD to be fully powered up before trying to access the image (I think that not doing this may have caused some of the data corruption on the SD cards), and then load up the image for the selected game.
The Arduino board on the red side of the control panel already had the power wires for the LCDs soldered in, as well as the ground wire for the button LEDs. All of the power leads are the same length, but the distance from the board to the LCDs varies, so there was a big loop of extra cable once those were wired up.
I looped it back on itself and zip-tied it so it is a little more contained now.
For the blue side, the power leads had not been soldered in yet. I decided to cut the leads to the length needed for each connection as I soldered them. So the blue side does not have the extra bundle of wires.
Here is the blue side with the board mounted, power leads zip-tied, and the ground lead for the button LEDs.
That ground lead jumping from button to button looked a little sloppy, so I zip-tied it in with the switch wires for the buttons.
Here are some close-ups of the blue and red sides of the panel, and a wide shot of how it looks at this stage.