Week 10. Input devices

Goal

This week we have to attach a sensor to a board and read data from it. This is a short sentence in a short week (Easter down here). Apparently fits perfect.

Last Week MIT lecture review

This has been the ninth week of assignments showcase. From all of these weeks I have been picked two times by the script. And both weeks (and just these weeks) I hadn't finish my assignments. What the hell of random in that?

At least in both cases I could show that this was Work In Progress and everything I did till the showcase because I had documented the work done. At the beginning of the Academy I did not commit my weekly assignments till I considered it to be 99% finished. And this usually happened at 23:59 on tuesday. I thought that WIP was not good enough or worthy of being uploaded to the network. But pushing all these small changes whenever I update the documentation has proven to be a good practice in Academy (and in my life). Because big projects or tasks have to be done at small steps. And the documentation is a key big task (remember: learning, making and sharing).

Let's talk about Input Devices. This has been one of these topics I was expecting since the beginning of the Fab Academy. I have some experience with reading data from sensors using an Arduino. Believe me, this is something anyone can do by just looking at internet tutorials. I think I could make one of these and finish my assignment this very afternoon (it's Friday now). But I would miss the opportunity of having a a whole week for learning somewhat amazing: Step Response sensors. I didn't even have heard anything about this kind of sensors. It is amazing what you can do with copper, some resistors, capacitors and such a ridiculous micro-controller. I was particularly amazed by the touch sensors that Matt Blackshaw and Matthew Keeter made. So my mission this week is going to be: to understand, modify and make a multitouch sensor like Matthew Keeter did.

Modifying Matthew Keeter design

I redraw Keeter's board in Kokopelli. Some people asked me why I was doing such a thing since Matthew already draw it in Eagle. There are a few reasons why I did this. The main reason is that this way I understood what the board does. If you have to draw every wire and component of your design (even if you copy it) you will learn a lot from it. The second reason is that I do not like Eagle. It is not Open Source. I agree it is free but who knows, maybe in the future the new CEO will change their mind and since everybody depends upon Eagle to make circuit boards you will be forced to pay. It has already happened, they even gave it a name in economics: Loop. On the other hand Kokopelli is quite a  versatile tool, you can make from mechanical design to circuit boards. And I have more control on the design. I can set the wires width, I can make custom pads, I can modify a component. This week I saw some people sweating because they didn't find in Eagle the library for the part they wanted to use. Finally Kokopelli designs have a nice home-made look and feel which I like so much.

Kokopelli multitouch

The main modification that I made to Keeter's design is changing the size of the board. I made my board 2.75 inches width (7cm) because since it is a multitouch sensor it was the smallest size to fit my four fingers. Also I arranged the components symmetrical around the board for better understanding the circuit (I found somewhat difficult to understand Keeter's circuit). The last modification was removing the holes. I could remove them all but the four holes of the central pads.

My hand

Here is one tip I want to share. While I was designing I used a combination of real components and computer graphics to prototype the board without actually milling it: Put the screen of your laptop horizontal on the table and lay the components in a 1:1 scale image of your board (do it easy so that you do not scratch the screen). This way I found some design errors that I could solve (not all of them as you will see later). You can also do it with a printed image of the board if you are really worried about your screen, not ultra sustainable though, but better than milling a brand new board.

Low tech board visualization

Making the board

Milling 2 sided boards

If your board has a symmetrical shape (one axis, either x or y is enough), milling both sides is tricky but not difficult. I started by milling the touch pad traces. I set the offsets to -1 in order to remove all the unused copper. Then I cut the board with the 1/32 bit. Here it comes the tricky part: remove the board, and clean the double side tape with alcohol or acetone. Apply double side tape to the milled side of the board. Flip it (that is why it must be symmetrical) and just softly let it lay down in the void, carefully center it and when everything is correct press firmly to stick it to the base. That's it. I did it this way and both sides were perfectly lined up.

Flipping the board

And here you are the final result of both sides of the board:

Final board

Stuffing the board and connecting both sides of the board

I stuffed the board quite fast and I found myself very confident in this task. This time I was only focused in putting all numbers of the resistors the same side and trying to perfectly line up all the components. Any misaligned resistor was considered a fail and should be reflowed.

Unusable wood

Connecting both sides of the board wasn't that easy. I took three approaches. But none of them were functional or aesthetically pleasant to me. At the beginning I used a very thin copper wire: This wire had some kind of coating because it was not conductive at all and the solder did not even stick to it. Burning the coating did not work either. They might make it fire resistant. Luciano helped me removing the coating with pliers and it worked. But this approach took a lot of time and I had 12 pads to connect this way. Then we tried with hard wire. It was the most functional approach but it was very big. Then at home I tested with copper tape. It is tricky to make it work because you have to press with your nail all the surface of the tape to make it both sides conductive. It was the cleanest solution but I wasn't really satisfied with the result. There must be a better method to connect both sides of the board. At that point I was wondering why the hell I removed the holes from Keeter's design.

Connecting both sides with tape

For the inner 4 pads I had holes and I faced even worse problems that almost ruin my board. The first thing I noticed is that the pads I made for the holes in the components side of the board were very small (0.35 inch). They should be at least twice this size because when you drill the holes there is very little space for soldering. The second problem I noticed was that hole number 11 was beneath the FTDI connector. I tried to pull up the FTDI connector and it cracked destroying 3 of the FDTI pads.

The holes nightmare

So I connected the pads the best I could and I used Sugru to fix all the damage I was doing to the board. Since I still had some more Sugru left over I made a couple of  side supports to hold the board while using it.

Sugru is your friend

Programming the board

When I was drawing the board in Kokopelli I noticed that there was no ISP connector in Keeter's design. I tried to put one in my design but there were a lot of crossing wires and I needed to put several bridges and going around lots of components to reach the pads. So I emailed him and asked him how did he program his board. He told me that he used a 16 pin programming clip. We only have the 8 pin version in the inventory. It could be a nice assignment to make a custom 14 pin clip for the ATtiny44. In fact I think I'm going to make one. Later on I abandoned that idea after having a bad experience with the clip. Continue reading to find out why.

So I used the 8 pin version of the clip and since the board was being powered through the FTDI cable I thought that I should be able to easily program it. But avrdude kept telling me that there were connection errors.

In search of the error

A connection error is likely due to bad contact or misplaced pins. Ruben Saguar helped me to trace back till we found that pins 8 and 9 of the microcrontroller were bridged. The error had its origin beneath a zero ohm resistor. I made the very same design mistake than in week 06 (which I actually discovered in week 08). This happens in Kokopelli when you ignore the drawing window while coding the wires of the circuit. I have to pay attention next time.

Here you are error

KOKOPELLI USERS: If you design circuit boards in Kokopelli a common error when you place a wire is mistaking the pad number from one or both components. This error causes a bridge in the component. Fortunately, it only takes a few seconds to verify and avoid this kind of errors. Listen to me: spend these few seconds.

I used a sharp blade to cut both sides of the bridged resistor.

Cutting the wire

MICROSCOPE PICTURES TIP. If you want to take microscope-like pictures of your circuits as the one above just hold the 10x eye-loupe in front of your mobile phone camera.

I resoldered the resistor and attempted to program the board again. And again, it gave me the same connection error. And you know what? I checked pins 8 and 9 and they were still connected. WTH!! I unsoldered one more time the zero ohm resistor and i discovered that some solder had flowed from the pad to the wire. Probably due to remains of flux.

Solder that bridged again the pins

So I removed the excess of solder with desoldering braid and resoldered the zero ohm resistor (third time that I solder this component). This time I double checked that pins 8 and 9 were not connected.

RECOMMENDATION. If you fix something, make sure that you actually fixed it before continuing.

Problem solved but still the same connection error. I triple checked all the connections to the clip and they all looked fine. Then Ruben Saguar told me that I had probably broken the microcontroller. He told me that my best bet was to replace it with another one. We were able to desolder the microcontroller by quickly touching all the pins in boths sides of the micro. I just broke a bit one of the pads because I pulled it up prematurely.

Unsoldered ATtiny

Then I soldered another ATtiny to the board but I didn't manage to align it perfectly. It was slightly shifted to one side. As a result, only one pin of the clip was making contact to the microcontroller, no matter how hard I pressed the damn clip.

Temporary wiring an aftermarket ISP connector

By that time, my useless board had so many patches that I renamed it to franken-touchpad. As you can imagine, the aesthetic result of the board had been experiencing free falling in the priority list. So I decided to wire the ugliest ISP connector ever made in recorded history of electronics. Warning: The images you are about to see may hurt your sensibility.

The ugliest thing in the world

The funny thing is that it worked now. This horrible thing programmed the ATtiny.

Program done

CONCLUSION: No matter how hard it looks, how many bridges are needed, or going around components is necessary, but I promise that I will always place an ISP connector in my future designs.

Visualizing the data

I started by downloading Keeter's code. I used Processing 2 on Mac OS X because Processing 1.5.1 was giving me the following error:

WARNING:  RXTX Version mismatch
    Jar version = RXTX-2.2pre1
    native lib Version = RXTX-2.2pre2

And crashed/rebooted my computer twice without prior notice. Also I changed the portname number in order to match the USB port of my computer (since there is not a port list I just tried 0,1,2... till I got it working).

The first thing I noticed is that 4 of the pads connected by copper tape tape were not responding at all to touch. I temporary fixed it by rubbing the copper tape with the nail in order to make good contact. Copper tape is not a reliable solution, I won't use it anymore. And later the I decided to solder all the connections of pads in order to make good contact and also wire a (more or less) permanent ISP connector.

Final board front Final board back

The second thing I noticed is that the board was working fine, but it was not exactly behaving as the ones from Keeter and Santi Fuentemilla. It was working detecting all touchings events but as if it had a very poor signal. When I touched a pad it moved, but very little. If took my shoe off and touched the ground with my feet in order to get a stronger ground signal, then all the pads got a strong green signal.

I got a hint on what was happening when while removing the temporary ISP connector I accidentally broke the wire that was connecting to pin 9 in the microcontroller. Then row number 3, instead of giving me a zero, it was giving a 100% signal as I was touching all of them.

Pin 9 wire broken

Something was not fine tuned, either with the software of with the hardware. I needed to use an oscilloscope.

Oscilloscope

I could set it up and make some basic measurements to the pins of the microcontroller. But I was not very sure what was I looking for. I felt it to be the right moment to take the step I had been trying to avoid ... 

Understanding Step Response technology

I know it is supposed to be the first thing I should do before even starting this assignment. To understand how come this simple components can become such advanced sensor. But I want to make the sensor work before digging deeper in the theory of step response. I would have more interest in the topic once I see it working. I initially took this decision at the beginning of the week after spending 30 seconds in the Wikipedia step response page.

So basically what happens is that, believe it or not, your body has a certain amount of capacitance, your skin acts as a 1M ohm resistor and, since you are connected to ground, your body can be modeled electronically as a RC circuit. What's happening here is that you close the circuit and charge the pad when you touch it. You can measure this change in voltage but there are a couple of problems: first one is that the change is very little and second one is that it happens so fast. It happens so fast that without a proper measuring technique you will miss that change. So the tricky part is measuring the voltage at the right moment at the right place. And that is what you do with the software.

In the end

In the end I could not find the problem of high noise and low signal. It could be caused by the geometry of the board but I guess that interferences are mostly due to the massive surgery that the board suffered.

What I learned

Electronics is a deep and misunderstood subject. It looks both magic and complicated because we never bother in understanding what happens under the hood. But I am noticing that I can understand complex things by starting with simple ones. This week I had a lot of trouble with step response and making the board work. This is because I started with the most difficult sensor I found, ignoring again the spiral development lesson. I you are a Fab Academy student reading this before starting your assignment and you want to try step response technology start with Neil's example sensors. Analyze them in the oscilloscope and then try the complex thing. I don't know why the hell I never follow the advices I give.

Download files

You can download all the files related to this week here.