Measuring the speed of sound through different objects. Can Arduino help me?

I've never used Arduino before, and have no programming experience , but my friend just recently told me a bit about the projects he his trying out with it, and I'm wondering if it could be useful to me, too! I am a violin maker who is looking to build a device that can measure the speed of sound through different samples of wood. I think piezoelectric crystals on opposite ends of a piece, one to generate a pulse, and the other to record the pulse on the other side, would work. I'd need something that could measure time down to 1 Microsecond in order to get the resolution I need, just given that the sound will travel through my samples in only about 60 microseconds. Is this something that can be done with Arduino? Where would I start? Thanks!

Hello! At first glance the sample rate of 1 MHz seems like a very tall order for an Arduino, especially if there is anything else in the program loop to slow it down.

There is the Arduino DUE with an 84 MHz clock which may be the closest you can get with a regular microcontroller. You may be able to do something like buffer the input and process it afterwards, but it’s still right on the limit of possibility, I think.

This post may be interest: speed of analogRead

“Input capture” may be the way to go. Make your input signal digital (full 0 to 5V swing) and let it trigger the timer capture input. Read more about input capture in the controller data sheet. With a dedicated timer the timer clock can be the system clock, i.e. 16MHz typically.

On the UNO/Nano/Mini the Input Capture pin (ICP1) is Pin 8. This stores the current Timer/Counter1 count into the ICR register. I would use a PWM mode to pulse Pin 9 or Pin 10 (the two PWM pins on Timer/Counter 1. Then if your sensor triggers the ICP1 pin the ICR register will contain the transit time in 16ths of a microsecond. There is an ICR interrupt so you can capture the value and calculate a moving average.

Your friend should have also told you about the speed of sound being based on the density of the material. You can compute the density of your substance and compute the speed of sound based on that.

I think you can adopt this, just convert phase shift to speed.

Input A TX signal, input B received signal.

How precise can you make the measurement, without input capture?
Different gate trigger levels also can result in a shift.

they are using nanoseconds, pulse with for 500mm wooden stick will be about 100 us = 100 000 ns… Why not to make pulses the same level ?

On LCD they have resolution 0.01deg, 1 deg @50HZ = 55us, 0.01 deg = 0.55us resolution.