Sunday, October 23, 2005

If it ain't got that swing...

As part of our ongoing second project, I built two more prototypes to evaluate different sensors. The two sensor used were Piezo vibration (DigiKey #MSP1007-ND), and Force (DigiKey #102-1214-ND).

The Force sensor seemed to hold a lot of promise, as we were trying to sense when the ball is struck by a paddle. After all, that’s the focus of the project: to get the input of ball hitting paddle to create output as some other signal. For prototyping purposes, I just programmed an LED to light as my output.

Initially I peeled back the rubber pad on one side of the paddle and slipped the Sensor underneath it, and replaced the pad. This would have been a perfect solution because it was clean and tidy, but proved to be insufficient. The rubber pad dampened the collision force, and the readings were weak and sparse. If you didn’t hit the ball exactly where the sensor was or within close proximity, you got not reading at all.

For the second attempt, the sensor was placed on top of the rubber pad, and then covered with a stiff membrane (chipboard). This worked much better; no matter where you hit the ball with the paddle, the force was transferred to the sensor. We got plenty of useful readings from the sensor but the team felt that having to put the covering over it detracted too much from the original look and feel of the paddle.

On to Piezo

I was surprised when the Piezo sensors arrived because they were miniaturized versions of the Flex sensor accelerometer that I built a week ago. Working quickly, I designed a third prototype by taping the Piezo sensor to the paddle. These sensors worked fantastically, giving off tons of data. Too much so, in fact. The sensors are so sensitive that just holding the paddle steady, there’s enough vibration in your hand (time to switch to decaf?) to send a steady stream of data out to the PIC.

The challenge then was to develop a filter in the software that would only pass on a signal when the paddle struck the ball, not merely the slightest vibration or wiggle. The raw numbers coming in from the paddle ranged from 30 to 650. Tapping a ball with the paddle produced numbers from 400 to 600. The next step was to set up a filter that would knock out anything under what we thought a ball/paddle collision would produce. This presented a problem because the force of the ball hitting the paddle is always different, therefore it is never consistent. So if we set the filter to eliminate any numbers under say 350, just holding the paddle wouldn’t produce any signal. This seemed to work fine however once a ball was struck, we would then get multiple signals. After analysis, we determined that the problem was produced by the sensor continuing to reverberate after the paddle struck the ball. For instance, if a collision produced a reading of 425, we would then get a slowly descending string of readings from 425 down, until we hit the filter at 350.

To rectify this problem we introduced a new variable into the software that would represent the initial reading of a collision (the highest). We then used this reading as our cut-off point in the filter. After a set amount of time, the filter would be reset to a lower setting in anticipation of the next swing of the paddle. This produced much better results and only one output signal per collision. Unfortunately, the force of swinging the paddle sometimes was great enough to trigger the sensor as well. Much like the Flex sensor accelerometer I developed for my last prototype!

I felt that this could be interesting in our project, for we could create an event that happens when you swing the paddle and another one when the paddle collides with the ball. Sadly, my teammates were skeptical of the sensor protruding from the backside of the paddle and voted to go with the Drum trigger.

Here's the code:

Spacer = 0

Threshold = 300


High PORTD.1

pause 100


ADCIN 0, ADCvar ' Read channel 0 to adval

If ((ADCvar/2) > Threshold) then

serout2 PORTC.6, 16468, [DEC ADCvar/2, 13, 10] ' print it to serial out,

pause 250 ' with linefeed and carriage return (10, 13)

Spacer = 1


IF (Spacer = 1) then

High PORTD.2

Pause 100


Spacer = 0

Threshold = ADCvar


if (ADCvar/2 < 200) then

Threshold = 300



<< Home