1
\$\begingroup\$

My son is 10 years old just starting to play baseball and loves pitching. He is constantly throwing a ball at a wall trying to get better.

He also loves technology so we want to help him where we can.

We're looking to build a target that is 6ft x 6ft he can throw the ball at. Once the ball hits the target, we would like to know the x,y coordinates of the impact to track over time.

So far in the research we have done we have figured out the following:

  • Using 4 microphones, one on each corner to 'triangulate' the position. It seems like an Arduino isn't fast enough and this needs pretty specialized equipment for any real accuracy.

  • Using 4 accelerometers - but the accuracy would be really poor with consumer type devices

  • 2 x high FPS cameras - this is a bit harder as it becomes hard to move around, needs a lot of technology to synchronize video, calibrate cameras, detect the ball, etc.

  • grid of lasers attached (and protected) to the target, and the ball would break 2. This seems promising, but aligning all the lasers perfectly and wiring might be hard? Also very expensive to get lasers and receivers

  • When the ball hits the board, there should be an impact/energy created. Can an IR camera detect that? What kind of IR camera could we use to try this out?

  • piezo sensors: this seems like the best option where we sandwich a bunch of sensors in a grid between two pieces of wood. I would imagine there is some math we can use to figure out based on all the sensors triggered the position. Any suggestions on sensors here? Are we limited to the number of sensors based on the Arduino analog inputs?

  • multiple physical like switches that get pressed in by the ball and then figure out which ones were pressed. Does anyone know of switches that could work? Also are we limited to the # of inputs on Arduino?

  • FSR type panel to detect exact position, but these are very high resolution and costly ($5,000+ for smaller coverage areas)

Is there anything else we are missing, anyone else have any suggestions to do at home as a project with my son?

Thanks all!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I think and arduino could be fast enough. Look at the teensy 4.0. It uses the arduino IDE and is extremely fast. \$\endgroup\$
    – Drew
    Commented Sep 30, 2023 at 21:31
  • \$\begingroup\$ @Drew - are you thinking for using sound localization or something else? Are these high enough quality - or do you suggest anything else? amazon.com/gp/product/B00XT0PH10/… \$\endgroup\$
    – Nikki
    Commented Sep 30, 2023 at 21:57
  • \$\begingroup\$ @Drew the problem with the signal processing under Arduino is that the arduino software platform really follows an architecture that is quite contrary to what you'd need for medium-to-high-rate multichannel sampling. the processor is plenty fast enough; using it with Arduino just makes it harder to use as a DMA-driven sample machine. And large correlations will not happen in the RAM of a teensy, but that depends on your notion of "large". \$\endgroup\$ Commented Sep 30, 2023 at 23:12
  • \$\begingroup\$ @Nikki Some links popped up: this one and this one from a quick search for optical flow methods. \$\endgroup\$ Commented Sep 30, 2023 at 23:35
  • \$\begingroup\$ While computer keyboards couldn't take a hardball hit without being destroyed, you might be able to soften the blow, and/or remove key caps. It'd take more than a few to cover a large area. Keyboard electronics does all the key scanning for you. \$\endgroup\$
    – glen_geek
    Commented Oct 2, 2023 at 14:47

3 Answers 3

1
\$\begingroup\$

So, depends on what resolution you need. You could simply wire up a bunch of momentary switches, and put them in a rectangular grid, behind wooden squares. (Mechanically, you'll add stops behind the squares to make sure the ball's energy doesn't reduce the poor switches to crumbles.)

Wire that to a microcontroller with enough inputs, and just register the first switch to close (the others might close later, due to the ball bouncing/rolling to neighboring fields, or the whole thing shaking violently).

(You might want to have a lot of inputs, then, more than your average microcontroller has. There's solutions for that – an electronic latch that saves the "active" state of the first switch to get hit and deactivates all others instantly, together with things like shift registers.)

From the high-tech/high-resolution solutions you proposed:

I very much think the microphone solution is the one that's most likely to be viable; it's still not easy.

For localization, there is a technique called Time Difference of Arrival (TDoA), and the idea is very simple: you take two observers (here: microphones) that you know are synchronous (so, a stereo input on a soundcard). You correlate the chunks of the sample streams coming from both; which gives you a cross-correlation function (actually a cross-correlation sequence), telling you "at this temporal shift, the similarity of the A to the B channel was this high". You wait for really loud sounds (high absolute amplitude), you correlate, you find the maximum:
then you know how much longer the sound of impact took to get to the microphone B than to A (or vice versa). Since speed of sound is constant (at least, we're assuming that!), we can directly convert that time difference into a distance difference: the point of impact was so-and-so many millimeters closer to microphone A than to B. (please don't assume you get millimeter accuracy.)

Throw geometry at it (your son might still be a bit too young for that level of math!), and you'll find that the "set of all places with a fixed difference in distance to two fixed points" is a hyperbola (actually, one chord of a hyperbola, because we even know the sign of the difference, not just the absolute value). It's easy to imagine where the must have hit when the sound reaches both microphones at the same time: somewhere on a line going through the middle between the microphones, perpendicularly to the connecting line. If it's "a bit closer" to B than to A, you get a bend-y curve "around B" as possible places. The closer you get to B, the narrower / "sharper" this curve becomes. Here's an example:

Illustration: A, B: place of microphones. Red: board. Yellow: possible places of impact if sound took exactly equally long too reach A and B. Dark grey: Possible places of impact if sound took a little shorter to reach B than A. (not to scale)1
Illustration: A, B: place of microphones. Red: board. Yellow: possible places of impact if sound took exactly equally long too reach A and B. Dark grey: Possible places of impact if sound took a little shorter to reach B than A. (not to scale)

Ok, but your son won't like when you tell him

you hit somewhere on that branch of a parabola, can't tell you exactly!

So, you install another pair of microphones:

Adding a second pair of microphones perpendicularly to the first pair

And you get another hyperbola from the time difference of arrival you observe with microphones C and D. These two hyperbolas cut! And that's where the impact of the ball made a sound.

This is a beautiful method, and we use it for a lot of things – from allowing objects on earth to locate themselves (GPS is not built on a fundamentally different concept!), to finding airplanes approaching airports, to localizations of active shooters.

You can implement that with

  1. a sound card with four synchronous channels (hard to find, professional equipment, but would actually give the best signal), two stereo channels, or just two soundcards with a stereo channel each. Note that the two pairs don't need to be synchronous – we're combining the hyperbolas, not the individual audio channels. So, only each pair internally must record the audio against the same time basis. So, anything between, say a TASCAM US-4x4HR and just two sound cards with stereo line-ins (microphone inputs typically aren't stereo), like two Behringer UCA222.
  2. 4 omnidirectional microphones. (omnidirectionality is important because that defines whether the microphone sees the same delay in all directions).
    Higher end to go with the US-4x4HR would be something like MOVO LV lavalier mics, or you go with 4 separate cheaper omnidirectional electret microphones, and add a sufficient preamplifier. lcamtuf's microphone amplifier is an option there – don't build the AGC stage, that introduces variable delay, and you don't need much gain, so just use a relatively low-value feedback Rf (say, 47 kΩ to 100 kΩ).
    lcamtuf's amp
    Microphone Amplifier. Circuit and Schematic by lcamtuf.
  3. A controller fast enough to process the data from the sound cards. Good news is that for modern computers, these rates are ridiculously low. Raspberry Pi, old laptop, … what you have at hand.
  4. Software! Now, this is where you get to write things yourself. The handling of audio streams is easy (I use GNU Radio for these things, but I'm also biased towards GNU Radio); just drop all your stereo samples on the floor until you find something very loud on either channel, then take the 1500 samples before and 3000 samples after that (just throwing numbers around here), throw both 4500 samples from left and right in a vector, calculate the cross-correlation for shifts of less than 500 samples or so, find the maximum. You get your maximally likely time difference of arrival!
    From there it's "just" solving the TDoA equations. Your friend here:
    Y. T. Chan and K. C. Ho, "A simple and efficient estimator for hyperbolic location," in IEEE Transactions on Signal Processing, vol. 42, no. 8, pp. 1905-1915, Aug. 1994, doi: 10.1109/78.301830.
    is the classic paper, implemented all over the internet.
  5. Display: you need something to show the position, a score or something.

A word on accuracy: at a sampling rate of 48 kHz, your average sound card would allow for a cross-correlation accuracy of "1 sample", i.e. 1/48000 of a second, equivalent 6.25 mm of distance of sound traveling in air. Now, at sufficiently good signal-to-noise ratios, you can interpolate and get that further down. But: in reality, you probably won't get that accurate: your microphone positions, the actual phase centers of the microphones, and effects like sound echoing off surfaces and being conducted through the board will make this number much worse, even if there's little noise to disturb your estimation. But seriously, I'd say with an estimator stddev of maybe 5 cm to 12 cm you'd not be bad off, for training an upcoming pro :)


Another observation: when you already have these four microphones in place:

You could have a speaker close to the target board that emits a tone (preferably high enough that it doesn't annoy us adults ;) ). The sound bouncing off the ball exhibits Doppler Effect, i.e. the frequency of the reflected wave is higher than the frequency that the speaker emits at the ball. That allows you to build a velocity sonar! Simply shift the frequency you receive by the frequency your speaker emits, you get a so-called beat frequency, which is proportional to the velocity of the ball towards the speaker. This doesn't necessarily interfere with the operation of the TDoA system: you could filter out the frequencies of interest with a simple linear-phase FIR filter in software. And since that has the same delay for all frequencies and all channels, it has no effect on delay estimation.

\$\endgroup\$
1
  • \$\begingroup\$ I just realized that it would be much smarter to put A, B on diagonally opposite corners of the board, and C,D on the other two! It wouldn't change the principle, but it would improve the accuracy around the center of the board. What I also neglected to say was that there's cases where you still get two possible crossings of lines, which you often can only resolve through additional information ( comparing loudness at the microphones, for example) \$\endgroup\$ Commented Oct 1, 2023 at 0:09
1
\$\begingroup\$

Proposal with two variants of an X-Y grid.

The 6ft x 6ft (1.8 x 1.8m) target would be covered in an X - Y grid of conductive wires e.g. stainless steel, bronze, etc. The variant is the base of the target is wood, or wood covered in an electrical conductor e.g. foil or sheets of Aluminium, Stainless Steel or Brass.

Every Row (X) string is under tension (e.g. like a guitar string), all at the same height (e.g. 0.25" or say 5mm) above the base and not touching the base or the Column (Y) strings.

Every Column (Y) string is under tension, all at the same height (e.g. 0.5" or say 10mm) above the base therefore not touching the base or the Row (X) strings.

Concept is when the ball is thrown it compresses the X and Y strings together so that they make electrical contact. If the target is covered in an electrical conductor then the base plus the X and Y strings make electrical contact.

As a rough starting point each string is 6' 6" or say 2m in length. The number of strings is the target length and width divided by the string spacing. Suggest mocking up a small target and using a thrown baseball to see what is the actual maximum usable spacing of the X-Y grid for reliable operation so that it will minimize the total string length.

If using a 1" spacing and if the target is 6' or 72" then the total number of strings is 148 i.e. (2 x 72 / 1)+2. If using 25mm spacing and if the target was 1.8m or 1800mm then the total number of strings is 146 i.e. (2 x 1800 / 25)+2.

The total length for 6' 6" (78") strings is 23,088" (2 x 148 x 78") or 1,924' on conversion 582m. The total length for 2m (2,000mm) strings is 584m (2 x 146 x 2m). A common spool length is 100m therefore 6 rolls would be required.

Recalculate if the results of the mock up indicates a different wire spacing is required, or the base dimension's size or shape (rectangular instead of square) are modified.

As the target will be upright any wire sagging will be downwards and in theory this will not compromise the base to row wire to column wire spacings. There should be a screw or a wire clapping method used to tension the wires.

In effect the target has become a matrix forming a gigantic keyboard that uses the ball strike to hit a 'Key'.

The detector has to determine the location of the ball strike from the electrical changes. If the base has an electrical conductive sheet that is grounded (connected to system earth) then the circuit just has to detect the pulses to ground on the X and Y wires.

If an electrical conductive sheet on the base is not available then the task becomes more complex. A digital solution would perform scanning the rows and detecting the location of the ball strike from the impacted column wire. Given the large number of wires maybe different pulse widths or voltages could be used to provide a form of parallel scanning. An analog solution might connect the Row wires into a gigantic voltage divider and the circuit would have to capture the pulse and measure to determine location. Given the number of wires 8-Bit analog to digital converts(s) could be used.

More exotic solutions maybe possible such as measuring the resonant frequency of the wires or the frequency generated by the ball strike before the wire reverts to an open tuning when the ball rebounds.

A literature search (e.g. Google) may provide some other methods to solve the detection problem.

Personally I would use the metal sheet method and avoid the potentionally more complex and expensive solutions. This also would be easy to explain the circuit operation to your son.

\$\endgroup\$
2
  • \$\begingroup\$ Oh nice a keyboard matrix \$\endgroup\$ Commented Oct 1, 2023 at 9:00
  • \$\begingroup\$ I'd suggest microphones will be cheapest, easiest solution. \$\endgroup\$
    – PDP11
    Commented Oct 1, 2023 at 14:23
0
\$\begingroup\$

You can use any cheap video camera hooked up to a computer. Ideally, you will want to paint the 6' x 6' board black to have high-contrast (assuming a white baseball). Then, write a program to reduce the image down to just the ball as white (255,255,255). and the board to black (0,0,0). Then, you can implement some calculations that will use the pixels to figure out the center of the ball and the coordinates. This can be done on a frame by frame basis. To detect the "hit", you can look at changes between the frames of where the ball lands by a sharp change in direction. Or, you can set another camera up orthogonal to the pitch path so that it can "see" when it hits the board. Then you use the frame from the first camera (which should be in sync with the second camera) to calculate the position. Or, you can use a microphone to capture the frame to use when the impact is detected.

\$\endgroup\$
1
  • \$\begingroup\$ I'm out of touch with the framerates of cheap video cameras. But at 25 fps, your balls might be 26 cm away from the board in one frame, and 26cm bounced back from the board in the next frame, which wouldn't be a problem if you could mount the camera in line with the ball's flight path and use a tele lens to zoom in on the board's surface, but you can't with a cheap camera, so you'd have to mount it somewhere close to the board at an angle, and then your parallax error becomes very large! You can't sync multiple USB cameras, either, so that native triangulation will become hard. \$\endgroup\$ Commented Oct 1, 2023 at 12:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.