Close

Hit Detection

A project log for hit'em!

An anti-social game

avishorpavishorp 05/24/2016 at 21:410 Comments

In the project context, the term "Hit Detection" has two separate meanings. The first, trivial one is the method for detecting that a unit (hammer or hat) has been physically hit. The second, trickier one is how to detect which hammer hit which hat.

Physical Hit Detection

The problem of physical hit detection has been addressed many times. Two of the methods I considered are using an accelerometer and using a piezo sensor.

An accelerometer can easily detect a strike as an acceleration spike. Among its advantages is the ease of handling a hit coming from different direction (for example, a hammer can be hit from both ends) and the fact that when it's mounted on a PCB, no wiring to external sensor is required. In the constraints of this project, namely time frame and price, this approach had one major drawback - the assembly. Accelerometers come in tiny, fine pitched packages. The one I selected for this project, LIS2HH12, is perfect from the technical aspect and rather cheap (everything comes in multiples of 20, so a 5$ sensor is out of the question), but is housed in a 0.5 pitch, 2x2mm QFN. Soldering such package at home is challenging, so I had to prepare a fallback option, in case I would encounter such problems. Eventually, this is exactly what happened. Almost none of those chips were assembled successfully, so I had to cut their current (I prepared a jumper resistor for that).

A piezo sensor is much simpler device. When it is exposed to force, it generates a voltage pulse that can be picked up by the processor. A disadvantage of the piezo sensor is its directionality - the force has to come from specific direction, otherwise it will not be sensed. It is also much more challenging for installation. I will elaborate on that point on a project log describing the hammer mechanical structure.

Eventually, as I already mentioned, I had to go in the piezo path, due to the failed accelerometer assembly.

Hit Identification

The game include a set of hammers and a set of hats. The basic capability required from the system is to detect which of the hammers hit which of the hats.

When thinking of such a problem, RF proximity technologies, such as NFC and RFID come immediately in mind. NFC (at least passive one) is not suitable due to its long operation time (detection can take 100s of milliseconds). As to RFID - I didn't have any knowledge of that technology or experience with it, and I could not afford to take the risk.

Rather, I took a completely different approach - temporal proximity. The idea is simple. When a hammer hits a hat, they both sense the hit at the same time. When they report to the management computer that they've been hit, they attach a timestamp designating the exact time it happend. When the management computer receives two hits that occurred at the time - it may conclude that theses two units hit each other. If the timing is fine grained enough (milliseconds), the probability that two different hits (two hammers hit two hats) occur at the same time is low. This scheme assumes one important thing - that all the units share the same timebase. Without this, there is no point for comparing timestamps. The way this requirement was met will be discussed later.

Discussions