3 min read
Tone Actuated Electronic Lock

I designed and created this tone actuated solanoid lock system is designed to only open if it dectects a audible frequency in the range of 410-430Hz The system ustilizes an analogue amplifier/comparator front-end to condition the signal coming from the microphone and MOFET/solenoid backend which will be linked by a microcontroller that measures the frequency of the square wave emitted by the comparator and compares it to the frequency of interest. Once the incoming wave matches the frequency of interest within an acceptable error margin, the microcontroller sends an output voltage to the FET, causing the solenoid to fire. To measure the frequency emitted by the comparator, one approach is to count the number of rising edges of the incoming signal over a specified time period. Careful selection of a clock source and prescaler value is crucial to accurately parse frequencies of interest in the audio range of approximately 50 Hz to 15000 Hz

tone-lock-overview

Front-End

The front end signal chain starts at the line microphone where a signal with a magnitude of apporxi

The microphone only outputs about 3.5 mV peak to peak, so the signal is first passed to a 2N3906 PNP bipolar junction transistor to amplify the signal to approximately 200mV peak to peak. This is then fed into a CD4007 CMOS comparator / relaxation oscillator which converts the sine wave into a square wave that is at the rails. It is then fed into an op-amp in order to reduce the peak to peak voltage of the square to about 1.5 volts so it can be read by the RP2040’s GPIO pins.

tone-lock-schematic

Frontend schematic.

tone-lock-frontend

Frontend prototype.

Back-End

The RP2040 determines the frequency of the audio signal by counting the rising edges of the square wave over a specific period. To reduce noise 100 samples are taken and then averaged, and the lock is only opened if three of the consecutive averages fall within our frequency of interest, in this case 410-430 Hz or G#. Another approach would be to use a FFT library, but we had a lot of fun conditioning the signal so it was a nice square wave, and this kept the code very simple. When the correct tone is detected a GPIO drives a power mosfet which has enough current to drive the beefy solenoid lock. Overall this approached work great and the lock would only open if one specifc key was played on a keyboard.

tone-lock-amp-output

Output from the amplifier

tone-lock-comparator-output

Output from the compartor / relaxation oscilator

tone-lock-miro-input

Output from the opamp / input to the micro