So here we are at Part 8. The second to last post (unless something goes wrong).
Let’s get right to it.
The keypad had a hole for an LED but I wanted another so I could have both a red and a green one. This turned out to cause some problems, but more on that in a moment. I mounted both LEDs in a small piece of wood and soldered them to ribbon cable.
The problem arose when I needed to take the keypad off the metal plate it was glued to. I didn’t know where in the keypad the circuitry was, so I didn’t know where I could safely cut through without damaging it. Also, cutting through the metal would be much easier if I could just cut all the way through and not have to stop at the plastic. So I got a flat head screwdriver and pried it off.
Unfortunately, this caused several buttons to stop working. See, the keypad is able to be so thin because the circuitry is on super thin layers of copper and the buttons are slightly bent pieces of metal, like this:
When I was using the screwdriver, some of these pieces of metal got bent a little, so they didn’t pop back up after being pressed.
This wasn’t too bad because I could just take off the top layer of the keypad, take them out, and rebend them. This worked, but led to some of the thin layers of copper getting scratched. I tried fixing this with wire and conductive tape, but it didn’t work, leaving me with a broken keypad.
I decided it was simplest to just build one myself. Surprisingly, keypad diagrams are really simple, basically just being a matrix of buttons. With the Arduino keypad library, there aren’t even any power or resistors to deal with.
I decided to base mine off of the Festo one the Box came with. Since I don’t have any kind of circuit printing capabilities, I decided to use conductive tape as the circuit and plastic tape as an insulator, keeping my version nice and thin. The metal pieces would be reused.
First I marked where all the buttons would go so they would line up with the cover, which had the numbers printed on it.
Then I put down layers of conductive tape to act as the rows. This would be what the metal pieces touched when they were pressed.
Then, after some strategic plastic tape, came the columns, which would always be touching the metal.
After some thought, I decided to just tape the wires to the metal. They would be pressed down by the tape and the keypad as a whole, so I didn’t feel that a more complicated approach was necessary.
After making sure each connection worked, I taped all the buttons in place.
The different layers are more clearly shown here:
Finally, I added some double-sided tape and put back the face.
In a surprising turn of events, this worked really well and has been what I’ve been using for a while now. Not quite as elegant but looks pretty much the same and it works.
In between that whole mess, I drilled a new hole in the metal and scraped off a circle from the face, then mounted the LEDs.
However, the wire I was using made the system a little too thick for the LCD, so I needed to change how it was mounted. Holding the LCD in place was a hassle, since it had to line up with the window in the face, but I could only tell if it was lined up if it was on. I decided on a more secure method.
After some very careful measuring/sanding, I got a piece of thin wood that held the LCD in the perfect position.
From there it was pretty easy to build around everything and add thick layers of hot glue to hold everything securely. The wood would hold the LCD straight, and everything else would add pressure to hold it down. Even though I originally did this out of necessity, it actually worked a lot better.
The other layers are the same as before.
While I had not been planning on using the big buttons on the face of the Box, I decided that they would actually be super helpful, so I wired them up for lighting (through the high power supply) and actual use (through the Arduino).
Now, the more complicated pause/unpause routine could be replaced with the simple START and STOP buttons. Also, I printed out a new label for the POWER ON button to make it RESET COMPUTER. It now resets the Arduino, which means it is no longer necessary to open up the entire thing each time.
This being done, it was time for more testing. This is where I ran into trouble. While everything worked fine for the most part, the sensors weren’t stopping the pistons. After some experimenting, I found that the function to check the sensors (sensorGrab) was only running every 200 ms, while the smaller, faster piston passed through the sensor’s range in about 5 ms. This was a problem.
The first thing I tried was putting more instances of sensorGrab in the code so it would run more frequently, but it wasn’t fast enough. Next I tried a timer interrupt. Remember those? Well it was simpler this time because there was no issue with the LCD, which wouldn’t be used inside the interrupt. However, this didn’t work either because having the interrupt run that quickly slowed the rest of the program down to a crawl.
So I thought about using an external interrupt common to all the sensors (6 individual ones would be too complicated). After all, I only needed to check the sensors when something actually happened to them anyway. So I wired a sensor to an interrupt pin as well as the normal pin in the Arduino and tried it.
It worked! The piston still couldn’t stop halfway, which was unfortunate, but at least it stopped no matter where the sensor was. However, when I tried it with more than one sensor, it stopped working. The problem was that the sensors were normally high and only became low when they were hit, so the interrupt waited for the signal to go low. But, if any of them were high, the interrupt wouldn’t recognize the signal of the one that wasn’t.
Fear not, readers! A solution presented itself in time. I realized I could change the transistor circuit so that the transistor ran on the lower Arduino power and would become high when the sensor was activated. This way, a common interrupt would work. Also, since I had to rewire it anyway, I changed the sensors from the stupid wire to ribbon cable.
Unfortunately it was around this time that the Arduino stopped being recognized by either computer I was working with. I have recently determined that the problem is the comparator (which decides where the Arduino’s power comes from) and the USB-to-serial connection (which lets the computer talk to the Arduino).
The board still works, but I can’t program it. There is the possibility that I could program with the serial pins directly, but I have been advised that the Arduino is probably living on borrowed time and might stop working in the future, so I will most likely have to get a new one. More on this next time.
Until then, here are some pictures of the thing as a whole.
Until next time,