Sunday, November 18, 2018

Fake ultrasonic transducer

The goal here is to provide a fake ultrasonic transducer that can reproduce a constant echo signal, useful for production testing (produce a known fixed signal that can be tested against) or software development (produce a known fixed signal to determine if math/timing is correct for measuring distance).  An ultrasonic transducer works by converting voltage pulses into ultrasound, and then receiving an ultrasonic echo and converting that back into a voltage that can be read.  By measuring the time between the transmit and the echo received, the distance between the transducer and the floor (or whatever caused the signal to bounce, water, etc) can be determined using the speed of sound.

Recently I was working on a few products using ultrasonic transducers for measuring volume in a tank, and the need for testing or developing without a tank of water was needed.  The product was generating > 100V pulses into the transducer, and the converted echo response was going into an AM detector.  The signals looked like so:


The purple plot is the raw voltage on the product; the first edge is the > 100V signal generated to excite the transducer and the second smaller edge the echo received.  So what we need is a simple circuit that can take >100V, delay a short fixed period of time, and then generate a simple echo.  Here is what I came up with:
These products actually contained 2 transducers, as they were placed in the middle of the tank to measure if the bottom of the floor moved.  For that reason there are two transducer signals on the schematic, XDCR_1 and XDCR_2; however the circuitry for both is the same.  The >100V excited signal goes thru a simple transistor amplifier to bring the voltage down to ~5V and input into a comparator input on the PIC MCU.  The PIC comparator is configured to interrupt if the signal on the PIC MCU pin goes over 4.096V (using the PIC's internal voltage reference as the other input to the comparator).  On a comparator interrupt, the PIC has a short delay and then generates a response echo which goes back to the XDCR_x input thru a Schottky diode.

When I prototyped this design on old development kit with the old PIC16F877A on it, I had no problems.  But after moving to this design with the newer PIC16F18325, the PIC was resetting when the board was sending the >100V ultrasonic pulses.  After removing the Schottky diode to verify it wasn't some kind of weird ground bounce on the circuit, I added the BAV99 diodes to act as transient suppression and the problem went away.  It makes me wonder if Microchip is going cheap on PICs and not making them as hard as they used to.  Otherwise I liked the 16F18325; every pin was peripheral reprogrammable, which allowed me to tie all 3 LEDs to 1 PWM for brightness control.  As a side note, I can't believe how bright surface mount LEDs are getting these days.

Here is what a 3D model of the PCB and the final board (blue jumper wire on the final board is due to having to cram the BAV99 diodes on the design after the PCBs were made):






No comments:

Post a Comment