Hello Everyone. Need some guidelines on appropriate use of Arduino. So In my project I hope to measure time of flight using ultrasonic transducers. They operate at 40 KHz and in picture attached I sampled trigger square wave and resulting received signal. In picture transducers are glued together so distance is almost zero. My question is would I be able to use Arduino uno to get 100 samples of received signal I am thinking of sampling period about 1 ms as this is period of green signal which is most interesting to me.
What does "green signal" mean?
Hard to read the scales and judge. A pulse being sent brings an answer of ringing much longer then the pulse. You ought to be able to do the calculation I think.
What is the project supposed to give You?
Someone's already been there, done that: https://www.davidpilling.com/wiki/index.php/HCSR04part2
Image from that page...'scope:
Image from that page...Arduino sample:


@ Railroader I understand poor JPEG quality hence some numbers each square on scope is 200us. Ringing response is due to mechanical inertia I believe as even a single square wave brings what looks like modulated signal. Reason for only this particular period of 5 squares is to get enough samples to perform cross correlation between two signals and to find time delay.
@DaveEvans Dear Sir thank you for link it is a FANTASTIC publishing I own author a cold paint! .
So I should be able to do it with standard Arduino ADC I mean to get 100 samples in 1ms?
Wintermuteldn:
@DaveEvans Dear Sir thank you for link it is a FANTASTIC publishing I own author a cold paint! .
You're welcome, but I'm not sure the author would be interested in a "cold paint"! Sounds like punishment, not reward!
Most likley he deservs cold pint instead ![]()
So I should be able to do it with standard Arduino ADC I mean to get 100 samples in 1ms?
That is a sample rate of 100K per second, so no you can't.
You can, if you don't mind the associated errors...which can be large...and if you don't mind violating the datasheet's ADC clock limit.
Pilling (who I linked to) claimed "usable results" at 300ksps (prescaler = 4), whereas Gammon got what most of us would consider horrible results with that prescaler.
And, of course, a prescaler of 4 puts the ADC clock at 4 MHz, four times beyond the datasheet max of 1 MHz.
It's not clear what "usable results" meant to Pilling. Perhaps he found that the ADC values, tho' not accurate, were sufficiently consistent so that phase or timing, his primary interest for that project, were "usable".
Not sure why anyone would want to push those boundaries, since there are many good (faster) alternatives. But, breaking things and pushing limits can be fun...
DaveEvans:
You can, if you don't mind the associated errors...which can be large...and if you don't mind violating the datasheet's ADC clock limit.Pilling (who I linked to) claimed "usable results" at 300ksps (prescaler = 4), whereas Gammon got what most of us would consider horrible results with that prescaler.
And, of course, a prescaler of 4 puts the ADC clock at 4 MHz, four times beyond the datasheet max of 1 MHz.
It's not clear what "usable results" meant to Pilling. Perhaps he found that the ADC values, tho' not accurate, were sufficiently consistent so that phase or timing, his primary interest for that project, were "usable".
Not sure why anyone would want to push those boundaries, since there are many good (faster) alternatives. But, breaking things and pushing limits can be fun...
Thank you for your explanation it makes total sense as when experimented and set Arduino prescaler over 1 / 4 it gave me constant max value. Now it’s clear as I was going for 8 MHz or 16 MHz hence absolutely insane results.
Also, related question I am going to use 2 M sample / s or faster external ADC I have choice of SPI or parallel input which one would be better? I have pins available so no issue here. My worry is that SPI is not "standardized" and do not want to run in to trouble interfacing. Also, my thinking is that reading parallel bus would be faster for Arduino.
For what it's worth here's a thread link to a HC-SR04 based ultrasonic time of flight discussion. This uses the HC-SR04 envelop detector whereas the original poster appears to be attempting coherent detection, but if the former provides sufficient accuracy for a particular application, it's easier to implement.
Thank you MrMark. Currently I am working on envelope detection using op-amp based precision rectifier and cap. My approach so far was to also use threshold voltage to measure delay. However recently I decided to try to us phase shift modulation. My thinking is to shift the phase of triggering signal by 180 degrees and detect corresponding voltage drop in detected signal. Here I struggle with it potentially due to mechanical inertia? So this might be very basic knowledge but I struggle with one issue if I use square wave out of signal generator and excite transmitter the receiver detects nice continues sinusoidal wave however using Arduino I get something like form in picture attached.

