Time difference measurement using two piezo sensors

Good day everyone. I am quite new to the Arduino community and I was wondering if anyone would be able to assist me in a project that I am busy with.

What I have:
Arduino Uno R3,
Breadboard and a large range of resistors,
Piezo sensors (20mm)

Query:
I want to stick two piezo sensors to opposite sides of a concrete cube. After this an impact is imposed on one side of the cube and I want to determine the difference in arrival times for the two sensors ( If I impose impact on one side near the first sensor how long will it take to reach the sensor on the opposite side?)

I hooked up the leads from the sensors to the Arduino digital pins (the 1st sensor on the face of impact I connected to pin 5 and the sensor on the opposite side I connected to pin 3)

I also attached a picture to illustrate the setup

Thank you for any help!

Have you been able to detect a signal from either Piezo when you strike the block?

This will be tricky for a beginner! It will not be easy for an expert!

The vibration will travel through the concrete at a speed of around 3 to 4 kilometers per second, much faster than the speed of sound in air. The time difference between the signals from your two sensors will only be perhaps 20 or 30 microseconds. Getting an Uno to measure that time accurately would be very difficult. The standard micros() function is only accurate to around 4us, so that may not be good enough. Some use of the atmega328's timers and interrupt pins may be needed to get more accuracy.

Have you thought what accuracy you need, as a minimum?

And I want to know why, if you can share. Abject curiosity.

"Sounds" interesting.

Do you have an oscilloscope with which you might tale a peek at the signals and timing before starting to mess with code, timers and interrupts?

a7

Hi. Yes I get good readings from both sensors. Although the values are still in bits.
I attached a sample of the serial plotter. The blue line is for the sensor on the opposite face and the Red line for the sensor on the face where the impact is applied (I just tapped it with a hammer)

I nocked the side 3 times

Hi. I am looking for an accuracy of about 0.5ųs
I know what might be stretching it a little!
My goal is to find a cheaper way of doing the UPV (Ultrasonic pulse Velocity) test. So, if I can get the time difference then I can work out the Velocity as V=0.1/t, where 0.1m is the distance travelled and t is the time in seconds. This will then give an indication of the Elastic Modulus of the Concrete. Thank you for your Reply PaulRB!

Hi. I can get access to an oscilloscope, but I would like to try and code it first, and as a last resort use the oscilloscope. The goal is to work out the Velocity at which the wave (due to a constant impact) would travel throught concrete. So, V=0.1/t , because the distance the wave travels is 0.1 m and then I just need the time. The time square and velocity then gives an indication of the Elastic modulus and Strength of the concrete sample. It is a modified UPV (Ultrasonic pulse Velocity) test

Thank you for your reply alto777!

The very shortest time an Uno could possibly measure, by itself, would be 1/16M = 0.0625us, because of its 16MHz clock. So perhaps 0.5us is possible, but it is only 8 clock cycles! It will take some expert knowledge of the atmega328's timers and interrupts, beyond my expertise, but there are some forum members who know much more than me.

Uno/atmega328 has 2 hardware interrupt pins (2 & 3) so I would look at attaching your sensors to those to see if you can trigger them with the sensor.

Maybe try something like this to begin. It won't be good enough and may not even work at all!

volatile unsigned long t2, t3;

void isr2() {
  t2 = micros();
}

void isr3() {
  t3 = micros();
}

void setup() {
  attachInterrupt(digitalPinToInterrupt(2), isr2, RISING);
  attachInterrupt(digitalPinToInterrupt(3), isr3, RISING);
  Serial.begin(115200);
}

void loop() {
  Serial.println(t3 - t2);
  delay(500);
}

Try xor gate, the output should be a pulse with width equal difference between pulses.

https://mousa-simple-projects.blogspot.com/2017/12/power-factor-measurment-using-arduino_18.html

Need amplify signals to 5V pulses.

Only if the pulses overlap. Not sure that will be true.

1 Like

Overlooked that, so use LED on/off
https://thecustomizewindows.com/2018/04/arduino-2-push-button-one-led-switch-on-off/

How does that help the OP exactly?

(bad circuit, by the way)

Post #8.
Replace buttons by signals from piezo sensors , the results are square waves on LED pin, than use those pulses as input in software post #5

Thank you very much PaulRB. I will attempt this and come back to you with feedback!

I'll have a look at this, thank you for the insight!

This might be better/easier using separate circuitry to start and stop an external counter , then read off the time

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.