Advice on my self-learning sonar circuit

Hi, for long time now I am looking for a simple and cheap way to measure waterdepth with a sonar. After many attemps, I think I made it. I manage to drive and read echo from a cheap 200 khz transducer with a ESP using the circuit presented in the schematic below. This circuit work well in my 1m test tank but I still need to try it on the field. Unfortunately breadboard is not convenient for outdoor testing, especially with water, so I think I will design a pcb before field testing. Before doing this, I am looking for advice about obvious thing that don't seem right in my circuit? I am self-learning in electronic... Specifically, I would like advices about AC coupling, signal filtering and problem with single supply (vbias) configuration if any?

This circuit work as follow:
Trigger: The ESP send a 200 kHz PWM square signal to the 200 khz center frequency transducer. I have 0 - 340 mV amplitude for this signal.
Pad A: The signal and returning echo (about 26v p-p) is then "scaled" by the oppose diode connected to ground. I obtain about 152 mV p-p signal.
Gain: The scaled signal enter a variable gain stage and get amplified. At point B I measure about 650 mV p-p.
Rectifier: This signal enter the Half-wave rectifier followed by a comparator that allow to produce a square signal that can be monitored by a pulseIn function of the ESP. The output signal is about 0 - 350 mV. I could certainly use more gain here!

The circuit work but have some specific behavior I don't understand.
The variable gain stage don't amplify much. I selected the OPA2320 for GBP of 20 Mhz. From the datasheet it should amplify by a gain of up to 40 at 200 khz (fig 4 page 10 here: https://www.ti.com/lit/ds/symlink/opa2320.pdf?ts=1679948880076&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FOPA2320). I can only obtain about 4. I would like to have more since I think that the echo will become smaller with increase depth and this transducer can work in it's original state up to 100m while my test are only 1m depth.

Another weird thing (for me!) is that I need to apply about 1 volt on pin 5 of the opamp forming the half-wave rectifier. If I connect the pin to Vbias or to ground, the stage don't work. At 1 volt, I have a rectified signal looking like a enveloppe follower. Why it only work with 1 volt?

There is 2 comparators. Only one is really needed. If I could use the other half for a better purpose (like adding gain to the rectified signal or before?), I am fully open to advices here!

Capacitor C2 just close to point A is 10 pF. I think this ne have to do with the resonance of the transducer. It might need to be precisely determine? I tried with value from 10 pF up to 100 nf. From what I could tell, the higher the farad, the lower is my signal at pad A. Since I don't have lower value than 10 pF. It's 10 pF for now.

I have pictures of the signal at each point T, A, B, C and D of the circuit and can add them to the post if needed.

Thank you for your help, time and advice.
Charles

Probably with about 200 VAC drive voltage. What is your drive voltage?

The schematic lacks 100 nF decoupling capacitors on each of the op amps. They are essential for proper performance, mounted as closely as possible to the power and ground pins.

I measure 28Vcc on my oscilloscope.

The mosfet may not turn fully on at 200khz. I only manage to have 450-500 mV PWM signal strenght at the gate input. This is the max I can get If I remove R1.

That is a serious problem. You need a MOSFET driver for that transistor.

You could try setting the current limit (drive strength) on the ESP (32?) port pin to maximum, but the driver is a better choice.

Because of your comments, I tried to use a comparator to drive the mosfet this morning. The MCP6002 was to slow and gave me triangular spike (no surprise). The same circuit with a OPA gave me the expected square PWM but not at rail voltage. It remained at 400-500 mV.

If I connect a fix DC voltage on the Vin port and decrease the comparator voltage, Vout reach the rail voltage. If I connect the ESP PWM signal instead of the fix voltage, I get the DC rail value (3.3 volt) but the PWM signal don't change and is about 400-500mV (or more or less Vin...).

In other words, the DC signal seem to behave like I expect but the 200khz signal have is own set of rules that I don't get.

A MOSFET driver can provide Amperes of gate current.

The problem is that the gate is a rather large capacitor, and you need to charge that capacitor rapidly in order to switch rapidly. See this application note.

Should I conclude that a mosfet is to slow for my task and I should find something else?

I have optocoupler and some transistors. Opto are easy to use but I feel they are slow. Transistor is a more complex thing.

No, your drive circuit is not capable of providing the current needed to charge the MOSFET gate.

You really need to learn MOSFET basics.

I understand the need for a driver. I tried to implement it with various circuit today. OPAMP has buffer or with gain, another mosfet to drive the mosfet. A NPN transistor to drive the gate. No success.
Each solution endup just like my opamp gain stage above. They do amplify the average DC voltage in a predictable way but the square pulse remained at the same level (Vin = Vout or Vin=-Vout when trying inverting opamp) and the mosfet behave just the same and don't turn on enough.

The GPIO signal of the ESP is 3.3 volts if I turn the pin High.
At 200 khz burst mode like I am using now, I was expecting to see a sequence of 0 / 3.3v pulses but the voltage is much lower (+-350 / 450mV).
I send twenty consecutive ON/OFF pulses for 100 uS. Each pulse is 5 uS and after this the gpio is LOW for 1 sec (minus the 100 uS pulses). This corresponded to 100 uS ON over 1000000 uS. Since fully ON correspond to 3.3 volts, I should have 0.33 mV and never trigger the Mosfet with such pulses. This do not match my oscilloscope reading of around 400 mV at the gate pin. This also do not match my observation since the mosfet do trigger (maybe not enough but it do turn ON).
Does this mismatch is related to the gate capacitance integrating the pulsations?

Why the OpAmp do not boost my Pulse max voltage value? I initially assumed it was AC but it really only is a DC signal and should follow typical opamp gain setting.

That is most likely because none of the circuits you tried can deliver the current required to charge the MOSFET gate capacitance.

The engineers that I worked for used NPN/PNP push-pull drivers for MOSFETS. I don't remember the exact circuit details.

What is the complete part number of the MOSFET? FQ30 seems to be an abbreviation. We could make some assumptions about what it stands for, but why don't you just tell us.
image

Please show a screenshot of Vgs (the voltage at the gate relative to the source) from your oscilloscope, for one or two cycles, with the ESP (ESP32? ESP8266?) as the driver, and with your best shot at some other DIY driver.

This is the datasheet for the FQP30NL06 N-channel Mosfet I use : https://cdn.sparkfun.com/datasheets/Components/General/FQP30N06L.pdf

I think it's not clear enough from my posts that I have 2 problems (related in a way but also independent). Problem 1. not enough drive capacity. Problem 2. regardless of the drive, I do not succeed to amplify my 0-340 mV 200 khz pulses in anyway even not connected to the mosfet gate. See by yourselfs:
The following pictures show the esp32 pulse trigger (Channel 1 yellow) and the opamp Vout signal (Channel 2 blue) for a basic unity gain buffer circuit, non-inverting and inverting comparator and finally with a gains of 2.
Inverting the signal do work (figure 3) and I even measure close to Vcc on the vout pin with my multimeter but not on the scope. Why?
Gain do not work (figure 4).
FIGURE 1: Vin = Vout and also correspond to Vgs asked by @DaveEvans


FIGURE 2: Vin = Vout

FIGURE 3: The signal is inverted and I get almost Vcc on the DMM but not the scope.

FIGURE 4: Gain of 2 resuylted in a lower Vcc signal!

If I cannot do those basic manipulation and solve problem 2. It's probably to soon to attack problem 1 (driving the gate).

Well, in your shoes, if I couldn't get 3.3 volts out of an ESP pin, I would back up a dozen steps and do the following:

  • disconnect everything from the ESP and toggle a different output pin (not the one or ones you've been using) HIGH and LOW every five seconds or so using digitalWrite(), and observe the voltage on a DMM and oscilloscope.

  • if that shows 3.3v and 0v, then I'd connect an FQP30N06L as shown in the schematic below, with a simple resistive load selected to approximately match the current you expect to need in the sonar circuit, using the same HIGH / LOW sequence every few seconds on the same pin used in the previous test. Drive the R12/R13 junction directly with the ESP pin. No op amp.

  • if that still shows nice clean rise and fall between 3.3v and 0v on the gate, and proper switching of the load, then without changing the physical setup, change the code to PWM. I'd start with a low frequency, ensure that works, and then try your 200 kHz.

  • if that still shows a clean square wave on the gate between 3.3v and 0v, and proper switching of the load, then disconnect the resistive load and connect the sonar load.

image

I get 3.3 volts out of the pin using digitalwrite or ledcwrite at full duty cycle.
Using ledcwrite configure for 200 khz at 0 duty I read 0 volt on both DMM and scope.
Using ledcwrite at 50% duty, I read 1.65 volt on DMM and 448 mV on my scope.
Using ledcwrite at 100% duty, I read 3.3 volt on my DMM and 448 mV again on my scope.

The voltage reads by my DMM change according to PWM duty as expected (0/50% and 100% duty). The Vcc read by my scope is way out no? Maybe this explain the discrepancie seen on figure 3?

Yes, it seems like you aren't correctly operating your scope. Post details on how you are using it (and others will be able to help you...that's outside my wheelhouse).

And perhaps change the title of your thread to "need help with oscilloscope operation" to attract the appropriate people. Or, better yet, start a new thread with that title.

I wonder what "Vcc" means on an oscilloscope screen.

In french this is Voltage Crète à Crète.
In english this is Vpp.

That was the problem. My probe switch are on 10x attenuation while the channel input in the oscilloscope was set to 1x creating a saturation at 4-500 mV. I now read 3.3volts on my pulses.

Maybe a good news. Now that the probe are correctly set, I have 250Vpp on my sonar output. Maybe my drive is already strong enough for a 0-100 m measurement.

Sounds good. Please keep us posted on how it goes.