# How to analyze the input of a ultrasonic sensor (A-14P20)

Hello together,

I'm doing a project right now in which I would like to analyze the input of my ultrasonic sensor (Euklid A-14P20) into my arduino due.
For more input:
The idea and working process at this moment is like this. I have a arduino due which generates a 10 * 40 kHz Burst. Which is level shifted to another voltage and input into the ultrasonic sensor. Afterword the signal is amplified by a amplifier stage and put through a schmitt tirgger and a level shifter to get a +3,3V / 0V input singal into the arduino due.

Now to my problem. I don't know how to analyze this signal in a programming code. Because the code would have to impliment the following things:

• Difference between the time when the burst was send and the signal was received (->distance)
• Sampling of the frequency to analyze if it is the 40 kHz pulse
• Count if the received signal has 10 * 40 kHz pulses

Does anybody have some tips or a code example for my problem?
I'm more of a hardware guy than a software

Thanks for the help!

bobberle

sounds like you would like an internal oscilloscope.

not sure how much spare memory is available, but you capture data in a circular buffer and dump it after you run an experiment. presumably you don’t want to print anything during the test because it would introduce delays.

i’m not sure if you data is simply a binary output and input, 2 bits, or if each is wider (# bits).

if it’s just binary (2 bits), i would capture a 16 bit value composed of the value from micro() << 2, the output << 1 and the input.

dump it to the serial monitor look at it on your laptop. i fond of using awk for post processing and using xgraph for uncomplicated plotting. (xgraph is better for interactive analysis than generating nice plots for articles)

it’s not clear why you amplify the received signal and pass it thru a schmitt trigger (7414, 555?) and then level shift for a digital input. is the output of the sensor a sine wave or digital? should a 40kHz detector be used

Then you must know where you need to grab the signal: " Afterword the signal is amplified by a amplifier stage and put through a schmitt tirgger". Right here is your signal to be analyzed. Probably need an amplifier.

Paul

gcjr:
sounds like you would like an internal oscilloscope.

not sure how much spare memory is available, but you capture data in a circular buffer and dump it after you run an experiment. presumably you don’t want to print anything during the test because it would introduce delays.

i’m not sure if you data is simply a binary output and input, 2 bits, or if each is wider (# bits).

if it’s just binary (2 bits), i would capture a 16 bit value composed of the value from micro() << 2, the output << 1 and the input.

dump it to the serial monitor look at it on your laptop. i fond of using awk for post processing and using xgraph for uncomplicated plotting. (xgraph is better for interactive analysis than generating nice plots for articles)

it’s not clear why you amplify the received signal and pass it thru a schmitt trigger (7414, 555?) and then level shift for a digital input. is the output of the sensor a sine wave or digital? should a 40kHz detector be used

I need to amplify my signal which I get from the ultrasonic sensor because I would else have a signal at the output of the sensor of around a few nA. The ultrasonic sensor is really only a sensor. No other electronics.
You could say that I get a binary signal after the schmitt trigger (+/-5V) and also after the level shifter (+3.3V / 0V). The problem of this binary signal is that i don’t know if the pulse width is okay (40kHz → 25µs).
That is why I need to check the pulse width and than the amout of pulses.

Your sensor produces AC voltage, not nA.

Paul

bobberle:

• Difference between the time when the burst was send and the signal was received (->distance)
• Sampling of the frequency to analyze if it is the 40 kHz pulse
• Count if the received signal has 10 * 40 kHz pulses

Does anybody have some tips or a code example for my problem?
I'm more of a hardware guy than a software

Thanks for the help!

bobberle

Have a look at examples using the hc-sr04 ultrasonic sensor to see how they code it to determine distance.

Here a schematic I found online of the hc-sr04 that should give you some ideas of how you could implement the receiving end using hardware.

hope that helps....